omnifocus-extrabrain 1.0.0 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 482430b2d510bd5ee974bb8624ece950e16a7085
4
- data.tar.gz: e29adfaf64c3fc92a714d90113ac5d1e5f5c2c71
3
+ metadata.gz: 9338e6fe76c74d2663d71b5086fe01eab256254a
4
+ data.tar.gz: 4d66acef1590db5a5606b9a9d34245c0a41ba6f2
5
5
  SHA512:
6
- metadata.gz: 8f02dd03246369b5043d452a24f0e99b3bad4b3516abead0ff7735d2176c450bedee8671e5fb27289bd7ac60c4c7d30ec90ce04da1f378cbc060c6ec09e3c54a
7
- data.tar.gz: 1cc2f4f8dcc94cb58af7baf21b879b4d66a0994652086622efc1646b672704e68330b967e99263c0fc921cf5231bbced94da093f158177170147ab83cc6d7950
6
+ metadata.gz: 64d1870941a4d35c8bfbe75a38071e33013866d1f6b5f18bdb788fb12e4f98c2304720a3b3a9a8105c6ba5a86d03b6410154c9519228dda4686942038387e82d
7
+ data.tar.gz: 58d071e03f7b11a2c93566491111943af4ad2f94807a0e766eb3de88500cbcfa3e4d38edaa66eb63262b40eedf32bca83de8b1d35b824256f9883d7267abddda
data/README.md CHANGED
@@ -38,6 +38,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
38
38
 
39
39
  ### Some todos, will you or me fix them first?
40
40
 
41
- [ ] Allows user to choose between keychain or other authentication method
42
- [ ] If no keychain for Extrabrain exists, ask user if one should be created and create one from the credentials the user gives.
41
+ Allows user to choose between keychain or other authentication method
42
+
43
+ ❒ If no keychain for Extrabrain exists, ask user if one should be created and create one from the credentials the user gives.
43
44
 
@@ -1,98 +1,96 @@
1
1
  require 'rest-client'
2
2
  require 'keychain'
3
3
 
4
- module OmniFocus
5
- module Extrabrain
6
- PREFIX = 'EB'
7
-
8
- class Task
9
- attr_accessor :id, :title, :project_title
10
-
11
- def initialize(attrs = {})
12
- attrs.each do |attribute, value|
13
- setter = "#{attribute}="
14
- if respond_to? setter
15
- public_send setter, value
16
- end
17
- end
18
- end
4
+ module OmniFocus::Extrabrain
5
+ PREFIX = 'EB'
19
6
 
20
- def ticket_id
21
- "#{PREFIX}-#{project_title}##{id}"
22
- end
7
+ class Task
8
+ attr_accessor :id, :title, :project_title
23
9
 
24
- def project_title
25
- if @project_title.to_s.gsub(' ', '') == ''
26
- 'Miscellaneous'
27
- else
28
- @project_title
10
+ def initialize(attrs = {})
11
+ attrs.each do |attribute, value|
12
+ setter = "#{attribute}="
13
+ if respond_to? setter
14
+ public_send setter, value
29
15
  end
30
16
  end
31
17
  end
32
18
 
33
- def keychain_user
34
- params = { server: 'extrabrain.se', protocol: Keychain::Protocols::HTTPS }
35
- Keychain.internet_passwords.where(params).first
19
+ def ticket_id
20
+ "#{PREFIX}-#{project_title}##{id}"
36
21
  end
37
22
 
38
- def username
39
- @username ||= keychain_user.account
23
+ def project_title
24
+ if @project_title.to_s.gsub(' ', '') == ''
25
+ 'Miscellaneous'
26
+ else
27
+ @project_title
28
+ end
40
29
  end
30
+ end
41
31
 
42
- def password
43
- @password ||= keychain_user.password
44
- end
32
+ def keychain_user
33
+ params = { server: 'extrabrain.se', protocol: Keychain::Protocols::HTTPS }
34
+ Keychain.internet_passwords.where(params).first
35
+ end
45
36
 
46
- # This is the method `of sync` calls.
47
- def populate_extrabrain_tasks
48
- teams.each do |team|
49
- page = 1
37
+ def username
38
+ @username ||= keychain_user.account
39
+ end
50
40
 
51
- while tasks = get_tasks(team, page) do
52
- tasks.each { |t| process_extrabrain_task(t, team) }
53
- page = page + 1
54
- end
41
+ def password
42
+ @password ||= keychain_user.password
43
+ end
44
+
45
+ # This is the method `of sync` calls.
46
+ def populate_extrabrain_tasks
47
+ teams.each do |team|
48
+ page = 1
49
+
50
+ while tasks = get_tasks(team, page) do
51
+ tasks.each { |t| process_extrabrain_task(t, team) }
52
+ page = page + 1
55
53
  end
56
54
  end
55
+ end
57
56
 
58
- def client(url)
59
- headers = {
60
- :accept => :json,
61
- :content_type => :json,
62
- }
63
- RestClient::Resource.new(url, :headers => headers, user: username, password: password)
64
- end
57
+ def client(url)
58
+ headers = {
59
+ :accept => :json,
60
+ :content_type => :json,
61
+ }
62
+ RestClient::Resource.new(url, :headers => headers, user: username, password: password)
63
+ end
65
64
 
66
- def teams
67
- JSON.parse resource['teams.json'].get
68
- end
65
+ def teams
66
+ JSON.parse resource['teams.json'].get
67
+ end
69
68
 
70
- def user_id
71
- @user_id ||= begin
72
- current_user = JSON.parse resource['users/current.json'].get
73
- current_user['user']['id']
74
- end
75
- end
69
+ def user_id
70
+ @user_id ||= begin
71
+ current_user = JSON.parse resource['users/current.json'].get
72
+ current_user['user']['id']
73
+ end
74
+ end
76
75
 
77
- def resource
78
- @resource ||= client('https://extrabrain.se')
79
- end
76
+ def resource
77
+ @resource ||= client('https://extrabrain.se')
78
+ end
80
79
 
81
80
 
82
- def get_tasks(team, page)
83
- team_resource = client("https://#{team['subdomain']}.extrabrain.se")
84
- json = JSON.parse team_resource["tasks.json?user_id=#{user_id}&page=#{page}"].get
85
- return nil if json.nil? || json.empty?
86
- json.map { |task_attributes| Task.new(task_attributes) }
87
- end
81
+ def get_tasks(team, page)
82
+ team_resource = client("https://#{team['subdomain']}.extrabrain.se")
83
+ json = JSON.parse team_resource["tasks.json?user_id=#{user_id}&page=#{page}"].get
84
+ return nil if json.nil? || json.empty?
85
+ json.map { |task_attributes| Task.new(task_attributes) }
86
+ end
88
87
 
89
- def process_extrabrain_task(task, team)
90
- description = "https://#{team['subdomain']}.extrabrain.se/tasks/#{task.id}"
91
- if existing[task.ticket_id]
92
- bug_db[task.project_title][task.ticket_id] = true
93
- return
94
- end
95
- bug_db[task.project_title][task.ticket_id] = [task.title, description]
88
+ def process_extrabrain_task(task, team)
89
+ description = "https://#{team['subdomain']}.extrabrain.se/tasks/#{task.id}"
90
+ if existing[task.ticket_id]
91
+ bug_db[task.project_title][task.ticket_id] = true
92
+ return
96
93
  end
94
+ bug_db[task.project_title][task.ticket_id] = [task.title, description]
97
95
  end
98
96
  end
@@ -1,5 +1,5 @@
1
1
  module OmniFocus
2
2
  module Extrabrain
3
- VERSION = "1.0.0"
3
+ VERSION = "1.0.1"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omnifocus-extrabrain
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Ross
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-06-06 00:00:00.000000000 Z
11
+ date: 2015-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client