omnifocus-extrabrain 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/lib/omnifocus/extrabrain.rb +69 -71
- data/lib/omnifocus/extrabrain/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9338e6fe76c74d2663d71b5086fe01eab256254a
|
4
|
+
data.tar.gz: 4d66acef1590db5a5606b9a9d34245c0a41ba6f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
42
|
-
|
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
|
|
data/lib/omnifocus/extrabrain.rb
CHANGED
@@ -1,98 +1,96 @@
|
|
1
1
|
require 'rest-client'
|
2
2
|
require 'keychain'
|
3
3
|
|
4
|
-
module OmniFocus
|
5
|
-
|
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
|
-
|
21
|
-
|
22
|
-
end
|
7
|
+
class Task
|
8
|
+
attr_accessor :id, :title, :project_title
|
23
9
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
34
|
-
|
35
|
-
Keychain.internet_passwords.where(params).first
|
19
|
+
def ticket_id
|
20
|
+
"#{PREFIX}-#{project_title}##{id}"
|
36
21
|
end
|
37
22
|
|
38
|
-
def
|
39
|
-
@
|
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
|
-
|
43
|
-
|
44
|
-
|
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
|
-
|
47
|
-
|
48
|
-
|
49
|
-
page = 1
|
37
|
+
def username
|
38
|
+
@username ||= keychain_user.account
|
39
|
+
end
|
50
40
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
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
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
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
|
-
|
67
|
-
|
68
|
-
|
65
|
+
def teams
|
66
|
+
JSON.parse resource['teams.json'].get
|
67
|
+
end
|
69
68
|
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
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
|
-
|
78
|
-
|
79
|
-
|
76
|
+
def resource
|
77
|
+
@resource ||= client('https://extrabrain.se')
|
78
|
+
end
|
80
79
|
|
81
80
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
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
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
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
|
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.
|
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-
|
11
|
+
date: 2015-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|