jiralicious 0.4.3 → 0.5.0

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 (52) hide show
  1. data/.document +5 -5
  2. data/.gitignore +11 -11
  3. data/.rspec +1 -1
  4. data/.ruby-gemset +1 -1
  5. data/.travis.yml +10 -10
  6. data/Gemfile +4 -4
  7. data/LICENSE +22 -22
  8. data/README.md +99 -94
  9. data/Rakefile +16 -16
  10. data/gemfiles/newest.gemfile +3 -3
  11. data/gemfiles/oldest.gemfile +6 -6
  12. data/jiralicious.gemspec +37 -37
  13. data/lib/jiralicious.rb +2 -0
  14. data/lib/jiralicious/base.rb +226 -226
  15. data/lib/jiralicious/component.rb +103 -0
  16. data/lib/jiralicious/custom_field_option.rb +45 -45
  17. data/lib/jiralicious/errors.rb +27 -27
  18. data/lib/jiralicious/field.rb +58 -58
  19. data/lib/jiralicious/issue/fields.rb +197 -197
  20. data/lib/jiralicious/issue/watchers.rb +92 -92
  21. data/lib/jiralicious/project.rb +116 -64
  22. data/lib/jiralicious/session.rb +61 -61
  23. data/lib/jiralicious/version.rb +4 -4
  24. data/lib/jiralicious/versions.rb +150 -0
  25. data/spec/components_spec.rb +74 -0
  26. data/spec/configuration_spec.rb +41 -41
  27. data/spec/field_parser_spec.rb +73 -73
  28. data/spec/fixtures/avatar.json +6 -6
  29. data/spec/fixtures/avatar_custom.json +15 -15
  30. data/spec/fixtures/avatar_list.json +15 -15
  31. data/spec/fixtures/avatar_temp.json +6 -6
  32. data/spec/fixtures/comment_single.json +28 -28
  33. data/spec/fixtures/component.json +39 -0
  34. data/spec/fixtures/component_ric.json +4 -0
  35. data/spec/fixtures/component_updated.json +39 -0
  36. data/spec/fixtures/jira.yml +7 -7
  37. data/spec/fixtures/project_componets.json +80 -0
  38. data/spec/fixtures/project_versions.json +22 -0
  39. data/spec/fixtures/test.json +23 -23
  40. data/spec/fixtures/version.json +11 -0
  41. data/spec/fixtures/version_ric.json +5 -0
  42. data/spec/fixtures/version_uic.json +4 -0
  43. data/spec/fixtures/version_updated.json +11 -0
  44. data/spec/issue_spec.rb +385 -385
  45. data/spec/jiralicious_spec.rb +16 -16
  46. data/spec/project_spec.rb +25 -2
  47. data/spec/search_result_spec.rb +54 -54
  48. data/spec/support/configuration.rb +11 -11
  49. data/spec/support/http.rb +147 -111
  50. data/spec/versions_spec.rb +84 -0
  51. metadata +189 -170
  52. checksums.yaml +0 -7
@@ -1,45 +1,45 @@
1
- # encoding: utf-8
2
- module Jiralicious
3
- ##
4
- # The CustomFieldOption provides a list of available custom
5
- # field options. This method is used in lazy loading and can
6
- # be used to validate options prior to updating the issue.
7
- #
8
- class CustomFieldOption < Jiralicious::Base
9
-
10
- ##
11
- # Initialization Method
12
- #
13
- # [Arguments]
14
- # :decoded_json (optional) rubyized json object
15
- #
16
- def initialize(decoded_json)
17
- @loaded = false
18
- if decoded_json.is_a? Hash
19
- properties_from_hash(decoded_json)
20
- super(decoded_json)
21
- parse!(decoded_json)
22
- @loaded = true
23
- end
24
- end
25
-
26
- class << self
27
- ##
28
- # Overrides the auto-generated endpoint_name from Base.
29
- # This is necessary due to lower camel case naming convention.
30
- #
31
- def endpoint_name
32
- "customFieldOption"
33
- end
34
-
35
- ##
36
- # Retrieves the options based on the ID
37
- #
38
- def find(id, options = {})
39
- response = fetch({:key => id})
40
- response.parsed_response['id'] = id
41
- new(response.parsed_response)
42
- end
43
- end
44
- end
45
- end
1
+ # encoding: utf-8
2
+ module Jiralicious
3
+ ##
4
+ # The CustomFieldOption provides a list of available custom
5
+ # field options. This method is used in lazy loading and can
6
+ # be used to validate options prior to updating the issue.
7
+ #
8
+ class CustomFieldOption < Jiralicious::Base
9
+
10
+ ##
11
+ # Initialization Method
12
+ #
13
+ # [Arguments]
14
+ # :decoded_json (optional) rubyized json object
15
+ #
16
+ def initialize(decoded_json)
17
+ @loaded = false
18
+ if decoded_json.is_a? Hash
19
+ properties_from_hash(decoded_json)
20
+ super(decoded_json)
21
+ parse!(decoded_json)
22
+ @loaded = true
23
+ end
24
+ end
25
+
26
+ class << self
27
+ ##
28
+ # Overrides the auto-generated endpoint_name from Base.
29
+ # This is necessary due to lower camel case naming convention.
30
+ #
31
+ def endpoint_name
32
+ "customFieldOption"
33
+ end
34
+
35
+ ##
36
+ # Retrieves the options based on the ID
37
+ #
38
+ def find(id, options = {})
39
+ response = fetch({:key => id})
40
+ response.parsed_response['id'] = id
41
+ new(response.parsed_response)
42
+ end
43
+ end
44
+ end
45
+ end
@@ -1,27 +1,27 @@
1
- # encoding: utf-8
2
-
3
- module Jiralicious
4
- # General Jira error
5
- class JiraError < StandardError; end
6
- # AuthenticateError
7
- class AuthenticationError < StandardError; end
8
- # NotLoggedIn error
9
- class NotLoggedIn < AuthenticationError; end
10
- # InvalidLogin error
11
- class InvalidLogin < AuthenticationError; end
12
-
13
- # These are in the JIRA API docs. Not sure about specifics, as the docs don't
14
- # mention them. Added here for completeness and future implementation.
15
- # http://confluence.atlassian.com/display/JIRA/JIRA+REST+API+%28Alpha%29+Tutorial
16
-
17
- # Cookie has Expired (depricated)
18
- class CookieExpired < AuthenticationError; end
19
- # Captcha is Required (not used)
20
- class CaptchaRequired < AuthenticationError; end
21
- # IssueNotFound error (any invalid object)
22
- class IssueNotFound < StandardError; end
23
- # JQL Error (error in JQL search(
24
- class JqlError < StandardError; end
25
- # Transition Error
26
- class TransitionError < StandardError; end
27
- end
1
+ # encoding: utf-8
2
+
3
+ module Jiralicious
4
+ # General Jira error
5
+ class JiraError < StandardError; end
6
+ # AuthenticateError
7
+ class AuthenticationError < StandardError; end
8
+ # NotLoggedIn error
9
+ class NotLoggedIn < AuthenticationError; end
10
+ # InvalidLogin error
11
+ class InvalidLogin < AuthenticationError; end
12
+
13
+ # These are in the JIRA API docs. Not sure about specifics, as the docs don't
14
+ # mention them. Added here for completeness and future implementation.
15
+ # http://confluence.atlassian.com/display/JIRA/JIRA+REST+API+%28Alpha%29+Tutorial
16
+
17
+ # Cookie has Expired (depricated)
18
+ class CookieExpired < AuthenticationError; end
19
+ # Captcha is Required (not used)
20
+ class CaptchaRequired < AuthenticationError; end
21
+ # IssueNotFound error (any invalid object)
22
+ class IssueNotFound < StandardError; end
23
+ # JQL Error (error in JQL search(
24
+ class JqlError < StandardError; end
25
+ # Transition Error
26
+ class TransitionError < StandardError; end
27
+ end
@@ -1,58 +1,58 @@
1
- # encoding: utf-8
2
- module Jiralicious
3
- ##
4
- # The Field class is used in multiple classes as a support
5
- # object. This class is designed as a Object Oriented Method
6
- # of viewing the Jira JSON/Hash.
7
- #
8
- class Field < Jiralicious::Base
9
- ##
10
- # Initialization Method
11
- #
12
- # Builds the dynamic Field object from either a Hash or Array.
13
- # The decoded JSON object can be nested as deep as necessary
14
- # but it is recommended that JSON objects are no deeper then
15
- # 5 levels maximum.
16
- #
17
- # [Arguments]
18
- # :decoded_json (optional) rubyized json object
19
- #
20
- def initialize(decoded_json)
21
- @loaded = false
22
- if decoded_json.is_a? Hash
23
- decoded_json = properties_from_hash(decoded_json)
24
- super(decoded_json)
25
- parse!(decoded_json)
26
- self.each do |k, v|
27
- if v.is_a? Hash
28
- self[k] = self.class.new(v)
29
- elsif v.is_a? Array
30
- v.each_index do |i|
31
- if v[i].is_a? Hash
32
- v[i] = self.class.new(v[i])
33
- end
34
- end
35
- self[k] = v
36
- end
37
- end
38
- @loaded = true
39
- else
40
- i = 0;
41
- decoded_json.each do |list|
42
- if !list['id'].nil?
43
- if numeric? list['id']
44
- id = :"id_#{list['id']}"
45
- else
46
- id = :"#{list['id']}"
47
- end
48
- else
49
- id = :"_#{i}"
50
- i += 1
51
- end
52
- self.class.property id
53
- self[id] = self.class.new(list)
54
- end
55
- end
56
- end
57
- end
58
- end
1
+ # encoding: utf-8
2
+ module Jiralicious
3
+ ##
4
+ # The Field class is used in multiple classes as a support
5
+ # object. This class is designed as a Object Oriented Method
6
+ # of viewing the Jira JSON/Hash.
7
+ #
8
+ class Field < Jiralicious::Base
9
+ ##
10
+ # Initialization Method
11
+ #
12
+ # Builds the dynamic Field object from either a Hash or Array.
13
+ # The decoded JSON object can be nested as deep as necessary
14
+ # but it is recommended that JSON objects are no deeper then
15
+ # 5 levels maximum.
16
+ #
17
+ # [Arguments]
18
+ # :decoded_json (optional) rubyized json object
19
+ #
20
+ def initialize(decoded_json)
21
+ @loaded = false
22
+ if decoded_json.is_a? Hash
23
+ decoded_json = properties_from_hash(decoded_json)
24
+ super(decoded_json)
25
+ parse!(decoded_json)
26
+ self.each do |k, v|
27
+ if v.is_a? Hash
28
+ self[k] = self.class.new(v)
29
+ elsif v.is_a? Array
30
+ v.each_index do |i|
31
+ if v[i].is_a? Hash
32
+ v[i] = self.class.new(v[i])
33
+ end
34
+ end
35
+ self[k] = v
36
+ end
37
+ end
38
+ @loaded = true
39
+ else
40
+ i = 0;
41
+ decoded_json.each do |list|
42
+ if !list['id'].nil?
43
+ if numeric? list['id']
44
+ id = :"id_#{list['id']}"
45
+ else
46
+ id = :"#{list['id']}"
47
+ end
48
+ else
49
+ id = :"_#{i}"
50
+ i += 1
51
+ end
52
+ self.class.property id
53
+ self[id] = self.class.new(list)
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
@@ -1,197 +1,197 @@
1
- # encoding: utf-8
2
- module Jiralicious
3
- class Issue
4
- ##
5
- # The Fields class provides functionality to the Issue
6
- # class that allows it to easily update or create issues.
7
- # The class retains the original and the proposed
8
- # information which could be used for cross validation
9
- # prior to posting an update.
10
- #
11
- class Fields
12
- # The fields that will be updated or created
13
- attr_accessor :fields_update
14
- # The current fields when a ticket was loaded
15
- attr_accessor :fields_current
16
-
17
- ##
18
- # Initialization Method
19
- #
20
- # [Arguments]
21
- # :fc (optional) fields to load
22
- #
23
- def initialize(fc = nil)
24
- @fields_current = (fc == nil) ? Hash.new : fc
25
- @fields_update = Hash.new
26
- end
27
-
28
- ##
29
- # Returns the count of fields being updated.
30
- #
31
- def count
32
- return @fields_update.count
33
- end
34
-
35
- ##
36
- # Returns the length of fields being updated.
37
- #
38
- def length
39
- return @fields_update.length
40
- end
41
-
42
- ##
43
- # Adds a comment to the field list
44
- #
45
- # [Arguments]
46
- # :comment (required) comment text
47
- #
48
- def add_comment(comment)
49
- if !(@fields_update['comment'].is_a? Array)
50
- @fields_update['comment'] = Array.new
51
- end
52
- @fields_update['comment'].push({"add" => {"body" => comment}})
53
- end
54
-
55
- ##
56
- # Appends the current String with the provided value
57
- #
58
- # [Arguments]
59
- # :field (required) field to update
60
- #
61
- # :value (required) value text
62
- #
63
- def append_s(field, value)
64
- if (@fields_update[field] == nil)
65
- @fields_update[field] = @fields_current[field] unless @fields_current.nil?
66
- @fields_update[field] ||= ""
67
- end
68
- @fields_update[field] += " " + value.to_s
69
- end
70
-
71
- ##
72
- # Appends the current Array with the provided value
73
- #
74
- # [Arguments]
75
- # :field (required) field to update
76
- #
77
- # :value (required) value array
78
- #
79
- def append_a(field, value)
80
- @fields_update[field] = @fields_current[field] if (@fields_update[field] == nil)
81
- @fields_update[field] = Array.new if !(@fields_update[field].is_a? Array)
82
- if value.is_a? String
83
- @fields_update[field].push(value) unless @fields_update[field].include? value
84
- else
85
- @fields_update[field] |= value
86
- end
87
- end
88
-
89
- ##
90
- # Appends the current Hash with the provided value
91
- #
92
- # [Arguments]
93
- # :field (required) field to update
94
- #
95
- # :value (required) value hash
96
- #
97
- def append_h(field, hash)
98
- @fields_update[field] = @fields_current[field] if (@fields_update[field] == nil)
99
- @fields_update[field] = Hash.new if !(@fields_update[field].is_a? Hash)
100
- @fields_update[field].merge!(hash)
101
- end
102
-
103
- ##
104
- # Merges current to updated to allow for a forced
105
- # update request to process.
106
- #
107
- def force_update
108
- @fields_update.merge!(@fields_current)
109
- end
110
-
111
- ##
112
- # Sets the field key with the provided value.
113
- #
114
- # [Arguments]
115
- # :field (required) field to update
116
- #
117
- # :value (required) value to add
118
- #
119
- def set(field, value)
120
- @fields_update[field] = value
121
- end
122
-
123
- ##
124
- # Sets the field with a name hash.
125
- # This is necessary for some objects in Jira.
126
- #
127
- # [Arguments]
128
- # :field (required) field to update
129
- #
130
- # :value (required) value text
131
- #
132
- def set_name(field, value)
133
- @fields_update[field] = {"name" => value}
134
- end
135
-
136
- ##
137
- # Sets the field with a id hash.
138
- # This is necessary for some objects in Jira.
139
- #
140
- # [Arguments]
141
- # :field (required) field to update
142
- #
143
- # :value (required) value text/int
144
- #
145
- def set_id(field, value)
146
- @fields_update[field] = {"id" => value}
147
- end
148
- ##
149
- # Fills the fields_current object with the provided Hash.
150
- #
151
- # [Arguments]
152
- # :fc (optional) fields to load
153
- #
154
- def set_current(fc)
155
- @fields_current = fc if fc.type == Hash
156
- end
157
-
158
- ##
159
- # Returns the current fields object
160
- #
161
- def current
162
- return @fields_current
163
- end
164
-
165
- ##
166
- # Returns the updated fields object
167
- #
168
- def updated
169
- return @fields_update
170
- end
171
-
172
- ##
173
- # Formats the fields_update object correctly
174
- # for Jira to perform an update request.
175
- #
176
- def format_for_update
177
- up = Hash.new
178
- @fields_update.each do |k, v|
179
- if k == "comment"
180
- up[k] = v
181
- else
182
- up[k] = [{"set" => v}]
183
- end
184
- end
185
- return {"update" => up}
186
- end
187
-
188
- ##
189
- # Formats the fields_update object correctly
190
- # for Jira to perform an create request.
191
- #
192
- def format_for_create
193
- return {"fields" => @fields_update}
194
- end
195
- end
196
- end
197
- end
1
+ # encoding: utf-8
2
+ module Jiralicious
3
+ class Issue
4
+ ##
5
+ # The Fields class provides functionality to the Issue
6
+ # class that allows it to easily update or create issues.
7
+ # The class retains the original and the proposed
8
+ # information which could be used for cross validation
9
+ # prior to posting an update.
10
+ #
11
+ class Fields
12
+ # The fields that will be updated or created
13
+ attr_accessor :fields_update
14
+ # The current fields when a ticket was loaded
15
+ attr_accessor :fields_current
16
+
17
+ ##
18
+ # Initialization Method
19
+ #
20
+ # [Arguments]
21
+ # :fc (optional) fields to load
22
+ #
23
+ def initialize(fc = nil)
24
+ @fields_current = (fc == nil) ? Hash.new : fc
25
+ @fields_update = Hash.new
26
+ end
27
+
28
+ ##
29
+ # Returns the count of fields being updated.
30
+ #
31
+ def count
32
+ return @fields_update.count
33
+ end
34
+
35
+ ##
36
+ # Returns the length of fields being updated.
37
+ #
38
+ def length
39
+ return @fields_update.length
40
+ end
41
+
42
+ ##
43
+ # Adds a comment to the field list
44
+ #
45
+ # [Arguments]
46
+ # :comment (required) comment text
47
+ #
48
+ def add_comment(comment)
49
+ if !(@fields_update['comment'].is_a? Array)
50
+ @fields_update['comment'] = Array.new
51
+ end
52
+ @fields_update['comment'].push({"add" => {"body" => comment}})
53
+ end
54
+
55
+ ##
56
+ # Appends the current String with the provided value
57
+ #
58
+ # [Arguments]
59
+ # :field (required) field to update
60
+ #
61
+ # :value (required) value text
62
+ #
63
+ def append_s(field, value)
64
+ if (@fields_update[field] == nil)
65
+ @fields_update[field] = @fields_current[field] unless @fields_current.nil?
66
+ @fields_update[field] ||= ""
67
+ end
68
+ @fields_update[field] += " " + value.to_s
69
+ end
70
+
71
+ ##
72
+ # Appends the current Array with the provided value
73
+ #
74
+ # [Arguments]
75
+ # :field (required) field to update
76
+ #
77
+ # :value (required) value array
78
+ #
79
+ def append_a(field, value)
80
+ @fields_update[field] = @fields_current[field] if (@fields_update[field] == nil)
81
+ @fields_update[field] = Array.new if !(@fields_update[field].is_a? Array)
82
+ if value.is_a? String
83
+ @fields_update[field].push(value) unless @fields_update[field].include? value
84
+ else
85
+ @fields_update[field] |= value
86
+ end
87
+ end
88
+
89
+ ##
90
+ # Appends the current Hash with the provided value
91
+ #
92
+ # [Arguments]
93
+ # :field (required) field to update
94
+ #
95
+ # :value (required) value hash
96
+ #
97
+ def append_h(field, hash)
98
+ @fields_update[field] = @fields_current[field] if (@fields_update[field] == nil)
99
+ @fields_update[field] = Hash.new if !(@fields_update[field].is_a? Hash)
100
+ @fields_update[field].merge!(hash)
101
+ end
102
+
103
+ ##
104
+ # Merges current to updated to allow for a forced
105
+ # update request to process.
106
+ #
107
+ def force_update
108
+ @fields_update.merge!(@fields_current)
109
+ end
110
+
111
+ ##
112
+ # Sets the field key with the provided value.
113
+ #
114
+ # [Arguments]
115
+ # :field (required) field to update
116
+ #
117
+ # :value (required) value to add
118
+ #
119
+ def set(field, value)
120
+ @fields_update[field] = value
121
+ end
122
+
123
+ ##
124
+ # Sets the field with a name hash.
125
+ # This is necessary for some objects in Jira.
126
+ #
127
+ # [Arguments]
128
+ # :field (required) field to update
129
+ #
130
+ # :value (required) value text
131
+ #
132
+ def set_name(field, value)
133
+ @fields_update[field] = {"name" => value}
134
+ end
135
+
136
+ ##
137
+ # Sets the field with a id hash.
138
+ # This is necessary for some objects in Jira.
139
+ #
140
+ # [Arguments]
141
+ # :field (required) field to update
142
+ #
143
+ # :value (required) value text/int
144
+ #
145
+ def set_id(field, value)
146
+ @fields_update[field] = {"id" => value}
147
+ end
148
+ ##
149
+ # Fills the fields_current object with the provided Hash.
150
+ #
151
+ # [Arguments]
152
+ # :fc (optional) fields to load
153
+ #
154
+ def set_current(fc)
155
+ @fields_current = fc if fc.type == Hash
156
+ end
157
+
158
+ ##
159
+ # Returns the current fields object
160
+ #
161
+ def current
162
+ return @fields_current
163
+ end
164
+
165
+ ##
166
+ # Returns the updated fields object
167
+ #
168
+ def updated
169
+ return @fields_update
170
+ end
171
+
172
+ ##
173
+ # Formats the fields_update object correctly
174
+ # for Jira to perform an update request.
175
+ #
176
+ def format_for_update
177
+ up = Hash.new
178
+ @fields_update.each do |k, v|
179
+ if k == "comment"
180
+ up[k] = v
181
+ else
182
+ up[k] = [{"set" => v}]
183
+ end
184
+ end
185
+ return {"update" => up}
186
+ end
187
+
188
+ ##
189
+ # Formats the fields_update object correctly
190
+ # for Jira to perform an create request.
191
+ #
192
+ def format_for_create
193
+ return {"fields" => @fields_update}
194
+ end
195
+ end
196
+ end
197
+ end