jira-ruby 3.0.0 → 3.1.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.
- checksums.yaml +4 -4
- data/.github/workflows/CI.yml +1 -0
- data/.github/workflows/rubocop.yml +1 -1
- data/README.md +0 -1
- data/jira-ruby.gemspec +1 -0
- data/lib/jira/base_factory.rb +1 -1
- data/lib/jira/resource/issue.rb +51 -18
- data/lib/jira/version.rb +1 -1
- data/spec/integration/issue_spec.rb +1 -2
- data/spec/jira/resource/issue_spec.rb +34 -0
- metadata +16 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8d81df9752f33a1c48332b6793d3b6596359b77b1a79575b57382553c1e04400
|
|
4
|
+
data.tar.gz: 5d6d16a50ccd3293b893068c303405a67450006197bd1d5aec85d75a9d3179e4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e4dc469b98fac2378bf647cd33e433a33ddc17ddf83d2e6fe835d21eda2239c6e3899fe9a838ebb4b1130356fa011302dd7f463ce9f4a0f660d4f66c5258e547
|
|
7
|
+
data.tar.gz: 2a09541af9b0028a16338dd13d31014e1e919e730e86ff370150536f1a2e4a8911532283dea8f7d57571010fffa5c2986097fda8d4da7034b35a3afbc806fcfa
|
data/.github/workflows/CI.yml
CHANGED
data/README.md
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
# JIRA API Gem
|
|
2
2
|
|
|
3
|
-
[](https://codeclimate.com/github/sumoheavy/jira-ruby)
|
|
4
3
|
[](https://github.com/sumoheavy/jira-ruby/actions/workflows/CI.yml)
|
|
5
4
|
|
|
6
5
|
This gem provides access to the Atlassian JIRA REST API.
|
data/jira-ruby.gemspec
CHANGED
data/lib/jira/base_factory.rb
CHANGED
|
@@ -38,7 +38,7 @@ module JIRA
|
|
|
38
38
|
# The principle purpose of this class is to delegate methods to the corresponding
|
|
39
39
|
# non-factory class and automatically prepend the client argument to the argument
|
|
40
40
|
# list.
|
|
41
|
-
delegate_to_target_class :all, :find, :collection_path, :singular_path, :jql, :get_backlog_issues,
|
|
41
|
+
delegate_to_target_class :all, :find, :collection_path, :singular_path, :jql, :jql_paged, :get_backlog_issues,
|
|
42
42
|
:get_board_issues, :get_sprints, :get_sprint_issues, :get_projects, :get_projects_full
|
|
43
43
|
|
|
44
44
|
# This method needs special handling as it has a default argument value
|
data/lib/jira/resource/issue.rb
CHANGED
|
@@ -80,7 +80,57 @@ module JIRA
|
|
|
80
80
|
result
|
|
81
81
|
end
|
|
82
82
|
|
|
83
|
+
# Get issues using JQL query.
|
|
84
|
+
# @param client [JIRA::Client]
|
|
85
|
+
# @param jql [String] the JQL query string to search with
|
|
86
|
+
# @param options [Hash] Jira API options for the search
|
|
87
|
+
# @return [Array<JIRA::Resource::Issue>] or [Integer] total count if max_results is 0
|
|
83
88
|
def self.jql(client, jql, options = { fields: nil, max_results: nil, expand: nil, reconcile_issues: nil })
|
|
89
|
+
issues = []
|
|
90
|
+
total = nil
|
|
91
|
+
next_page_token = nil
|
|
92
|
+
is_last = false
|
|
93
|
+
|
|
94
|
+
until is_last
|
|
95
|
+
result = jql_paged(client, jql, options.merge(next_page_token:))
|
|
96
|
+
|
|
97
|
+
issues.concat(result[:issues])
|
|
98
|
+
total = result[:total]
|
|
99
|
+
next_page_token = result[:next_page_token]
|
|
100
|
+
is_last = next_page_token.nil?
|
|
101
|
+
end
|
|
102
|
+
options[:max_results]&.zero? ? total : issues
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
# Get paged issues using JQL query.
|
|
106
|
+
# @param jql [String] the JQL query string to search with
|
|
107
|
+
# @param options [Hash] Jira API options for the search, including next_page_token
|
|
108
|
+
# @return [Hash] with format { issues: [JIRA::Resource::Issue], next_page_token: [String], total: [Integer] }
|
|
109
|
+
def self.jql_paged(client, jql, options = { fields: nil, max_results: nil, expand: nil, reconcile_issues: nil, next_page_token: nil })
|
|
110
|
+
url = jql_url(client, jql, options)
|
|
111
|
+
next_page_token = options[:next_page_token]
|
|
112
|
+
max_results = options[:max_results]
|
|
113
|
+
|
|
114
|
+
issues = []
|
|
115
|
+
|
|
116
|
+
page_url = url.dup
|
|
117
|
+
page_url << "&nextPageToken=#{next_page_token}" if next_page_token
|
|
118
|
+
|
|
119
|
+
response = client.get(page_url)
|
|
120
|
+
json = parse_json(response.body)
|
|
121
|
+
total = json['total']
|
|
122
|
+
|
|
123
|
+
unless max_results&.zero?
|
|
124
|
+
next_page_token = json['nextPageToken']
|
|
125
|
+
json['issues'].map do |issue|
|
|
126
|
+
issues << client.Issue.build(issue)
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
{ issues:, next_page_token:, total: }
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def self.jql_url(client, jql, options)
|
|
84
134
|
url = client.options[:rest_base_path] + "/search/jql?jql=#{CGI.escape(jql)}"
|
|
85
135
|
|
|
86
136
|
if options[:fields]
|
|
@@ -95,24 +145,7 @@ module JIRA
|
|
|
95
145
|
options[:expand] = [options[:expand]] if options[:expand].is_a?(String)
|
|
96
146
|
url << "&expand=#{options[:expand].to_a.map { |value| CGI.escape(value.to_s) }.join(',')}"
|
|
97
147
|
end
|
|
98
|
-
|
|
99
|
-
issues = []
|
|
100
|
-
next_page_token = nil
|
|
101
|
-
json = {}
|
|
102
|
-
while json['isLast'] != true
|
|
103
|
-
page_url = url.dup
|
|
104
|
-
page_url << "&nextPageToken=#{next_page_token}" if next_page_token
|
|
105
|
-
|
|
106
|
-
response = client.get(page_url)
|
|
107
|
-
json = parse_json(response.body)
|
|
108
|
-
return json['total'] if options[:max_results]&.zero?
|
|
109
|
-
|
|
110
|
-
next_page_token = json['nextPageToken']
|
|
111
|
-
json['issues'].map do |issue|
|
|
112
|
-
issues << client.Issue.build(issue)
|
|
113
|
-
end
|
|
114
|
-
end
|
|
115
|
-
issues
|
|
148
|
+
url
|
|
116
149
|
end
|
|
117
150
|
|
|
118
151
|
# Fetches the attributes for the specified resource from JIRA unless
|
data/lib/jira/version.rb
CHANGED
|
@@ -78,10 +78,9 @@ describe JIRA::Resource::Issue do
|
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
describe 'GET jql issues' do # JIRA::Resource::Issue.jql uses the search endpoint
|
|
81
|
-
jql_query_string = "PROJECT = 'SAMPLEPROJECT'"
|
|
82
81
|
let(:client) { client }
|
|
83
82
|
let(:site_url) { site_url }
|
|
84
|
-
let(:jql_query_string) {
|
|
83
|
+
let(:jql_query_string) { "PROJECT = 'SAMPLEPROJECT'" }
|
|
85
84
|
|
|
86
85
|
let(:expected_attributes) do
|
|
87
86
|
{
|
|
@@ -173,6 +173,40 @@ describe JIRA::Resource::Issue do
|
|
|
173
173
|
end
|
|
174
174
|
end
|
|
175
175
|
|
|
176
|
+
describe '.jql_paged' do
|
|
177
|
+
let(:issue) { double }
|
|
178
|
+
let(:response) { double }
|
|
179
|
+
|
|
180
|
+
before do
|
|
181
|
+
allow(response).to receive(:body).and_return(response_string)
|
|
182
|
+
allow(client).to receive(:Issue).and_return(issue)
|
|
183
|
+
allow(issue).to receive(:build).with({ 'key' => 'foo' }).and_return('1')
|
|
184
|
+
allow(issue).to receive(:build).with({ 'key' => 'bar' }).and_return('2')
|
|
185
|
+
allow(issue).to receive(:build).with({ 'key' => 'baz' }).and_return('3')
|
|
186
|
+
end
|
|
187
|
+
|
|
188
|
+
context 'without next_page_token (first page)' do
|
|
189
|
+
subject { described_class.jql_paged(client, 'foo bar', page_size: 2) }
|
|
190
|
+
|
|
191
|
+
before { expect(client).to receive(:get).with('/jira/rest/api/2/search/jql?jql=foo+bar').and_return(response) }
|
|
192
|
+
|
|
193
|
+
let(:response) { double }
|
|
194
|
+
let(:response_string) { '{"issues": [{"key":"foo"},{"key":"bar"}], "isLast": false, "nextPageToken": "abc"}' }
|
|
195
|
+
|
|
196
|
+
it { is_expected.to eq(issues: %w[1 2], next_page_token: 'abc', total: nil) }
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
context 'with next_page_token' do
|
|
200
|
+
subject { described_class.jql_paged(client, 'foo bar', page_size: 2, next_page_token: 'abc') }
|
|
201
|
+
|
|
202
|
+
let(:response_string) { '{"issues": [{"key":"baz"}], "isLast": true}' }
|
|
203
|
+
|
|
204
|
+
before { expect(client).to receive(:get).with('/jira/rest/api/2/search/jql?jql=foo+bar&nextPageToken=abc').and_return(double(body: response_string)) }
|
|
205
|
+
|
|
206
|
+
it { is_expected.to eq(issues: %w[3], next_page_token: nil, total: nil) }
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
|
|
176
210
|
it 'returns meta data available for editing an issue' do
|
|
177
211
|
subject = described_class.new(client, attrs: { 'fields' => { 'key' => 'TST=123' } })
|
|
178
212
|
response = double
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jira-ruby
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- SUMO Heavy Industries
|
|
8
8
|
- test IO
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-02-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -38,6 +38,20 @@ dependencies:
|
|
|
38
38
|
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: cgi
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
41
55
|
- !ruby/object:Gem::Dependency
|
|
42
56
|
name: multipart-post
|
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|