jira-rest 0.1.42 → 0.1.79
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +121 -41
- data/lib/jirarest.rb +1 -1
- data/lib/jirarest/client.rb +30 -39
- data/lib/jirarest/search.rb +4 -10
- data/lib/jirarest/struct.rb +1 -1
- data/lib/jirarest/version.rb +2 -1
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDk5ZjMyYWYyY2VmODk5ZmFjMzg5YjllNWFhM2I5ZTUyMjUxNGU0Nw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OGNmZGMxOTdiODk1MzJmNzUxNjhiMWMzNjI4MTFkNGFjZGE0ZTU4Yg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YzQyZGIxNTZhMTQ4YjMwODkwNzhkNGQxZjRjZTIzNDcxNjBkMDc0ZDI1ZmVm
|
10
|
+
YTkxYjdmYTgwNDNhMjhhN2YwYTU3OTFiMzJiMGNiMTcyYTJjOTQyODM0MmM5
|
11
|
+
NGE0Njc5MGNhYWIwMjkwZmIwNTJhMmIyYzA3OGQ1MzllMTkwOWM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MjFmOWYwMjllMzcxMDhiNjU5YThlZmQwYmFmNTQ1NTYzMmYwZDcwNjZmYzIw
|
14
|
+
Y2NlY2Q0ZmUzNWNiNThiYjY0NzRlYmRhZjZjZWY4ZDM4OWMwMWRiMzJmYjdi
|
15
|
+
MDEyMDNiNWIyN2VjMTQ4Mjg1YjdjMjA3ZDZjYmE2OGYyYTg4ZWY=
|
data/README.md
CHANGED
@@ -1,57 +1,72 @@
|
|
1
1
|
jira-rest
|
2
2
|
=========
|
3
3
|
|
4
|
-
[![Build Status](https://travis-ci.org/macwadu/jira-rest.png?branch=master)](https://travis-ci.org/macwadu/jira-rest)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/jira-rest.png)](http://badge.fury.io/rb/jira-rest) [![Build Status](https://travis-ci.org/macwadu/jira-rest.png?branch=master)](https://travis-ci.org/macwadu/jira-rest) [![Code Climate](https://codeclimate.com/github/macwadu/jira-rest.png)](https://codeclimate.com/github/macwadu/jira-rest) [![Dependency Status](https://gemnasium.com/macwadu/jira-rest.png)](https://gemnasium.com/macwadu/jira-rest.png) [![Coverage Status](https://coveralls.io/repos/macwadu/jira-rest/badge.png)](https://coveralls.io/r/macwadu/jira-rest)
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
## Installation
|
6
|
+
Installation
|
7
|
+
------------
|
9
8
|
|
10
9
|
Add this line to your application's Gemfile:
|
11
10
|
|
12
|
-
|
11
|
+
```
|
12
|
+
gem 'jirarest'
|
13
|
+
```
|
13
14
|
|
14
15
|
And then execute:
|
15
16
|
|
16
|
-
|
17
|
+
```
|
18
|
+
$ bundle
|
19
|
+
```
|
17
20
|
|
18
21
|
Or install it yourself as:
|
19
22
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
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
|
-
|
23
|
+
```
|
24
|
+
$ gem install jira-rest
|
25
|
+
```
|
26
|
+
|
27
|
+
Usage
|
28
|
+
-----
|
29
|
+
|
30
|
+
```
|
31
|
+
require 'jira-rest'
|
32
|
+
|
33
|
+
@jira = JiraRest::Client.new(jira_host, username, password)
|
34
|
+
```
|
35
|
+
|
36
|
+
**Query by hash**
|
37
|
+
|
38
|
+
```
|
39
|
+
hash_query = {:project => 'DEMO', :status => '"in progress", Open'}
|
40
|
+
@jira.search.query_by_hash(hash_query)
|
41
|
+
|
42
|
+
optional:
|
43
|
+
@jira.search.query_by_hash(hash_query, return_fields, maxresults)
|
44
|
+
```
|
45
|
+
|
46
|
+
**Query by jql string**
|
47
|
+
|
48
|
+
```
|
49
|
+
jql_query = "project in (DEMO) AND status in ("in progress", Open)"
|
50
|
+
@jira.search.jqlquery(jql_query)
|
51
|
+
|
52
|
+
optional:
|
53
|
+
@jira.search.jqlquery(jql_query, return_fields, maxresults)
|
54
|
+
```
|
55
|
+
|
56
|
+
**Search by issue key**
|
57
|
+
|
58
|
+
```
|
59
|
+
@jira.search.issue "JRA-9"
|
60
|
+
```
|
61
|
+
|
62
|
+
**Get filter issues**
|
63
|
+
|
64
|
+
```
|
65
|
+
@jira.search.filter "12843"
|
66
|
+
```
|
67
|
+
|
68
|
+
Contributing
|
69
|
+
------------
|
55
70
|
|
56
71
|
1. Fork it
|
57
72
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
@@ -59,3 +74,68 @@ Or install it yourself as:
|
|
59
74
|
4. Push to the branch (`git push origin my-new-feature`)
|
60
75
|
5. Create new Pull Request
|
61
76
|
|
77
|
+
```
|
78
|
+
gem 'jirarest'
|
79
|
+
```
|
80
|
+
|
81
|
+
And then execute:
|
82
|
+
|
83
|
+
```
|
84
|
+
$ bundle
|
85
|
+
```
|
86
|
+
|
87
|
+
Or install it yourself as:
|
88
|
+
|
89
|
+
```
|
90
|
+
$ gem install jira-rest
|
91
|
+
```
|
92
|
+
|
93
|
+
Usage
|
94
|
+
-----
|
95
|
+
|
96
|
+
```
|
97
|
+
require 'jira-rest'
|
98
|
+
|
99
|
+
@jira = JiraRest::Client.new(jira_host, username, password)
|
100
|
+
```
|
101
|
+
|
102
|
+
**Query by hash**
|
103
|
+
|
104
|
+
```
|
105
|
+
hash_query = {:project => 'DEMO', :status => '"in progress", Open'}
|
106
|
+
@jira.search.query_by_hash(hash_query)
|
107
|
+
|
108
|
+
optional:
|
109
|
+
@jira.search.query_by_hash(hash_query, return_fields, maxresults)
|
110
|
+
```
|
111
|
+
|
112
|
+
**Query by jql string**
|
113
|
+
|
114
|
+
```
|
115
|
+
jql_query = "project in (DEMO) AND status in ("in progress", Open)"
|
116
|
+
@jira.search.jqlquery(jql_query)
|
117
|
+
|
118
|
+
optional:
|
119
|
+
@jira.search.jqlquery(jql_query, return_fields, maxresults)
|
120
|
+
```
|
121
|
+
|
122
|
+
**Search by issue key**
|
123
|
+
|
124
|
+
```
|
125
|
+
@jira.search.issue "JRA-9"
|
126
|
+
```
|
127
|
+
|
128
|
+
**Get filter issues**
|
129
|
+
|
130
|
+
```
|
131
|
+
@jira.search.filter "12843"
|
132
|
+
```
|
133
|
+
|
134
|
+
Contributing
|
135
|
+
------------
|
136
|
+
|
137
|
+
1. Fork it
|
138
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
139
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
140
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
141
|
+
5. Create new Pull Request
|
data/lib/jirarest.rb
CHANGED
data/lib/jirarest/client.rb
CHANGED
@@ -10,11 +10,8 @@ module JiraRest
|
|
10
10
|
Response = Struct.new(:success, :body, :error_msg, :optional)
|
11
11
|
|
12
12
|
def initialize(jira_host, username=nil, password=nil)
|
13
|
-
|
14
13
|
jira_url = "#{jira_host}/rest/api/latest/"
|
15
|
-
|
16
14
|
generate jira_url, username, password
|
17
|
-
|
18
15
|
end
|
19
16
|
|
20
17
|
def generate(url, username=nil, password=nil)
|
@@ -23,12 +20,10 @@ module JiraRest
|
|
23
20
|
@token = Token.new(url, header)
|
24
21
|
end
|
25
22
|
|
26
|
-
|
27
23
|
def search
|
28
24
|
JiraRest::Search.new(self)
|
29
25
|
end
|
30
26
|
|
31
|
-
|
32
27
|
def self.get(url, header)
|
33
28
|
begin
|
34
29
|
p "Url: #{url}"
|
@@ -39,9 +34,6 @@ module JiraRest
|
|
39
34
|
end
|
40
35
|
end
|
41
36
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
37
|
def self.construct_url(endpoint, params)
|
46
38
|
p "Query: #{params.jql}" unless params.jql.nil?
|
47
39
|
params.fields = DEFAULT_FIELDS if (params.fields.nil? or params.fields.to_s.empty?)
|
@@ -71,13 +63,18 @@ module JiraRest
|
|
71
63
|
end.join('&')
|
72
64
|
end
|
73
65
|
|
74
|
-
|
75
|
-
def self.handle_response(response, key=nil)
|
66
|
+
|
67
|
+
def self.handle_response(response, key=nil, parsed_response=false)
|
76
68
|
raise ArgumentError, 'Response is not a HTTParty::Response' unless response.class == HTTParty::Response
|
77
69
|
case response.code
|
78
70
|
when 200
|
79
|
-
|
80
|
-
|
71
|
+
parsed = key.nil? ? response.parsed_response : response.parsed_response[key]
|
72
|
+
if parsed_response
|
73
|
+
return Response.new(true, parse_response(parsed), nil)
|
74
|
+
else
|
75
|
+
return Response.new(true, parsed, nil)
|
76
|
+
end
|
77
|
+
|
81
78
|
when (400..499)
|
82
79
|
msg = response['errorMessages'].nil? ? response.code : response['errorMessages'].join("\n")
|
83
80
|
return Response.new(false, response.response.message, msg)
|
@@ -86,34 +83,28 @@ module JiraRest
|
|
86
83
|
end
|
87
84
|
end
|
88
85
|
|
89
|
-
def self.
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
p sss
|
86
|
+
def self.parse_response(response, fields=nil)
|
87
|
+
jira_tickets = []
|
88
|
+
if response.has_key? 'issues'
|
89
|
+
response['issues'].each do |tickets|
|
90
|
+
if !tickets['key'].nil? and !tickets['fields']['summary'].nil?
|
91
|
+
jira_tickets << [tickets['key'], tickets['fields']['summary'], tickets['self']]
|
92
|
+
end
|
93
|
+
end
|
94
|
+
elsif !fields.nil?
|
95
|
+
sss = ""
|
96
|
+
fields.split(',').each { |field|
|
97
|
+
p field if response[field]
|
98
|
+
sss << response[field] if response[field]
|
99
|
+
|
100
|
+
}
|
101
|
+
p sss
|
102
|
+
else
|
103
|
+
if !response['key'].nil? and !response['fields']['summary'].nil?
|
104
|
+
jira_tickets << [response['key'], response['fields']['summary'], response['self'], response['description']]
|
109
105
|
end
|
110
|
-
return Response.new(true, jira_tickets.sort_by { |x| x.first }, nil)
|
111
|
-
when (400..499)
|
112
|
-
msg = response['errorMessages'].nil? ? code : response['errorMessages'].join("\n")
|
113
|
-
return Response.new(false, nil, msg)
|
114
|
-
else
|
115
|
-
return Response.new(false, nil, 'fail')
|
116
106
|
end
|
107
|
+
return jira_tickets.sort_by { |x| x.first }
|
117
108
|
end
|
118
109
|
end
|
119
|
-
end
|
110
|
+
end
|
data/lib/jirarest/search.rb
CHANGED
@@ -6,16 +6,13 @@ module JiraRest
|
|
6
6
|
@token = params.token
|
7
7
|
end
|
8
8
|
|
9
|
-
|
10
9
|
def issue(issue_id)
|
11
|
-
|
12
10
|
url = 'issue/' + issue_id.to_s
|
13
11
|
issue = Url.new
|
14
12
|
issue.fields = 'key,summary,issuetype,reporter,priority'
|
15
13
|
search_url = Client.construct_url @token.url + url, issue
|
16
14
|
response = Client.get search_url, @token.header
|
17
|
-
Client.handle_response(response)
|
18
|
-
#TODO parse issue result
|
15
|
+
Client.handle_response(response, nil, true)
|
19
16
|
end
|
20
17
|
|
21
18
|
#get tickets from filter id
|
@@ -29,12 +26,9 @@ module JiraRest
|
|
29
26
|
search_url = Client.construct_url @token.url + url, issue
|
30
27
|
response = Client.get search_url, @token.header
|
31
28
|
filter_url = Client.handle_response(response, 'searchUrl')
|
32
|
-
|
33
29
|
return filter_url unless filter_url.success
|
34
|
-
|
35
30
|
filter_response = Client.get filter_url.body, @token.header
|
36
|
-
Client.
|
37
|
-
|
31
|
+
Client.handle_response(filter_response, nil, true)
|
38
32
|
end
|
39
33
|
|
40
34
|
|
@@ -50,7 +44,7 @@ module JiraRest
|
|
50
44
|
|
51
45
|
#search_url = construct_query URI.escape(jql_string), return_fields, maxresults
|
52
46
|
response = Client.get @token.url + search_url, @token.header
|
53
|
-
Client.
|
47
|
+
Client.handle_response(response, nil, true)
|
54
48
|
end
|
55
49
|
|
56
50
|
#get tickets from by a jql query
|
@@ -62,7 +56,7 @@ module JiraRest
|
|
62
56
|
def jqlquery(jql_string, return_fields=nil, maxresults=nil)
|
63
57
|
search_url = Client.construct_url('search', Url.new(URI.encode(jql_string), return_fields, maxresults))
|
64
58
|
response = Client.get @token.url + search_url, @token.header
|
65
|
-
Client.
|
59
|
+
Client.handle_response(response, nil, true)
|
66
60
|
end
|
67
61
|
end
|
68
62
|
end
|
data/lib/jirarest/struct.rb
CHANGED
data/lib/jirarest/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jira-rest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.79
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tiago.l.nobre@gmail.com
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -94,7 +94,21 @@ dependencies:
|
|
94
94
|
- - ~>
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '1.3'
|
97
|
-
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: coveralls
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: jira-rest is a ruby lib to interact with JIRA
|
98
112
|
email: tiago.l.nobre@gmail.com
|
99
113
|
executables: []
|
100
114
|
extensions: []
|
@@ -129,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
143
|
version: '0'
|
130
144
|
requirements: []
|
131
145
|
rubyforge_project:
|
132
|
-
rubygems_version: 2.
|
146
|
+
rubygems_version: 2.3.0
|
133
147
|
signing_key:
|
134
148
|
specification_version: 4
|
135
149
|
summary: JIRA REST API
|