factor-connector-pivotal 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 395bb44b325addb67f1c98a97e81d3cb8015cc61
4
+ data.tar.gz: c5ed28b450c79840a2a56b8c3693f4df31da7220
5
+ SHA512:
6
+ metadata.gz: d0f5faadbaddf65bdd1a9441ac11460ce6fe4704428d528b354035ebc98a0f89a7428101aa795383267c23908e3d3bf64a37dfc9fdc25537dcc47d5e10aefed9
7
+ data.tar.gz: 0d4ccc513e93249b4cc7681b244326c227eb766d3b3676ee6a03414e8e85b465278e2e34d5ee9e281c5377919de742d53e9c754c99a199cef5344742aab0349f
@@ -0,0 +1,176 @@
1
+ require 'factor-connector-api'
2
+ require 'pivotal-tracker'
3
+
4
+ Factor::Connector.service 'pivotal_notes' do
5
+ action 'get' do |params|
6
+ api_key = params['api_key']
7
+ project_id = params['project']
8
+ story_id = params['story']
9
+ id = params['id']
10
+
11
+ fail 'API Key (api_key) are required' unless api_key
12
+ fail 'Project ID (project) is required' unless project_id
13
+ fail 'Project ID (project) must be an integer' unless project_id.is_a?(Integer)
14
+ fail 'Story ID (story) is required' unless story_id
15
+ fail 'Story ID (story) must be an Integer' unless story_id.is_a?(Integer)
16
+ fail 'Note ID (id) is required' unless id
17
+ fail 'Note ID (id) must be an integer' unless id.is_a?(Integer)
18
+
19
+
20
+ info 'Initializing Pivotal Tracker Client'
21
+ PivotalTracker::Client.token = api_key
22
+
23
+ info "Getting project with ID #{project_id.to_s}"
24
+ begin
25
+ project = PivotalTracker::Project.find(project_id)
26
+ rescue
27
+ fail "Failed to get the project with id #{project_id.to_s}, check your credentials"
28
+ end
29
+
30
+ fail "No project with id #{project_id.to_s} found" unless project
31
+
32
+ info "Getting story with id #{story_id.to_s}"
33
+ begin
34
+ story = project.stories.find(story_id)
35
+ rescue
36
+ fail "Failed to get stories, check your credentials"
37
+ end
38
+
39
+ fail "No stories found" unless story
40
+
41
+ info "Getting note with id #{id.to_s}"
42
+ begin
43
+ raw_note = story.notes.find(id)
44
+ rescue
45
+ fail "Failed to get note, check your credentials"
46
+ end
47
+
48
+ fail "No note found" unless raw_note
49
+
50
+ return_note = raw_note.instance_variables.each_with_object({}) do |v, h|
51
+ val = raw_note.instance_variable_get(v)
52
+ if val.is_a?(DateTime)
53
+ h[v.to_s.delete('@')] = val.iso8601
54
+ else
55
+ h[v.to_s.delete('@')] = val
56
+ end
57
+ end
58
+
59
+ action_callback return_note
60
+ end
61
+
62
+ action 'all' do |params|
63
+ api_key = params['api_key']
64
+ project_id = params['project']
65
+ story_id = params['story']
66
+
67
+ fail 'API Key (api_key) are required' unless api_key
68
+ fail 'Project ID (project) is required' unless project_id
69
+ fail 'Project ID (project) must be an integer' unless project_id.is_a?(Integer)
70
+ fail 'Story ID (story) is required' unless story_id
71
+ fail 'Story ID (story) must be an Integer' unless story_id.is_a?(Integer)
72
+
73
+
74
+ info 'Initializing Pivotal Tracker Client'
75
+ PivotalTracker::Client.token = api_key
76
+
77
+ info "Getting project with ID #{project_id.to_s}"
78
+ begin
79
+ project = PivotalTracker::Project.find(project_id)
80
+ rescue
81
+ fail "Failed to get the project with id #{project_id.to_s}, check your credentials"
82
+ end
83
+
84
+ fail "No project with id #{project_id.to_s} found" unless project
85
+
86
+ info "Getting story with id #{story_id.to_s}"
87
+ begin
88
+ story = project.stories.find(story_id)
89
+ rescue
90
+ fail "Failed to get stories, check your credentials"
91
+ end
92
+
93
+ fail "No stories found" unless story
94
+
95
+ info "Getting notes from story"
96
+ begin
97
+ raw_notes = story.notes.all
98
+ rescue
99
+ fail "Failed to get note, check your credentials"
100
+ end
101
+
102
+ fail "No note found" unless raw_notes
103
+
104
+ return_notes = raw_notes.map do |raw_note|
105
+ raw_note.instance_variables.each_with_object({}) do |v, h|
106
+ val = raw_note.instance_variable_get(v)
107
+ if val.is_a?(DateTime)
108
+ h[v.to_s.delete('@')] = val.iso8601
109
+ else
110
+ h[v.to_s.delete('@')] = val
111
+ end
112
+ end
113
+ end
114
+
115
+ action_callback return_notes
116
+ end
117
+
118
+ action 'create' do |params|
119
+ api_key = params['api_key']
120
+ project_id = params['project']
121
+ story_id = params['story']
122
+
123
+ fail 'API Key (api_key) are required' unless api_key
124
+ fail 'Project ID (project_id) is required' unless project_id
125
+ fail 'Project ID (project_id) must be an integer' unless project_id.is_a?(Integer)
126
+ fail 'Story ID (story) is required' unless story_id
127
+ fail 'Story ID (story) must be an Integer' unless story_id.is_a?(Integer)
128
+
129
+
130
+ info 'Initializing Pivotal Tracker Client'
131
+ PivotalTracker::Client.token = api_key
132
+
133
+ info "Getting project with ID #{project_id.to_s}"
134
+ begin
135
+ project = PivotalTracker::Project.find(project_id)
136
+ rescue
137
+ fail "Failed to get the project with id #{project_id.to_s}, check your credentials"
138
+ end
139
+
140
+ fail "No project with id #{project_id.to_s} found" unless project
141
+
142
+ info "Getting story with id #{story_id.to_s}"
143
+ begin
144
+ story = project.stories.find(story_id)
145
+ rescue
146
+ fail "Failed to get stories, check your credentials"
147
+ end
148
+
149
+ fail "No stories found" unless story
150
+
151
+ fields = %w(text author noted_at)
152
+ note_fields = params.select do |key, value|
153
+ fields.include?(key)
154
+ end
155
+
156
+ begin
157
+ raw_note = story.notes.create(note_fields)
158
+ rescue
159
+ fail "Failed to create the note, check the fields"
160
+ end
161
+
162
+ fail "Failed to create the note" unless raw_note
163
+
164
+ return_note = raw_note.instance_variables.each_with_object({}) do |v, h|
165
+ val = raw_note.instance_variable_get(v)
166
+ if val.is_a?(DateTime)
167
+ h[v.to_s.delete('@')] = val.iso8601
168
+ else
169
+ h[v.to_s.delete('@')] = val
170
+ end
171
+ end
172
+
173
+ action_callback return_note
174
+ end
175
+
176
+ end
@@ -0,0 +1,59 @@
1
+ require 'factor-connector-api'
2
+ require 'pivotal-tracker'
3
+
4
+ Factor::Connector.service 'pivotal_projects' do
5
+ action 'get' do |params|
6
+ api_key = params['api_key']
7
+ id = params['id']
8
+
9
+ fail 'API Key (api_key) are required' unless api_key
10
+ fail 'Project ID (id) is required' unless id
11
+ fail 'Project ID (id) must be an integer' unless id.is_a?(Integer)
12
+
13
+ info 'Initializing Pivotal Tracker Client'
14
+ PivotalTracker::Client.token = api_key
15
+
16
+ info "Getting project with ID #{id.to_s}"
17
+ begin
18
+ raw_project = PivotalTracker::Project.find(id)
19
+ rescue
20
+ fail "Failed to get the project with id #{id.to_s}, check your credentials"
21
+ end
22
+ fail "No project with id #{id.to_s} found" unless raw_project
23
+
24
+ project = raw_project.instance_variables.each_with_object({}) do |v, h|
25
+ val = raw_project.instance_variable_get(v)
26
+ id = v.to_s.delete('@')
27
+ if val.is_a?(DateTime)
28
+ h[id] = val.iso8601
29
+ else
30
+ h[id] = val
31
+ end
32
+ end
33
+
34
+ action_callback project
35
+ end
36
+
37
+ action 'all' do |params|
38
+ api_key = params['api_key']
39
+
40
+ fail 'API Key (api_key) are required' unless api_key
41
+
42
+ info 'Initializing Pivotal Tracker Client'
43
+ PivotalTracker::Client.token = api_key
44
+
45
+ info 'Getting list of projects'
46
+ projects = PivotalTracker::Project.all.map do |project|
47
+ project.instance_variables.each_with_object({}) do |v, h|
48
+ val = p.instance_variable_get(v)
49
+ if val.is_a?(DateTime)
50
+ h[v.to_s.delete('@')] = val.iso8601
51
+ else
52
+ h[v.to_s.delete('@')] = val
53
+ end
54
+ end
55
+ end
56
+
57
+ action_callback projects
58
+ end
59
+ end
@@ -0,0 +1,256 @@
1
+ require 'factor-connector-api'
2
+ require 'pivotal-tracker'
3
+
4
+ Factor::Connector.service 'pivotal_stories' do
5
+ action 'get' do |params|
6
+ api_key = params['api_key']
7
+ project_id = params['project']
8
+ id = params['id']
9
+
10
+ fail 'API Key (api_key) are required' unless api_key
11
+ fail 'Project ID (project_id) is required' unless project_id
12
+ fail 'Project ID (project_id) must be an integer' unless project_id.is_a?(Integer)
13
+ fail 'Story ID (id) is required' unless id
14
+ fail 'Story ID (id) must be an Integer' unless id.is_a?(Integer)
15
+
16
+
17
+ info 'Initializing Pivotal Tracker Client'
18
+ PivotalTracker::Client.token = api_key
19
+
20
+ info "Getting project with ID #{project_id.to_s}"
21
+ begin
22
+ project = PivotalTracker::Project.find(project_id)
23
+ rescue
24
+ fail "Failed to get the project with id #{project_id.to_s}, check your credentials"
25
+ end
26
+
27
+ fail "No project with id #{project_id.to_s} found" unless project
28
+
29
+ info "Getting story with id #{id.to_s}"
30
+ begin
31
+ raw_story = project.stories.find(id)
32
+ rescue
33
+ fail "Failed to get stories, check your credentials and filter"
34
+ end
35
+
36
+ fail "No stories found" unless raw_story
37
+
38
+
39
+ story = raw_story.instance_variables.each_with_object({}) do |v, h|
40
+ val = raw_story.instance_variable_get(v)
41
+ if val.is_a?(DateTime)
42
+ h[v.to_s.delete('@')] = val.iso8601
43
+ else
44
+ h[v.to_s.delete('@')] = val
45
+ end
46
+ end
47
+
48
+ action_callback story
49
+ end
50
+
51
+ action 'all' do |params|
52
+ api_key = params['api_key']
53
+ project_id = params['project']
54
+ filter = params['filter'] || {}
55
+
56
+ fail 'API Key (api_key) are required' unless api_key
57
+ fail 'Project ID (project_id) is required' unless project_id
58
+ fail 'Project ID (project_id) must be an integer' unless project_id.is_a?(Integer)
59
+ fail 'Filter (filter) must be a Hash' unless filter.is_a?(Hash)
60
+
61
+
62
+ info 'Initializing Pivotal Tracker Client'
63
+ PivotalTracker::Client.token = api_key
64
+
65
+ info "Getting project with ID #{project_id.to_s}"
66
+ begin
67
+ project = PivotalTracker::Project.find(project_id)
68
+ rescue
69
+ fail "Failed to get the project with id #{project_id.to_s}, check your credentials"
70
+ end
71
+
72
+ fail "No project with id #{project_id.to_s} found" unless project
73
+
74
+ info 'Getting list of stories'
75
+ begin
76
+ stories = filter == {} ? project.stories.all : project.stories.all(filter)
77
+ rescue
78
+ fail "Failed to get stories, check your credentials and filter"
79
+ end
80
+
81
+ fail "No stories found" unless stories
82
+
83
+
84
+ stories = stories.map do |story|
85
+ story.instance_variables.each_with_object({}) do |v, h|
86
+ val = story.instance_variable_get(v)
87
+ if val.is_a?(DateTime)
88
+ h[v.to_s.delete('@')] = val.iso8601
89
+ else
90
+ h[v.to_s.delete('@')] = val
91
+ end
92
+ end
93
+ end
94
+
95
+ action_callback stories
96
+ end
97
+
98
+ action 'create' do |params|
99
+ api_key = params['api_key']
100
+ project_id = params['project']
101
+
102
+ fail 'API Key (api_key) are required' unless api_key
103
+ fail 'Project ID (project_id) is required' unless project_id
104
+ fail 'Project ID (project_id) must be an integer' unless project_id.is_a?(Integer)
105
+
106
+ info 'Initializing Pivotal Tracker Client'
107
+ PivotalTracker::Client.token = api_key
108
+
109
+ info "Getting project with ID #{project_id.to_s}"
110
+ begin
111
+ project = PivotalTracker::Project.find(project_id)
112
+ rescue
113
+ fail "Failed to get the project with id #{project_id.to_s}, check your credentials"
114
+ end
115
+
116
+ fail "No project with id #{project_id.to_s} found" unless project
117
+
118
+
119
+ fields = %w(name description story_type estimate current_state requested_by owned_by labels jira_id jira_url other_id zendesk_id zendesk_url integration_id deadline)
120
+
121
+ story_fields = params.select do |key, value|
122
+ fields.include?(key)
123
+ end
124
+
125
+ begin
126
+ raw_story = project.stories.create(story_fields)
127
+ rescue
128
+ fail "Failed to create the story, check the fields"
129
+ end
130
+
131
+ fail "Failed to create the story" unless raw_story
132
+
133
+ story = raw_story.instance_variables.each_with_object({}) do |v, h|
134
+ val = raw_story.instance_variable_get(v)
135
+ if val.is_a?(DateTime)
136
+ h[v.to_s.delete('@')] = val.iso8601
137
+ else
138
+ h[v.to_s.delete('@')] = val
139
+ end
140
+ end
141
+
142
+ action_callback story
143
+ end
144
+
145
+ action 'update' do |params|
146
+ api_key = params['api_key']
147
+ project_id = params['project']
148
+ id = params['id']
149
+
150
+ fail 'API Key (api_key) are required' unless api_key
151
+ fail 'Project ID (project_id) is required' unless project_id
152
+ fail 'Project ID (project_id) must be an integer' unless project_id.is_a?(Integer)
153
+ fail 'Story ID (id) is required' unless id
154
+ fail 'Story ID (id) must be an Integer' unless id.is_a?(Integer)
155
+
156
+
157
+ info 'Initializing Pivotal Tracker Client'
158
+ PivotalTracker::Client.token = api_key
159
+
160
+ info "Getting project with ID #{project_id.to_s}"
161
+ begin
162
+ project = PivotalTracker::Project.find(project_id)
163
+ rescue
164
+ fail "Failed to get the project with id #{project_id.to_s}, check your credentials"
165
+ end
166
+
167
+ fail "No project with id #{project_id.to_s} found" unless project
168
+
169
+ info "Getting story with id #{id.to_s}"
170
+ begin
171
+ story = project.stories.find(id)
172
+ rescue
173
+ fail "Failed to get stories, check your credentials and filter"
174
+ end
175
+
176
+ fail "No stories found" unless story
177
+
178
+ fields = %w(name description story_type estimate current_state requested_by owned_by labels jira_id jira_url other_id zendesk_id zendesk_url integration_id deadline)
179
+
180
+ story_fields = params.select do |key, value|
181
+ fields.include?(key)
182
+ end
183
+
184
+ begin
185
+ new_story = story.update(story_fields)
186
+ rescue
187
+ fail "Failed to update the story for unknown reason"
188
+ end
189
+
190
+ return_story = new_story.instance_variables.each_with_object({}) do |v, h|
191
+ val = new_story.instance_variable_get(v)
192
+ if val.is_a?(DateTime)
193
+ h[v.to_s.delete('@')] = val.iso8601
194
+ else
195
+ h[v.to_s.delete('@')] = val
196
+ end
197
+ end
198
+
199
+ action_callback return_story
200
+ end
201
+
202
+ action 'delete' do |params|
203
+ api_key = params['api_key']
204
+ project_id = params['project']
205
+ id = params['id']
206
+
207
+ fail 'API Key (api_key) are required' unless api_key
208
+ fail 'Project ID (project_id) is required' unless project_id
209
+ fail 'Project ID (project_id) must be an integer' unless project_id.is_a?(Integer)
210
+ fail 'Story ID (id) is required' unless id
211
+ fail 'Story ID (id) must be an Integer' unless id.is_a?(Integer)
212
+
213
+
214
+ info 'Initializing Pivotal Tracker Client'
215
+ PivotalTracker::Client.token = api_key
216
+
217
+ info "Getting project with ID #{project_id.to_s}"
218
+ begin
219
+ project = PivotalTracker::Project.find(project_id)
220
+ rescue
221
+ fail "Failed to get the project with id #{project_id.to_s}, check your credentials"
222
+ end
223
+
224
+ fail "No project with id #{project_id.to_s} found" unless project
225
+
226
+ info "Getting story with id #{id.to_s}"
227
+ begin
228
+ story = project.stories.find(id)
229
+ rescue
230
+ fail "Failed to get stories, check your credentials and filter"
231
+ end
232
+
233
+ warn "No stories found" unless story
234
+
235
+ if story
236
+ begin
237
+ new_story = story.delete
238
+ rescue
239
+ fail "Failed to delete story for unknown reason"
240
+ end
241
+ else
242
+ warn "No stories found, nothing to delete"
243
+ end
244
+
245
+ return_story = new_story.instance_variables.each_with_object({}) do |v, h|
246
+ val = new_story.instance_variable_get(v)
247
+ if val.is_a?(DateTime)
248
+ h[v.to_s.delete('@')] = val.iso8601
249
+ else
250
+ h[v.to_s.delete('@')] = val
251
+ end
252
+ end
253
+
254
+ action_callback return_story
255
+ end
256
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: factor-connector-pivotal
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
5
+ platform: ruby
6
+ authors:
7
+ - Maciej Skierkowski
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: factor-connector-api
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.13
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.13
27
+ - !ruby/object:Gem::Dependency
28
+ name: pivotal-tracker
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.5.12
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.5.12
41
+ - !ruby/object:Gem::Dependency
42
+ name: codeclimate-test-reporter
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.4.1
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.4.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.1.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.1.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 10.3.2
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 10.3.2
83
+ - !ruby/object:Gem::Dependency
84
+ name: wrong
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.7.1
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.7.1
97
+ description:
98
+ email:
99
+ - maciej@factor.io
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - lib/factor/connector/pivotal_notes.rb
105
+ - lib/factor/connector/pivotal_projects.rb
106
+ - lib/factor/connector/pivotal_stories.rb
107
+ homepage: https://factor.io
108
+ licenses: []
109
+ metadata: {}
110
+ post_install_message:
111
+ rdoc_options: []
112
+ require_paths:
113
+ - lib
114
+ required_ruby_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ required_rubygems_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ requirements: []
125
+ rubyforge_project:
126
+ rubygems_version: 2.2.2
127
+ signing_key:
128
+ specification_version: 4
129
+ summary: Pivotal Tracker Factor.io Connector
130
+ test_files: []