jiraby 0.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.
Files changed (51) hide show
  1. data/.gitignore +9 -0
  2. data/.rspec +3 -0
  3. data/.travis.yml +4 -0
  4. data/.yardopts +8 -0
  5. data/Gemfile +7 -0
  6. data/README.md +132 -0
  7. data/Rakefile +5 -0
  8. data/docs/development.md +20 -0
  9. data/docs/history.md +5 -0
  10. data/docs/ideas.md +54 -0
  11. data/docs/index.md +11 -0
  12. data/docs/usage.md +64 -0
  13. data/jiraby.gemspec +31 -0
  14. data/lib/jiraby.rb +8 -0
  15. data/lib/jiraby/entity.rb +21 -0
  16. data/lib/jiraby/exceptions.rb +8 -0
  17. data/lib/jiraby/issue.rb +109 -0
  18. data/lib/jiraby/jira.rb +319 -0
  19. data/lib/jiraby/json_resource.rb +136 -0
  20. data/lib/jiraby/project.rb +19 -0
  21. data/spec/data/field.json +32 -0
  22. data/spec/data/issue_10002.json +187 -0
  23. data/spec/data/issue_createmeta.json +35 -0
  24. data/spec/data/jira_issues.rb +265 -0
  25. data/spec/data/jira_projects.rb +117 -0
  26. data/spec/data/project_TST.json +97 -0
  27. data/spec/data/search_results.json +26 -0
  28. data/spec/entity_spec.rb +20 -0
  29. data/spec/issue_spec.rb +289 -0
  30. data/spec/jira_spec.rb +314 -0
  31. data/spec/json_resource_spec.rb +222 -0
  32. data/spec/mockapp/config.ru +6 -0
  33. data/spec/mockapp/index.html +10 -0
  34. data/spec/mockapp/jira.rb +61 -0
  35. data/spec/mockapp/views/auth/login_failed.erb +1 -0
  36. data/spec/mockapp/views/auth/login_success.erb +7 -0
  37. data/spec/mockapp/views/error.erb +3 -0
  38. data/spec/mockapp/views/field.erb +32 -0
  39. data/spec/mockapp/views/issue/TST-1.erb +186 -0
  40. data/spec/mockapp/views/issue/createmeta.erb +35 -0
  41. data/spec/mockapp/views/issue/err_nonexistent.erb +1 -0
  42. data/spec/mockapp/views/project/TST.erb +97 -0
  43. data/spec/mockapp/views/project/err_nonexistent.erb +4 -0
  44. data/spec/mockapp/views/search.erb +26 -0
  45. data/spec/project_spec.rb +20 -0
  46. data/spec/spec_helper.rb +26 -0
  47. data/tasks/mockjira.rake +10 -0
  48. data/tasks/pry.rake +28 -0
  49. data/tasks/spec.rake +9 -0
  50. data/tasks/test.rake +8 -0
  51. metadata +288 -0
@@ -0,0 +1,19 @@
1
+ require 'hashie'
2
+ require 'jiraby/entity'
3
+
4
+ module Jiraby
5
+ class Project < Entity
6
+ # Return a hash of issue types for the project, indexed by the name of the
7
+ # issue type.
8
+ #
9
+ def issue_types
10
+ # Index by issue type name
11
+ result = {}
12
+ self['issueTypes'].each do |issue_type|
13
+ result[issue_type['name']] = issue_type
14
+ end
15
+ return result
16
+ end
17
+ end
18
+ end
19
+
@@ -0,0 +1,32 @@
1
+ [
2
+ {
3
+ "id": "description",
4
+ "name": "Description",
5
+ "custom": false,
6
+ "orderable": true,
7
+ "navigable": true,
8
+ "searchable": true,
9
+ "schema": {
10
+ "type": "string",
11
+ "system": "description"
12
+ }
13
+ },
14
+ {
15
+ "id": "summary",
16
+ "name": "Summary",
17
+ "custom": false,
18
+ "schema": {
19
+ "type": "string",
20
+ "system": "summary"
21
+ }
22
+ },
23
+ {
24
+ "id": "customfield_123",
25
+ "name": "My Field",
26
+ "custom": true,
27
+ "schema": {
28
+ "type": "string",
29
+ "system": "customfield_123"
30
+ }
31
+ }
32
+ ]
@@ -0,0 +1,187 @@
1
+ {
2
+ "id": "10002",
3
+ "self": "http://www.example.com/jira/rest/api/2/issue/10002",
4
+ "key": "TST-1",
5
+ "fields": {
6
+ "description": "example bug report",
7
+ "customfield_10001": "custom field value",
8
+ "sub-tasks": [
9
+ {
10
+ "id": "10000",
11
+ "type": {
12
+ "id": "10000",
13
+ "name": "",
14
+ "inward": "Parent",
15
+ "outward": "Sub-task"
16
+ },
17
+ "outwardIssue": {
18
+ "id": "10003",
19
+ "key": "EX-2",
20
+ "self": "http://www.example.com/jira/rest/api/2/issue/EX-2",
21
+ "fields": {
22
+ "status": {
23
+ "iconUrl": "http://www.example.com/jira//images/icons/statuses/open.png",
24
+ "name": "Open"
25
+ }
26
+ }
27
+ }
28
+ }
29
+ ],
30
+ "timetracking": {
31
+ "originalEstimate": "10m",
32
+ "remainingEstimate": "3m",
33
+ "timeSpent": "6m",
34
+ "originalEstimateSeconds": 600,
35
+ "remainingEstimateSeconds": 200,
36
+ "timeSpentSeconds": 400
37
+ },
38
+ "project": {
39
+ "self": "http://www.example.com/jira/rest/api/2/project/EX",
40
+ "id": "10000",
41
+ "key": "EX",
42
+ "name": "Example",
43
+ "avatarUrls": {
44
+ "24x24": "http://www.example.com/jira/secure/projectavatar?size=small&pid=10000",
45
+ "16x16": "http://www.example.com/jira/secure/projectavatar?size=xsmall&pid=10000",
46
+ "32x32": "http://www.example.com/jira/secure/projectavatar?size=medium&pid=10000",
47
+ "48x48": "http://www.example.com/jira/secure/projectavatar?size=large&pid=10000"
48
+ }
49
+ },
50
+ "updated": 1,
51
+ "issuelinks": [
52
+ {
53
+ "id": "10001",
54
+ "type": {
55
+ "id": "10000",
56
+ "name": "Dependent",
57
+ "inward": "depends on",
58
+ "outward": "is depended by"
59
+ },
60
+ "outwardIssue": {
61
+ "id": "10004L",
62
+ "key": "PRJ-2",
63
+ "self": "http://www.example.com/jira/rest/api/2/issue/PRJ-2",
64
+ "fields": {
65
+ "status": {
66
+ "iconUrl": "http://www.example.com/jira//images/icons/statuses/open.png",
67
+ "name": "Open"
68
+ }
69
+ }
70
+ }
71
+ },
72
+ {
73
+ "id": "10002",
74
+ "type": {
75
+ "id": "10000",
76
+ "name": "Dependent",
77
+ "inward": "depends on",
78
+ "outward": "is depended by"
79
+ },
80
+ "inwardIssue": {
81
+ "id": "10004",
82
+ "key": "PRJ-3",
83
+ "self": "http://www.example.com/jira/rest/api/2/issue/PRJ-3",
84
+ "fields": {
85
+ "status": {
86
+ "iconUrl": "http://www.example.com/jira//images/icons/statuses/open.png",
87
+ "name": "Open"
88
+ }
89
+ }
90
+ }
91
+ }
92
+ ],
93
+ "attachment": [
94
+ {
95
+ "self": "http://www.example.com/jira/rest/api/2.0/attachments/10000",
96
+ "filename": "picture.jpg",
97
+ "author": {
98
+ "self": "http://www.example.com/jira/rest/api/2/user?username=fred",
99
+ "name": "fred",
100
+ "avatarUrls": {
101
+ "24x24": "http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred",
102
+ "16x16": "http://www.example.com/jira/secure/useravatar?size=xsmall&ownerId=fred",
103
+ "32x32": "http://www.example.com/jira/secure/useravatar?size=medium&ownerId=fred",
104
+ "48x48": "http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred"
105
+ },
106
+ "displayName": "Fred F. User",
107
+ "active": false
108
+ },
109
+ "created": "2013-09-04T17:50:46.927+0000",
110
+ "size": 23123,
111
+ "mimeType": "image/jpeg",
112
+ "content": "http://www.example.com/jira/attachments/10000",
113
+ "thumbnail": "http://www.example.com/jira/secure/thumbnail/10000"
114
+ }
115
+ ],
116
+ "watcher": {
117
+ "self": "http://www.example.com/jira/rest/api/2/issue/TST-1/watchers",
118
+ "isWatching": false,
119
+ "watchCount": 1,
120
+ "watchers": [
121
+ {
122
+ "self": "http://www.example.com/jira/rest/api/2/user?username=fred",
123
+ "name": "fred",
124
+ "avatarUrls": {
125
+ "24x24": "http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred",
126
+ "16x16": "http://www.example.com/jira/secure/useravatar?size=xsmall&ownerId=fred",
127
+ "32x32": "http://www.example.com/jira/secure/useravatar?size=medium&ownerId=fred",
128
+ "48x48": "http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred"
129
+ },
130
+ "displayName": "Fred F. User",
131
+ "active": false
132
+ }
133
+ ]
134
+ },
135
+ "comment": [
136
+ {
137
+ "self": "http://www.example.com/jira/rest/api/2/issue/10010/comment/10000",
138
+ "id": "10000",
139
+ "author": {
140
+ "self": "http://www.example.com/jira/rest/api/2/user?username=fred",
141
+ "name": "fred",
142
+ "displayName": "Fred F. User",
143
+ "active": false
144
+ },
145
+ "body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eget venenatis elit. Duis eu justo eget augue iaculis fermentum. Sed semper quam laoreet nisi egestas at posuere augue semper.",
146
+ "updateAuthor": {
147
+ "self": "http://www.example.com/jira/rest/api/2/user?username=fred",
148
+ "name": "fred",
149
+ "displayName": "Fred F. User",
150
+ "active": false
151
+ },
152
+ "created": "2013-09-04T17:50:46.929+0000",
153
+ "updated": "2013-09-04T17:50:46.930+0000",
154
+ "visibility": {
155
+ "type": "role",
156
+ "value": "Administrators"
157
+ }
158
+ }
159
+ ],
160
+ "worklog": [
161
+ {
162
+ "self": "http://www.example.com/jira/rest/api/2/issue/10010/worklog/10000",
163
+ "author": {
164
+ "self": "http://www.example.com/jira/rest/api/2/user?username=fred",
165
+ "name": "fred",
166
+ "displayName": "Fred F. User",
167
+ "active": false
168
+ },
169
+ "updateAuthor": {
170
+ "self": "http://www.example.com/jira/rest/api/2/user?username=fred",
171
+ "name": "fred",
172
+ "displayName": "Fred F. User",
173
+ "active": false
174
+ },
175
+ "comment": "I did some work here.",
176
+ "visibility": {
177
+ "type": "group",
178
+ "value": "jira-developers"
179
+ },
180
+ "started": "2013-09-04T17:50:46.931+0000",
181
+ "timeSpent": "3h 20m",
182
+ "timeSpentSeconds": 12000,
183
+ "id": "100028"
184
+ }
185
+ ]
186
+ }
187
+ }
@@ -0,0 +1,35 @@
1
+ {
2
+ "projects": [
3
+ {
4
+ "self": "http://www.example.com/jira/rest/api/2/project/TST",
5
+ "id": "10000",
6
+ "key": "TST",
7
+ "name": "Example Project",
8
+ "avatarUrls": {
9
+ "24x24": "http://www.example.com/jira/secure/projectavatar?size=small&pid=10000&avatarId=10011",
10
+ "16x16": "http://www.example.com/jira/secure/projectavatar?size=xsmall&pid=10000&avatarId=10011",
11
+ "32x32": "http://www.example.com/jira/secure/projectavatar?size=medium&pid=10000&avatarId=10011",
12
+ "48x48": "http://www.example.com/jira/secure/projectavatar?pid=10000&avatarId=10011"
13
+ },
14
+ "issuetypes": [
15
+ {
16
+ "self": "http://www.example.com/jira/rest/api/2/issueType/1",
17
+ "id": "1",
18
+ "description": "An error in the code",
19
+ "iconUrl": "http://www.example.com/jira/images/icons/issuetypes/bug.png",
20
+ "name": "Bug",
21
+ "subtask": false,
22
+ "fields": {
23
+ "issuetype": {
24
+ "required": true,
25
+ "name": "Issue Type",
26
+ "operations": [
27
+ "set"
28
+ ]
29
+ }
30
+ }
31
+ }
32
+ ]
33
+ }
34
+ ]
35
+ }
@@ -0,0 +1,265 @@
1
+ JIRA_2_ISSUE = {
2
+ "key" => "TST-1",
3
+ "id" => "10000",
4
+ "self" => "http://localhost:8080/rest/api/2/issue/10000",
5
+ "expand" => "renderedFields,names,schema,transitions,editmeta,changelog",
6
+ "fields" => {
7
+ "comment" => {"comments" => [], "startAt" => 0, "total" => 0, "maxResults" => 0},
8
+ "aggregatetimeestimate" => 60,
9
+ "watches" => {
10
+ "self" => "http://localhost:8080/rest/api/2/issue/TST-1/watchers",
11
+ "watchCount" => 0,
12
+ "isWatching" => false,
13
+ },
14
+ "votes" => {
15
+ "votes" => 0,
16
+ "self" => "http://localhost:8080/rest/api/2/issue/TST-1/votes",
17
+ "hasVoted" => false,
18
+ },
19
+ "timeestimate" => 60,
20
+ "reporter" => {
21
+ "name" => "user",
22
+ "self" => "http://localhost:8080/rest/api/2/user?username=user",
23
+ "displayName" => "Eric Pierce",
24
+ "emailAddress" => "user@example.com",
25
+ "avatarUrls" => {
26
+ "48x48" => "http://localhost:8080/secure/useravatar?avatarId=10122",
27
+ "16x16" => "http://localhost:8080/secure/useravatar?size=small&avatarId=10122",
28
+ },
29
+ "active" => true,
30
+ },
31
+ "resolution" => nil,
32
+ "aggregatetimespent" => nil,
33
+ "components" => [],
34
+ "issuelinks" => [],
35
+ "aggregateprogress" => {"total" => 60, "progress" => 0, "percent" => 0},
36
+ "attachment" => [],
37
+ "timespent" => nil,
38
+ "priority" => {
39
+ "name" => "Major",
40
+ "iconUrl" => "http://localhost:8080/images/icons/priority_major.gif",
41
+ "self" => "http://localhost:8080/rest/api/2/priority/3",
42
+ "id" => "3",
43
+ },
44
+ "progress" => {"total" => 60, "progress" => 0, "percent" => 0},
45
+ "project" => {
46
+ "name" => "Test",
47
+ "self" => "http://localhost:8080/rest/api/2/project/TST",
48
+ "id" => "10000",
49
+ "avatarUrls" => {
50
+ "48x48" => "http://localhost:8080/secure/projectavatar?pid=10000&avatarId=10011",
51
+ "16x16" => "http://localhost:8080/secure/projectavatar?size=small&pid=10000&avatarId=10011",
52
+ },
53
+ "key" => "TST",
54
+ },
55
+ "subtasks" => [],
56
+ "aggregatetimeoriginalestimate" => 60,
57
+ "assignee" => {
58
+ "name" => "admin",
59
+ "self" => "http://localhost:8080/rest/api/2/user?username=admin",
60
+ "displayName" => "User",
61
+ "emailAddress" => "user@example.com",
62
+ "avatarUrls" => {
63
+ "48x48" => "http://localhost:8080/secure/useravatar?avatarId=10122",
64
+ "16x16" => "http://localhost:8080/secure/useravatar?size=small&avatarId=10122",
65
+ },
66
+ "active" => true,
67
+ },
68
+ "workratio" => 0,
69
+ "duedate" => nil,
70
+ "resolutiondate" => nil,
71
+ "timetracking" => {"originalEstimate" => "1m", "remainingEstimate" => "1m"},
72
+ "versions" => [],
73
+ "fixVersions" => [],
74
+ "timeoriginalestimate" => 60,
75
+ "environment" => nil,
76
+ "worklog" => {"startAt" => 0, "worklogs" => [], "total" => 0, "maxResults" => 0},
77
+ "description" => "We need a new foo widget",
78
+ "summary" => "New widget",
79
+ "labels" => [],
80
+ "status" => {
81
+ "name" => "Open",
82
+ "iconUrl" => "http://localhost:8080/images/icons/status_open.gif",
83
+ "self" => "http://localhost:8080/rest/api/2/status/1",
84
+ "id" => "1",
85
+ "description" => "The issue is open and ready for the assignee to start work on it.",
86
+ },
87
+ "updated" => "2011-12-21T11:36:12.145-0700",
88
+ "created" => "2011-12-21T11:36:12.145-0700",
89
+ "issuetype" => {
90
+ "name" => "Bug",
91
+ "iconUrl" => "http://localhost:8080/images/icons/bug.gif",
92
+ "self" => "http://localhost:8080/rest/api/2/issuetype/1",
93
+ "id" => "1",
94
+ "subtask" => false,
95
+ "description" => "A problem which impairs or prevents the functions of the product.",
96
+ },
97
+ },
98
+ }
99
+
100
+
101
+ JIRA_2_ALPHA_ISSUE = {
102
+ "key" => "TST-1",
103
+ "self" => "http://localhost:8080/rest/api/2.0.alpha1/issue/TST-1",
104
+ "transitions" => "http://localhost:8080/rest/api/2.0.alpha1/issue/TST-1/transitions",
105
+ "expand" => "html",
106
+ "fields" => {
107
+ "comment" => {
108
+ "name" => "comment",
109
+ "type" => "com.atlassian.jira.issue.fields.CommentSystemField",
110
+ "value" => [],
111
+ },
112
+ "customfield_10040" => {
113
+ "name" => "Flagged",
114
+ "type" => "com.atlassian.jira.plugin.system.customfieldtypes:multicheckboxes",
115
+ },
116
+ "reporter" => {
117
+ "name" => "reporter",
118
+ "type" => "com.opensymphony.user.User",
119
+ "value" => {
120
+ "name" => "user",
121
+ "self" => "http://localhost:8080/rest/api/2.0.alpha1/user?username=user",
122
+ "displayName" => "Pierce, Eric",
123
+ "active" => true,
124
+ },
125
+ },
126
+ "security" => {
127
+ "name" => "security",
128
+ "type" => "com.atlassian.jira.issue.security.IssueSecurityLevel",
129
+ },
130
+ "attachment" => {
131
+ "name" => "attachment",
132
+ "value" => [],
133
+ "type" => "attachment",
134
+ },
135
+ "priority" => {
136
+ "name" => "priority",
137
+ "type" => "com.atlassian.jira.issue.priority.Priority",
138
+ "value" => {
139
+ "name" => "Major",
140
+ "self" => "http://localhost:8080/rest/api/2.0.alpha1/priority/3",
141
+ },
142
+ },
143
+ "project" => {
144
+ "name" => "project",
145
+ "type" => "com.atlassian.jira.project.Project",
146
+ "value" => {
147
+ "name" => "SHRM Test",
148
+ "self" => "http://localhost:8080/rest/api/2.0.alpha1/project/TST",
149
+ "roles" => {},
150
+ "key" => "TST",
151
+ },
152
+ },
153
+ "sub-tasks" => {
154
+ "name" => "sub-tasks",
155
+ "value" => [
156
+ {
157
+ "type" => {
158
+ "name" => "Sub-Task",
159
+ "direction" => "OUTBOUND",
160
+ },
161
+ "issue" => "http://localhost:8080/rest/api/2.0.alpha1/issue/TST-4",
162
+ "issueKey" => "TST-4",
163
+ },
164
+ {
165
+ "type" => {
166
+ "name" => "Sub-Task",
167
+ "direction" => "OUTBOUND",
168
+ },
169
+ "issue" => "http://localhost:8080/rest/api/2.0.alpha1/issue/TST-5",
170
+ "issueKey" => "TST-5",
171
+ },
172
+ ],
173
+ "type" => "issuelinks",
174
+ },
175
+ "assignee" => {
176
+ "name" => "assignee",
177
+ "type" => "com.opensymphony.user.User",
178
+ "value" => {
179
+ "name" => "user",
180
+ "self" => "http://localhost:8080/rest/api/2.0.alpha1/user?username=user",
181
+ "displayName" => "Pierce, Eric",
182
+ "active" => true,
183
+ },
184
+ },
185
+ "duedate" => {
186
+ "name" => "duedate",
187
+ "type" => "java.util.Date",
188
+ },
189
+ "timetracking" => {
190
+ "name" => "timetracking",
191
+ "type" => "com.atlassian.jira.issue.fields.TimeTrackingSystemField",
192
+ },
193
+ "links" => {
194
+ "name" => "links",
195
+ "value" => [],
196
+ "type" => "issuelinks",
197
+ },
198
+ "fixVersions" => {
199
+ "name" => "fixVersions",
200
+ "type" => "com.atlassian.jira.project.version.Version",
201
+ "value" => [],
202
+ },
203
+ "environment" => {
204
+ "name" => "environment",
205
+ "type" => "java.lang.String",
206
+ },
207
+ "worklog" => {
208
+ "name" => "worklog",
209
+ "type" => "worklog",
210
+ "value" => [],
211
+ },
212
+ "description" => {
213
+ "name" => "description",
214
+ "type" => "java.lang.String",
215
+ "value" => "We need a new foo widget",
216
+ },
217
+ "summary" => {
218
+ "name" => "summary",
219
+ "type" => "java.lang.String",
220
+ "value" => "New widget",
221
+ },
222
+ "labels" => {
223
+ "name" => "labels",
224
+ "type" => "com.atlassian.jira.issue.label.Label",
225
+ "value" => [],
226
+ },
227
+ "status" => {
228
+ "name" => "status",
229
+ "type" => "com.atlassian.jira.issue.status.Status",
230
+ "value" => {
231
+ "name" => "Open",
232
+ "self" => "http://localhost:8080/rest/api/2.0.alpha1/status/1",
233
+ },
234
+ },
235
+ "updated" => {
236
+ "name" => "updated",
237
+ "type" => "java.util.Date",
238
+ "value" => "2010-12-06T15:31:33.015-0500",
239
+ },
240
+ "watcher" => {
241
+ "name" => "watcher",
242
+ "type" => "watcher",
243
+ "value" => {
244
+ "self" => "http://localhost:8080/rest/api/2.0.alpha1/issue/TST-1/watchers",
245
+ "watchCount" => 0,
246
+ "isWatching" => false,
247
+ },
248
+ },
249
+ "created" => {
250
+ "name" => "created",
251
+ "type" => "java.util.Date",
252
+ "value" => "2010-12-06T15:22:05.461-0500",
253
+ },
254
+ "issuetype" => {
255
+ "name" => "issuetype",
256
+ "type" => "com.atlassian.jira.issue.issuetype.IssueType",
257
+ "value" => {
258
+ "name" => "Task",
259
+ "self" => "http://localhost:8080/rest/api/2.0.alpha1/issueType/3",
260
+ "subtask" => false,
261
+ },
262
+ },
263
+ },
264
+ }
265
+