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.
- data/.document +5 -5
- data/.gitignore +11 -11
- data/.rspec +1 -1
- data/.ruby-gemset +1 -1
- data/.travis.yml +10 -10
- data/Gemfile +4 -4
- data/LICENSE +22 -22
- data/README.md +99 -94
- data/Rakefile +16 -16
- data/gemfiles/newest.gemfile +3 -3
- data/gemfiles/oldest.gemfile +6 -6
- data/jiralicious.gemspec +37 -37
- data/lib/jiralicious.rb +2 -0
- data/lib/jiralicious/base.rb +226 -226
- data/lib/jiralicious/component.rb +103 -0
- data/lib/jiralicious/custom_field_option.rb +45 -45
- data/lib/jiralicious/errors.rb +27 -27
- data/lib/jiralicious/field.rb +58 -58
- data/lib/jiralicious/issue/fields.rb +197 -197
- data/lib/jiralicious/issue/watchers.rb +92 -92
- data/lib/jiralicious/project.rb +116 -64
- data/lib/jiralicious/session.rb +61 -61
- data/lib/jiralicious/version.rb +4 -4
- data/lib/jiralicious/versions.rb +150 -0
- data/spec/components_spec.rb +74 -0
- data/spec/configuration_spec.rb +41 -41
- data/spec/field_parser_spec.rb +73 -73
- data/spec/fixtures/avatar.json +6 -6
- data/spec/fixtures/avatar_custom.json +15 -15
- data/spec/fixtures/avatar_list.json +15 -15
- data/spec/fixtures/avatar_temp.json +6 -6
- data/spec/fixtures/comment_single.json +28 -28
- data/spec/fixtures/component.json +39 -0
- data/spec/fixtures/component_ric.json +4 -0
- data/spec/fixtures/component_updated.json +39 -0
- data/spec/fixtures/jira.yml +7 -7
- data/spec/fixtures/project_componets.json +80 -0
- data/spec/fixtures/project_versions.json +22 -0
- data/spec/fixtures/test.json +23 -23
- data/spec/fixtures/version.json +11 -0
- data/spec/fixtures/version_ric.json +5 -0
- data/spec/fixtures/version_uic.json +4 -0
- data/spec/fixtures/version_updated.json +11 -0
- data/spec/issue_spec.rb +385 -385
- data/spec/jiralicious_spec.rb +16 -16
- data/spec/project_spec.rb +25 -2
- data/spec/search_result_spec.rb +54 -54
- data/spec/support/configuration.rb +11 -11
- data/spec/support/http.rb +147 -111
- data/spec/versions_spec.rb +84 -0
- metadata +189 -170
- 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
|
data/lib/jiralicious/project.rb
CHANGED
@@ -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
|
-
|
11
|
-
#
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
decoded_json
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
#
|
38
|
-
#
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
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
|
data/lib/jiralicious/session.rb
CHANGED
@@ -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
|