module OmniFocus::Extrabrain
Constants
- PREFIX
- VERSION
Public Instance Methods
client(url)
click to toggle source
# File lib/omnifocus/extrabrain.rb, line 63 def client(url) headers = { :accept => :json, :content_type => :json, } RestClient::Resource.new(url, :headers => headers, user: username, password: password) end
get_tasks(team, page)
click to toggle source
# File lib/omnifocus/extrabrain.rb, line 86 def get_tasks(team, page) team_resource = client("https://#{team['subdomain']}.extrabrain.se") json = JSON.parse team_resource["tasks.json?user_id=#{user_id}&page=#{page}"].get return nil if json.nil? || json.empty? json.map { |task_attributes| Task.new(task_attributes.merge team: team) } end
keychain_user()
click to toggle source
# File lib/omnifocus/extrabrain.rb, line 39 def keychain_user params = { server: 'extrabrain.se', protocol: Keychain::Protocols::HTTPS } Keychain.internet_passwords.where(params).first end
password()
click to toggle source
# File lib/omnifocus/extrabrain.rb, line 48 def password @password ||= keychain_user.password end
populate_extrabrain_tasks()
click to toggle source
This is the method ‘of sync` calls.
# File lib/omnifocus/extrabrain.rb, line 53 def populate_extrabrain_tasks teams.each do |team| page = 1 while tasks = get_tasks(team, page) do tasks.each { |task| process_extrabrain_task(task, team) } page = page + 1 end end end
process_extrabrain_task(task, team)
click to toggle source
# File lib/omnifocus/extrabrain.rb, line 93 def process_extrabrain_task(task, team) if existing[task.ticket_id] bug_db[existing[task.ticket_id]][task.ticket_id] = true else title = "#{task.ticket_id}: #{task.title}" description = task.url bug_db[task.project_title][task.ticket_id] = [title, description] end end
resource()
click to toggle source
# File lib/omnifocus/extrabrain.rb, line 82 def resource @resource ||= client('https://extrabrain.se') end
teams()
click to toggle source
# File lib/omnifocus/extrabrain.rb, line 71 def teams JSON.parse resource['teams.json'].get end
user_id()
click to toggle source
# File lib/omnifocus/extrabrain.rb, line 75 def user_id @user_id ||= begin current_user = JSON.parse resource['users/current.json'].get current_user['user']['id'] end end
username()
click to toggle source
# File lib/omnifocus/extrabrain.rb, line 44 def username @username ||= keychain_user.account end