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,6 @@
1
+ # config.ru
2
+
3
+ require 'rubygems'
4
+ require File.join(File.dirname(__FILE__), 'jira')
5
+
6
+ run MockJira
@@ -0,0 +1,10 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <title>Hello</title>
5
+ </head>
6
+ <body>
7
+ Hello world
8
+ </body>
9
+ </html>
10
+
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env ruby
2
+ # Mock Jira API sinatra app
3
+
4
+ require 'sinatra/base'
5
+ require 'erb'
6
+ require 'yajl'
7
+
8
+ class MockJira < Sinatra::Base
9
+ set :root, File.dirname(__FILE__)
10
+ set :static, false
11
+
12
+ before do
13
+ content_type :json
14
+ end
15
+
16
+ get '/' do
17
+ "Hello!"
18
+ end
19
+
20
+ post '/rest/auth/1/session' do
21
+ data = Yajl::Parser.parse(request.body.read)
22
+ if data['username'] == 'user' and data['password'] == 'password'
23
+ erb :"auth/login_success"
24
+ else
25
+ halt 401, erb(:"auth/login_failed")
26
+ end
27
+ end
28
+
29
+ get '/rest/auth/1/session' do
30
+ end
31
+
32
+ delete '/rest/auth/1/session' do
33
+ erb :"auth/logout_success"
34
+ end
35
+
36
+ post '/rest/api/2/search' do
37
+ erb :search
38
+ end
39
+
40
+ post '/rest/api/2/issue' do
41
+ erb :"issue/TST-1"
42
+ end
43
+
44
+ get '/rest/api/2/field' do
45
+ erb :field
46
+ end
47
+
48
+ get '/rest/api/2/:resource/:action' do |resource, action|
49
+ begin
50
+ erb :"#{resource}/#{action}"
51
+ rescue
52
+ erb :"#{resource}/err_nonexistent", :locals => {:key => action}
53
+ end
54
+ end
55
+
56
+ get '/rest/api/2/*' do
57
+ subpath = params[:splat]
58
+ return "You requested '#{subpath}'"
59
+ end
60
+ end # class MockJira
61
+
@@ -0,0 +1 @@
1
+ {"errorMessages": ["Login failed"], "errors": {}}
@@ -0,0 +1,7 @@
1
+ {
2
+ "session": {
3
+ "name": "JSESSIONID",
4
+ "value": "5185C2FF5854BDEADBEEFF3E31449A1E"
5
+ }
6
+ }
7
+
@@ -0,0 +1,3 @@
1
+ {
2
+ "error": "TODO"
3
+ }
@@ -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,186 @@
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
+ "sub-tasks": [
8
+ {
9
+ "id": "10000",
10
+ "type": {
11
+ "id": "10000",
12
+ "name": "",
13
+ "inward": "Parent",
14
+ "outward": "Sub-task"
15
+ },
16
+ "outwardIssue": {
17
+ "id": "10003",
18
+ "key": "EX-2",
19
+ "self": "http://www.example.com/jira/rest/api/2/issue/EX-2",
20
+ "fields": {
21
+ "status": {
22
+ "iconUrl": "http://www.example.com/jira//images/icons/statuses/open.png",
23
+ "name": "Open"
24
+ }
25
+ }
26
+ }
27
+ }
28
+ ],
29
+ "timetracking": {
30
+ "originalEstimate": "10m",
31
+ "remainingEstimate": "3m",
32
+ "timeSpent": "6m",
33
+ "originalEstimateSeconds": 600,
34
+ "remainingEstimateSeconds": 200,
35
+ "timeSpentSeconds": 400
36
+ },
37
+ "project": {
38
+ "self": "http://www.example.com/jira/rest/api/2/project/EX",
39
+ "id": "10000",
40
+ "key": "EX",
41
+ "name": "Example",
42
+ "avatarUrls": {
43
+ "24x24": "http://www.example.com/jira/secure/projectavatar?size=small&pid=10000",
44
+ "16x16": "http://www.example.com/jira/secure/projectavatar?size=xsmall&pid=10000",
45
+ "32x32": "http://www.example.com/jira/secure/projectavatar?size=medium&pid=10000",
46
+ "48x48": "http://www.example.com/jira/secure/projectavatar?size=large&pid=10000"
47
+ }
48
+ },
49
+ "updated": 1,
50
+ "issuelinks": [
51
+ {
52
+ "id": "10001",
53
+ "type": {
54
+ "id": "10000",
55
+ "name": "Dependent",
56
+ "inward": "depends on",
57
+ "outward": "is depended by"
58
+ },
59
+ "outwardIssue": {
60
+ "id": "10004L",
61
+ "key": "PRJ-2",
62
+ "self": "http://www.example.com/jira/rest/api/2/issue/PRJ-2",
63
+ "fields": {
64
+ "status": {
65
+ "iconUrl": "http://www.example.com/jira//images/icons/statuses/open.png",
66
+ "name": "Open"
67
+ }
68
+ }
69
+ }
70
+ },
71
+ {
72
+ "id": "10002",
73
+ "type": {
74
+ "id": "10000",
75
+ "name": "Dependent",
76
+ "inward": "depends on",
77
+ "outward": "is depended by"
78
+ },
79
+ "inwardIssue": {
80
+ "id": "10004",
81
+ "key": "PRJ-3",
82
+ "self": "http://www.example.com/jira/rest/api/2/issue/PRJ-3",
83
+ "fields": {
84
+ "status": {
85
+ "iconUrl": "http://www.example.com/jira//images/icons/statuses/open.png",
86
+ "name": "Open"
87
+ }
88
+ }
89
+ }
90
+ }
91
+ ],
92
+ "attachment": [
93
+ {
94
+ "self": "http://www.example.com/jira/rest/api/2.0/attachments/10000",
95
+ "filename": "picture.jpg",
96
+ "author": {
97
+ "self": "http://www.example.com/jira/rest/api/2/user?username=fred",
98
+ "name": "fred",
99
+ "avatarUrls": {
100
+ "24x24": "http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred",
101
+ "16x16": "http://www.example.com/jira/secure/useravatar?size=xsmall&ownerId=fred",
102
+ "32x32": "http://www.example.com/jira/secure/useravatar?size=medium&ownerId=fred",
103
+ "48x48": "http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred"
104
+ },
105
+ "displayName": "Fred F. User",
106
+ "active": false
107
+ },
108
+ "created": "2013-09-04T17:50:46.927+0000",
109
+ "size": 23123,
110
+ "mimeType": "image/jpeg",
111
+ "content": "http://www.example.com/jira/attachments/10000",
112
+ "thumbnail": "http://www.example.com/jira/secure/thumbnail/10000"
113
+ }
114
+ ],
115
+ "watcher": {
116
+ "self": "http://www.example.com/jira/rest/api/2/issue/TST-1/watchers",
117
+ "isWatching": false,
118
+ "watchCount": 1,
119
+ "watchers": [
120
+ {
121
+ "self": "http://www.example.com/jira/rest/api/2/user?username=fred",
122
+ "name": "fred",
123
+ "avatarUrls": {
124
+ "24x24": "http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred",
125
+ "16x16": "http://www.example.com/jira/secure/useravatar?size=xsmall&ownerId=fred",
126
+ "32x32": "http://www.example.com/jira/secure/useravatar?size=medium&ownerId=fred",
127
+ "48x48": "http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred"
128
+ },
129
+ "displayName": "Fred F. User",
130
+ "active": false
131
+ }
132
+ ]
133
+ },
134
+ "comment": [
135
+ {
136
+ "self": "http://www.example.com/jira/rest/api/2/issue/10010/comment/10000",
137
+ "id": "10000",
138
+ "author": {
139
+ "self": "http://www.example.com/jira/rest/api/2/user?username=fred",
140
+ "name": "fred",
141
+ "displayName": "Fred F. User",
142
+ "active": false
143
+ },
144
+ "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.",
145
+ "updateAuthor": {
146
+ "self": "http://www.example.com/jira/rest/api/2/user?username=fred",
147
+ "name": "fred",
148
+ "displayName": "Fred F. User",
149
+ "active": false
150
+ },
151
+ "created": "2013-09-04T17:50:46.929+0000",
152
+ "updated": "2013-09-04T17:50:46.930+0000",
153
+ "visibility": {
154
+ "type": "role",
155
+ "value": "Administrators"
156
+ }
157
+ }
158
+ ],
159
+ "worklog": [
160
+ {
161
+ "self": "http://www.example.com/jira/rest/api/2/issue/10010/worklog/10000",
162
+ "author": {
163
+ "self": "http://www.example.com/jira/rest/api/2/user?username=fred",
164
+ "name": "fred",
165
+ "displayName": "Fred F. User",
166
+ "active": false
167
+ },
168
+ "updateAuthor": {
169
+ "self": "http://www.example.com/jira/rest/api/2/user?username=fred",
170
+ "name": "fred",
171
+ "displayName": "Fred F. User",
172
+ "active": false
173
+ },
174
+ "comment": "I did some work here.",
175
+ "visibility": {
176
+ "type": "group",
177
+ "value": "jira-developers"
178
+ },
179
+ "started": "2013-09-04T17:50:46.931+0000",
180
+ "timeSpent": "3h 20m",
181
+ "timeSpentSeconds": 12000,
182
+ "id": "100028"
183
+ }
184
+ ]
185
+ }
186
+ }
@@ -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 @@
1
+ {"errorMessages": ["Issue Does Not Exist"], "errors": {}}
@@ -0,0 +1,97 @@
1
+ {
2
+ "self": "http://www.example.com/jira/rest/api/2/project/TST",
3
+ "id": "10000",
4
+ "key": "TST",
5
+ "description": "This project was created as an example for REST.",
6
+ "lead": {
7
+ "self": "http://www.example.com/jira/rest/api/2/user?username=fred",
8
+ "name": "fred",
9
+ "avatarUrls": {
10
+ "24x24": "http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred",
11
+ "16x16": "http://www.example.com/jira/secure/useravatar?size=xsmall&ownerId=fred",
12
+ "32x32": "http://www.example.com/jira/secure/useravatar?size=medium&ownerId=fred",
13
+ "48x48": "http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred"
14
+ },
15
+ "displayName": "Fred F. User",
16
+ "active": false
17
+ },
18
+ "components": [
19
+ {
20
+ "self": "http://www.example.com/jira/rest/api/2/component/10000",
21
+ "id": "10000",
22
+ "name": "Component 1",
23
+ "description": "This is a JIRA component",
24
+ "lead": {
25
+ "self": "http://www.example.com/jira/rest/api/2/user?username=fred",
26
+ "name": "fred",
27
+ "avatarUrls": {
28
+ "24x24": "http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred",
29
+ "16x16": "http://www.example.com/jira/secure/useravatar?size=xsmall&ownerId=fred",
30
+ "32x32": "http://www.example.com/jira/secure/useravatar?size=medium&ownerId=fred",
31
+ "48x48": "http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred"
32
+ },
33
+ "displayName": "Fred F. User",
34
+ "active": false
35
+ },
36
+ "assigneeType": "PROJECT_LEAD",
37
+ "assignee": {
38
+ "self": "http://www.example.com/jira/rest/api/2/user?username=fred",
39
+ "name": "fred",
40
+ "avatarUrls": {
41
+ "24x24": "http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred",
42
+ "16x16": "http://www.example.com/jira/secure/useravatar?size=xsmall&ownerId=fred",
43
+ "32x32": "http://www.example.com/jira/secure/useravatar?size=medium&ownerId=fred",
44
+ "48x48": "http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred"
45
+ },
46
+ "displayName": "Fred F. User",
47
+ "active": false
48
+ },
49
+ "realAssigneeType": "PROJECT_LEAD",
50
+ "realAssignee": {
51
+ "self": "http://www.example.com/jira/rest/api/2/user?username=fred",
52
+ "name": "fred",
53
+ "avatarUrls": {
54
+ "24x24": "http://www.example.com/jira/secure/useravatar?size=small&ownerId=fred",
55
+ "16x16": "http://www.example.com/jira/secure/useravatar?size=xsmall&ownerId=fred",
56
+ "32x32": "http://www.example.com/jira/secure/useravatar?size=medium&ownerId=fred",
57
+ "48x48": "http://www.example.com/jira/secure/useravatar?size=large&ownerId=fred"
58
+ },
59
+ "displayName": "Fred F. User",
60
+ "active": false
61
+ },
62
+ "isAssigneeTypeValid": false
63
+ }
64
+ ],
65
+ "issueTypes": [
66
+ {
67
+ "self": "http://localhost:8090/jira/rest/api/2.0/issueType/3",
68
+ "id": "3",
69
+ "description": "A task that needs to be done.",
70
+ "iconUrl": "http://localhost:8090/jira/images/icons/issuetypes/task.png",
71
+ "name": "Task",
72
+ "subtask": false
73
+ },
74
+ {
75
+ "self": "http://localhost:8090/jira/rest/api/2.0/issueType/1",
76
+ "id": "1",
77
+ "description": "A problem with the software.",
78
+ "iconUrl": "http://localhost:8090/jira/images/icons/issuetypes/bug.png",
79
+ "name": "Bug",
80
+ "subtask": false
81
+ }
82
+ ],
83
+ "url": "http://www.example.com/jira/browse/TST",
84
+ "email": "from-jira@example.com",
85
+ "assigneeType": "PROJECT_LEAD",
86
+ "versions": [],
87
+ "name": "Example",
88
+ "roles": {
89
+ "Developers": "http://www.example.com/jira/rest/api/2/project/TST/role/10000"
90
+ },
91
+ "avatarUrls": {
92
+ "24x24": "http://www.example.com/jira/secure/projectavatar?size=small&pid=10000",
93
+ "16x16": "http://www.example.com/jira/secure/projectavatar?size=xsmall&pid=10000",
94
+ "32x32": "http://www.example.com/jira/secure/projectavatar?size=medium&pid=10000",
95
+ "48x48": "http://www.example.com/jira/secure/projectavatar?size=large&pid=10000"
96
+ }
97
+ }