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,92 +1,92 @@
1
- # encoding: utf-8
2
- module Jiralicious
3
- class Issue
4
- ##
5
- # The Watchers class is used to manage the
6
- # watchers on an issue.
7
- #
8
- class Watchers < Jiralicious::Base
9
- ##
10
- # Holds the Issue Key
11
- #
12
- attr_accessor :jira_key
13
-
14
- ##
15
- # Initialization Method
16
- #
17
- def initialize(decoded_json = nil)
18
- if (decoded_json != nil)
19
- properties_from_hash(decoded_json)
20
- super(decoded_json)
21
- parse!(decoded_json)
22
- end
23
- end
24
-
25
- class << self
26
- ##
27
- # Finds all watchers based on the provided Issue Key
28
- #
29
- # [Arguments]
30
- # :key (required) issue key to find
31
- #
32
- def find_by_key(key)
33
- issueKey_test(key)
34
- response = fetch({:parent => parent_name, :parent_key => key})
35
- a = new(response)
36
- a.jira_key = key
37
- return a
38
- end
39
-
40
- ##
41
- # Adds a new Watcher to the Issue
42
- #
43
- # [Arguments]
44
- # :name (required) name of the watcher
45
- #
46
- # :key (required) issue key
47
- #
48
- def add(name, key)
49
- issueKey_test(key)
50
- fetch({:method => :post, :body => name, :body_override => true, :parent => parent_name, :parent_key => key})
51
- end
52
-
53
- ##
54
- # Removes/Deletes a Watcher from the Issue
55
- #
56
- # [Arguments]
57
- # :name (required) name of the watcher
58
- #
59
- # :key (required) issue key
60
- #
61
- def remove(name, key)
62
- issueKey_test(key)
63
- fetch({:method => :delete, :body_to_params => true, :body => {:username => name}, :parent => parent_name, :parent_key => key})
64
- end
65
- end
66
-
67
- ##
68
- # Finds all watchers based on the provided Issue Key
69
- #
70
- def find
71
- self.class.find_by_key(@jira_key)
72
- end
73
-
74
- ##
75
- # Adds a new Watcher to the Issue
76
- #
77
- # [Arguments]
78
- # :name (required) name of the watcher
79
- #
80
- def add(name)
81
- self.class.add(name, @jira_key)
82
- end
83
-
84
- ##
85
- # Removes/Deletes a Watcher from the Issue
86
- #
87
- def remove(name)
88
- self.class.remove(name, @jira_key)
89
- end
90
- end
91
- end
92
- end
1
+ # encoding: utf-8
2
+ module Jiralicious
3
+ class Issue
4
+ ##
5
+ # The Watchers class is used to manage the
6
+ # watchers on an issue.
7
+ #
8
+ class Watchers < Jiralicious::Base
9
+ ##
10
+ # Holds the Issue Key
11
+ #
12
+ attr_accessor :jira_key
13
+
14
+ ##
15
+ # Initialization Method
16
+ #
17
+ def initialize(decoded_json = nil)
18
+ if (decoded_json != nil)
19
+ properties_from_hash(decoded_json)
20
+ super(decoded_json)
21
+ parse!(decoded_json)
22
+ end
23
+ end
24
+
25
+ class << self
26
+ ##
27
+ # Finds all watchers based on the provided Issue Key
28
+ #
29
+ # [Arguments]
30
+ # :key (required) issue key to find
31
+ #
32
+ def find_by_key(key)
33
+ issueKey_test(key)
34
+ response = fetch({:parent => parent_name, :parent_key => key})
35
+ a = new(response)
36
+ a.jira_key = key
37
+ return a
38
+ end
39
+
40
+ ##
41
+ # Adds a new Watcher to the Issue
42
+ #
43
+ # [Arguments]
44
+ # :name (required) name of the watcher
45
+ #
46
+ # :key (required) issue key
47
+ #
48
+ def add(name, key)
49
+ issueKey_test(key)
50
+ fetch({:method => :post, :body => name, :body_override => true, :parent => parent_name, :parent_key => key})
51
+ end
52
+
53
+ ##
54
+ # Removes/Deletes a Watcher from the Issue
55
+ #
56
+ # [Arguments]
57
+ # :name (required) name of the watcher
58
+ #
59
+ # :key (required) issue key
60
+ #
61
+ def remove(name, key)
62
+ issueKey_test(key)
63
+ fetch({:method => :delete, :body_to_params => true, :body => {:username => name}, :parent => parent_name, :parent_key => key})
64
+ end
65
+ end
66
+
67
+ ##
68
+ # Finds all watchers based on the provided Issue Key
69
+ #
70
+ def find
71
+ self.class.find_by_key(@jira_key)
72
+ end
73
+
74
+ ##
75
+ # Adds a new Watcher to the Issue
76
+ #
77
+ # [Arguments]
78
+ # :name (required) name of the watcher
79
+ #
80
+ def add(name)
81
+ self.class.add(name, @jira_key)
82
+ end
83
+
84
+ ##
85
+ # Removes/Deletes a Watcher from the Issue
86
+ #
87
+ def remove(name)
88
+ self.class.remove(name, @jira_key)
89
+ end
90
+ end
91
+ end
92
+ end
@@ -1,64 +1,116 @@
1
- # encoding: utf-8
2
- module Jiralicious
3
- ##
4
- # The Project class rolls up the basic functionality for
5
- # managing Projects within Jira through the Rest API.
6
- #
7
- class Project < Jiralicious::Base
8
-
9
- ##
10
- # Initialization Method
11
- #
12
- # [Arguments]
13
- # :decoded_json (optional) rubyized json object
14
- #
15
- def initialize(decoded_json)
16
- @loaded = false
17
- if decoded_json.is_a? Hash
18
- properties_from_hash(decoded_json)
19
- super(decoded_json)
20
- parse!(decoded_json)
21
- @loaded = true
22
- else
23
- decoded_json.each do |list|
24
- self.class.property :"#{list['key']}"
25
- self.merge!({list['key'] => self.class.find(list['key'])})
26
- end
27
- end
28
- end
29
-
30
- class << self
31
- ##
32
- # Returns a list of issues within the project. The issue list is limited
33
- # to only return the issue ID and KEY values to minimize the amount of
34
- # data being returned This is used in lazy loading methodology.
35
- #
36
- # [Arguments]
37
- # :key (required) project key
38
- #
39
- def issue_list(key)
40
- response = Jiralicious.search("project=#{key}", {:fields => ["id", "key"]})
41
- i_out = Issue.new
42
- response.issues_raw.each do |issue|
43
- i_out.class.property :"#{issue["key"].gsub("-", "_")}"
44
- t = Issue.new
45
- t.load(issue, true)
46
- i_out[issue["key"].gsub("-", "_")] = t
47
- end
48
- i_out
49
- end
50
- end
51
-
52
- ##
53
- # Issues loads the issue list into the current Project.
54
- # It also acts as a reference for lazy loading of issues.
55
- #
56
- attr_accessor :issues
57
- def issues
58
- if @issues == nil
59
- @issues = self.class.issue_list(self.key)
60
- end
61
- return @issues
62
- end
63
- end
64
- end
1
+ # encoding: utf-8
2
+ module Jiralicious
3
+ ##
4
+ # The Project class rolls up the basic functionality for
5
+ # managing Projects within Jira through the Rest API.
6
+ #
7
+ class Project < Jiralicious::Base
8
+
9
+ # Contains the Fields Class
10
+ attr_accessor :components
11
+ # Contains the Fields Class
12
+ attr_accessor :versions
13
+
14
+ ##
15
+ # Initialization Method
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
+ properties_from_hash(decoded_json)
24
+ super(decoded_json)
25
+ parse!(decoded_json)
26
+ @loaded = true
27
+ else
28
+ decoded_json.each do |list|
29
+ self.class.property :"#{list['key']}"
30
+ self.merge!({list['key'] => self.class.find(list['key'])})
31
+ end
32
+ end
33
+ end
34
+
35
+ class << self
36
+ ##
37
+ # Returns a list of issues within the project. The issue list is limited
38
+ # to only return the issue ID and KEY values to minimize the amount of
39
+ # data being returned This is used in lazy loading methodology.
40
+ #
41
+ # [Arguments]
42
+ # :key (required) project key
43
+ #
44
+ def issue_list(key)
45
+ response = Jiralicious.search("project=#{key}", {:fields => ["id", "key"]})
46
+ i_out = Issue.new
47
+ response.issues_raw.each do |issue|
48
+ i_out.class.property :"#{issue["key"].gsub("-", "_")}"
49
+ t = Issue.new
50
+ t.load(issue, true)
51
+ i_out[issue["key"].gsub("-", "_")] = t
52
+ end
53
+ i_out
54
+ end
55
+
56
+ ##
57
+ # Retrieves the components associated with the project
58
+ #
59
+ # [Arguments]
60
+ # :key (required) project key to generate components
61
+ #
62
+ def components(key)
63
+ response = fetch({:key => "#{key}/components"})
64
+ Field.new(response.parsed_response)
65
+ end
66
+
67
+ ##
68
+ # Retrieves the versions associated with the project
69
+ #
70
+ # [Arguments]
71
+ # :key (required) project key to generate versions
72
+ #
73
+ # :expand (optional) expansion options.
74
+ #
75
+ def versions(key, expand = {})
76
+ response = fetch({:key => "#{key}/versions", :body => expand})
77
+ Field.new(response.parsed_response)
78
+ end
79
+ end
80
+
81
+ ##
82
+ # Issues loads the issue list into the current Project.
83
+ # It also acts as a reference for lazy loading of issues.
84
+ #
85
+ attr_accessor :issues
86
+ def issues
87
+ if @issues == nil
88
+ @issues = self.class.issue_list(self.key)
89
+ end
90
+ return @issues
91
+ end
92
+
93
+ ##
94
+ # Retrieves the components associated with the project
95
+ #
96
+ def components
97
+ if @components.nil?
98
+ @components = self.class.components(self.key)
99
+ end
100
+ @components
101
+ end
102
+
103
+ ##
104
+ # Retrieves the versions associated with the project
105
+ #
106
+ # [Arguments]
107
+ # :expand (optional) expansion options.
108
+ #
109
+ def versions(expand = {})
110
+ if @versions.nil? || !expand.empty?
111
+ @versions = self.class.verions(self.key, expand)
112
+ end
113
+ @versions
114
+ end
115
+ end
116
+ end
@@ -1,61 +1,61 @@
1
- # encoding: utf-8
2
- require 'jiralicious/configuration'
3
-
4
- module Jiralicious
5
- ##
6
- # The Session class handles the interactions with the Jira Rest API
7
- # Through the HTTParty gem.
8
- #
9
- class Session
10
- include HTTParty
11
-
12
- # Sets the default format to JSON for send and return
13
- format :json
14
- # Sets the default headers to application/json for send and return
15
- headers 'Content-Type' => 'application/json'
16
-
17
- ##
18
- # Main access method to request data from the Jira API
19
- #
20
- # [Arguments]
21
- # :method (required) http method type
22
- #
23
- # :options (required) request specific options
24
- #
25
- def request(method, *options)
26
- if options.last.is_a?(Hash) && options.last[:handler]
27
- response_handler = options.last.delete(:handler)
28
- else
29
- response_handler = handler
30
- end
31
-
32
- self.class.base_uri Jiralicious.uri
33
- before_request if respond_to?(:before_request)
34
- response = self.class.send(method, *options)
35
- after_request(response) if respond_to?(:after_request)
36
-
37
- response_handler.call(response)
38
- end
39
-
40
- private
41
-
42
- ##
43
- # Configures the default handler. This can be overridden in
44
- # the child class to provide additional error handling.
45
- #
46
- def handler
47
- Proc.new do |response|
48
- case response
49
- when 200..204
50
- response.body
51
- else
52
- message = response.body
53
- if message.is_a?(Hash)
54
- message = message['errorMessages'].join('\n')
55
- end
56
- Jiralicious::JiraError.new(message)
57
- end
58
- end
59
- end
60
- end
61
- end
1
+ # encoding: utf-8
2
+ require 'jiralicious/configuration'
3
+
4
+ module Jiralicious
5
+ ##
6
+ # The Session class handles the interactions with the Jira Rest API
7
+ # Through the HTTParty gem.
8
+ #
9
+ class Session
10
+ include HTTParty
11
+
12
+ # Sets the default format to JSON for send and return
13
+ format :json
14
+ # Sets the default headers to application/json for send and return
15
+ headers 'Content-Type' => 'application/json'
16
+
17
+ ##
18
+ # Main access method to request data from the Jira API
19
+ #
20
+ # [Arguments]
21
+ # :method (required) http method type
22
+ #
23
+ # :options (required) request specific options
24
+ #
25
+ def request(method, *options)
26
+ if options.last.is_a?(Hash) && options.last[:handler]
27
+ response_handler = options.last.delete(:handler)
28
+ else
29
+ response_handler = handler
30
+ end
31
+
32
+ self.class.base_uri Jiralicious.uri
33
+ before_request if respond_to?(:before_request)
34
+ response = self.class.send(method, *options)
35
+ after_request(response) if respond_to?(:after_request)
36
+
37
+ response_handler.call(response)
38
+ end
39
+
40
+ private
41
+
42
+ ##
43
+ # Configures the default handler. This can be overridden in
44
+ # the child class to provide additional error handling.
45
+ #
46
+ def handler
47
+ Proc.new do |response|
48
+ case response
49
+ when 200..204
50
+ response.body
51
+ else
52
+ message = response.body
53
+ if message.is_a?(Hash)
54
+ message = message['errorMessages'].join('\n')
55
+ end
56
+ Jiralicious::JiraError.new(message)
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end