rujira 0.1.5 → 0.1.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +31 -19
- data/compose.yaml +1 -0
- data/lib/rujira/api/attachments.rb +9 -0
- data/lib/rujira/api/issue.rb +30 -16
- data/lib/rujira/api/project.rb +2 -1
- data/lib/rujira/api/search.rb +2 -2
- data/lib/rujira/connection.rb +1 -0
- data/lib/rujira/entity.rb +15 -4
- data/lib/rujira/tasks/jira.rb +31 -7
- data/lib/rujira/version.rb +1 -1
- data/lib/rujira.rb +2 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be517969de7ad5a326182e68a46edd4b20d5b5a18ce91a0ca04df2c358a827ed
|
4
|
+
data.tar.gz: '09c6ae394603fe54be3be5d7119ff054556f68991ab3fb80cbf4dbb373b98dea'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56a6b962413d44807786d0399a3c1c5f96c947eb13f893093e86418e87394a3b8bb598e9c10e042c6b48585dca8d5850257c4cf547c78f1fdaa0cf0698ceac4e
|
7
|
+
data.tar.gz: b92fe934ebb3c07213f5432744e06fdfbab201ce06f21733758c7f95e285469cff7951fdfab07bf8fa5c521c3c3b57c6e5b335db7b0f51ada2da0d3f6a9e98a8
|
data/README.md
CHANGED
@@ -8,28 +8,37 @@
|
|
8
8
|
|
9
9
|
name = Rujira::Api::Myself.get.name
|
10
10
|
Rujira::Api::Project.get 'ITMG'
|
11
|
-
Rujira::Api::Issue.create
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
Rujira::Api::Issue.create do
|
12
|
+
data fields: {
|
13
|
+
project: { key: 'ITMG' },
|
14
|
+
summary: 'BOT: added a new feature.',
|
15
|
+
description: 'This task was generated by the bot when creating changes in the repository.',
|
16
|
+
issuetype: { name: 'Task' },
|
17
|
+
labels: ['bot'] }
|
18
|
+
params updateHistory: true
|
19
|
+
end
|
18
20
|
Rujira::Api::Issue.watchers 'ITMG-1', 'wilful'
|
19
21
|
Rujira::Api::Issue.get 'ITMG-1'
|
20
|
-
result = Rujira::Api::Search.get
|
21
|
-
|
22
|
-
|
23
|
-
|
22
|
+
result = Rujira::Api::Search.get do
|
23
|
+
data jql: 'project = ITMG and status IN ("To Do", "In Progress") ORDER BY issuekey',
|
24
|
+
maxResults: 10,
|
25
|
+
startAt: 0,
|
26
|
+
fields: ['id', 'key']
|
27
|
+
end
|
24
28
|
result.iter
|
25
|
-
Rujira::Api::Issue.comment 'ITMG-1'
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
29
|
+
Rujira::Api::Issue.comment 'ITMG-1' do
|
30
|
+
data body: 'Adding a new comment'
|
31
|
+
end
|
32
|
+
Rujira::Api::Issue.edit 'ITMG-1' do
|
33
|
+
data update: {
|
34
|
+
labels:[{add: 'rujira'},{remove: 'bot'}],
|
35
|
+
},
|
36
|
+
fields: {
|
37
|
+
assignee: { name: name },
|
38
|
+
summary: 'This is a shorthand for a set operation on the summary field'
|
39
|
+
}
|
40
|
+
end
|
41
|
+
Rujira::Api::Issue.attachments 'ITMG-1', 'upload.png'
|
33
42
|
Rujira::Api::Issue.del 'ITMG-1'
|
34
43
|
|
35
44
|
## Rake tasks
|
@@ -41,6 +50,7 @@
|
|
41
50
|
'--description=The base description of task' \
|
42
51
|
'--issuetype=Task'
|
43
52
|
rake jira:search -- '-q project = ITMG'
|
53
|
+
rake jira:attach -- '--file=upload.png' '--issue=ITMG-1'
|
44
54
|
|
45
55
|
## Testing
|
46
56
|
|
@@ -52,3 +62,5 @@
|
|
52
62
|
### Example with Curl
|
53
63
|
|
54
64
|
curl -H "Authorization: Bearer <JIRA_ACCESS_TOKEN>" 'http://localhost:8080/rest/api/2/search?expand=summary'
|
65
|
+
curl -D- -F "file=@upload.png" -X POST -H "X-Atlassian-Token: nocheck" \
|
66
|
+
-H "Authorization: Bearer <JIRA_ACCESS_TOKEN>" 'http://localhost:8080/rest/api/2/issue/ITMG-70/attachments'
|
data/compose.yaml
CHANGED
data/lib/rujira/api/issue.rb
CHANGED
@@ -5,56 +5,70 @@ module Rujira
|
|
5
5
|
# TODO
|
6
6
|
# https://docs.atlassian.com/software/jira/docs/api/REST/8.17.1/#api/2/issue
|
7
7
|
class Issue < Item
|
8
|
-
def self.
|
8
|
+
def self.create(&block)
|
9
9
|
entity = Entity.build do
|
10
|
-
path
|
10
|
+
path 'issue'
|
11
|
+
method :POST
|
12
|
+
instance_eval(&block) if block_given?
|
11
13
|
end
|
12
14
|
new(entity.commit)
|
13
15
|
end
|
14
16
|
|
15
|
-
def self.
|
17
|
+
def self.get(id_or_key, &block)
|
16
18
|
entity = Entity.build do
|
17
19
|
path "issue/#{id_or_key}"
|
18
|
-
|
20
|
+
instance_eval(&block) if block_given?
|
19
21
|
end
|
20
|
-
entity.commit
|
22
|
+
new(entity.commit)
|
21
23
|
end
|
22
24
|
|
23
|
-
def self.
|
25
|
+
def self.del(id_or_key, &block)
|
24
26
|
entity = Entity.build do
|
25
|
-
path
|
26
|
-
method :
|
27
|
-
|
27
|
+
path "issue/#{id_or_key}"
|
28
|
+
method :DELETE
|
29
|
+
instance_eval(&block) if block_given?
|
28
30
|
end
|
29
|
-
|
31
|
+
entity.commit
|
30
32
|
end
|
31
33
|
|
32
|
-
def self.edit(id_or_key,
|
34
|
+
def self.edit(id_or_key, &block)
|
33
35
|
entity = Entity.build do
|
34
36
|
path "issue/#{id_or_key}"
|
35
37
|
method :PUT
|
36
|
-
|
38
|
+
instance_eval(&block) if block_given?
|
37
39
|
end
|
38
40
|
new(entity.commit)
|
39
41
|
end
|
40
42
|
|
41
|
-
def self.comment(id_or_key,
|
43
|
+
def self.comment(id_or_key, &block)
|
42
44
|
entity = Entity.build do
|
43
45
|
path "issue/#{id_or_key}/comment"
|
44
46
|
method :POST
|
45
|
-
|
47
|
+
instance_eval(&block) if block_given?
|
46
48
|
end
|
47
49
|
Comment.new(entity.commit)
|
48
50
|
end
|
49
51
|
|
50
|
-
def self.watchers(id_or_key,
|
52
|
+
def self.watchers(id_or_key, &block)
|
51
53
|
entity = Entity.build do
|
52
54
|
path "issue/#{id_or_key}/watchers"
|
53
55
|
method :POST
|
54
|
-
|
56
|
+
instance_eval(&block) if block_given?
|
55
57
|
end
|
56
58
|
new(entity.commit)
|
57
59
|
end
|
60
|
+
|
61
|
+
def self.attachments(id_or_key, path, &block)
|
62
|
+
entity = Entity.build do
|
63
|
+
path "issue/#{id_or_key}/attachments"
|
64
|
+
method :POST
|
65
|
+
headers 'Content-Type': 'multipart/form-data', 'X-Atlassian-Token': 'nocheck',
|
66
|
+
'Transfer-Encoding': 'chunked', 'Content-Length': File.size(path).to_s
|
67
|
+
data file: Faraday::Multipart::FilePart.new(path, 'multipart/form-data')
|
68
|
+
instance_eval(&block) if block_given?
|
69
|
+
end
|
70
|
+
Attachments.new(entity.commit)
|
71
|
+
end
|
58
72
|
end
|
59
73
|
end
|
60
74
|
end
|
data/lib/rujira/api/project.rb
CHANGED
@@ -5,9 +5,10 @@ module Rujira
|
|
5
5
|
# TODO
|
6
6
|
# https://docs.atlassian.com/software/jira/docs/api/REST/8.17.1/#api/2/project
|
7
7
|
class Project < Item
|
8
|
-
def self.get(id_or_key)
|
8
|
+
def self.get(id_or_key, &block)
|
9
9
|
entity = Entity.build do
|
10
10
|
path "project/#{id_or_key}"
|
11
|
+
instance_eval(&block) if block_given?
|
11
12
|
end
|
12
13
|
new(entity.commit)
|
13
14
|
end
|
data/lib/rujira/api/search.rb
CHANGED
@@ -5,11 +5,11 @@ module Rujira
|
|
5
5
|
# TODO
|
6
6
|
# https://docs.atlassian.com/software/jira/docs/api/REST/8.17.1/#api/2/search
|
7
7
|
class Search < Item
|
8
|
-
def self.get(
|
8
|
+
def self.get(&block)
|
9
9
|
entity = Entity.build do
|
10
10
|
path 'search'
|
11
|
-
data data
|
12
11
|
method :POST
|
12
|
+
instance_eval(&block) if block_given?
|
13
13
|
end
|
14
14
|
new(entity.commit)
|
15
15
|
end
|
data/lib/rujira/connection.rb
CHANGED
data/lib/rujira/entity.rb
CHANGED
@@ -6,6 +6,7 @@ module Rujira
|
|
6
6
|
def initialize
|
7
7
|
@method = :GET
|
8
8
|
@params = {}
|
9
|
+
@headers = {}
|
9
10
|
@rest_api = 'rest/api/2'
|
10
11
|
end
|
11
12
|
|
@@ -22,6 +23,10 @@ module Rujira
|
|
22
23
|
@params = params
|
23
24
|
end
|
24
25
|
|
26
|
+
def headers(headers)
|
27
|
+
@headers = headers
|
28
|
+
end
|
29
|
+
|
25
30
|
def method(method)
|
26
31
|
@method = method
|
27
32
|
end
|
@@ -65,21 +70,26 @@ module Rujira
|
|
65
70
|
|
66
71
|
def get
|
67
72
|
request do
|
68
|
-
client.get path
|
73
|
+
client.get path do |req|
|
74
|
+
req.params = @params
|
75
|
+
end
|
69
76
|
end
|
70
77
|
end
|
71
78
|
|
72
79
|
def delete
|
73
80
|
request do
|
74
|
-
client.delete path
|
81
|
+
client.delete path do |req|
|
82
|
+
req.params = @params
|
83
|
+
end
|
75
84
|
end
|
76
85
|
end
|
77
86
|
|
78
87
|
def post
|
79
88
|
request do
|
80
89
|
client.post path do |req|
|
90
|
+
req.headers = @headers
|
81
91
|
req.params = @params
|
82
|
-
req.body = data
|
92
|
+
req.body = data
|
83
93
|
end
|
84
94
|
end
|
85
95
|
end
|
@@ -87,7 +97,8 @@ module Rujira
|
|
87
97
|
def put
|
88
98
|
request do
|
89
99
|
client.put path do |req|
|
90
|
-
req.
|
100
|
+
req.params = @params
|
101
|
+
req.body = data
|
91
102
|
end
|
92
103
|
end
|
93
104
|
end
|
data/lib/rujira/tasks/jira.rb
CHANGED
@@ -51,12 +51,15 @@ module Rujira
|
|
51
51
|
@parser.on('-i ISSUETYPE', '--issuetype=ISSUETYPE') { |issuetype| @options[:issuetype] = issuetype.strip }
|
52
52
|
end
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
54
|
+
options = @options
|
55
|
+
result = Rujira::Api::Issue.create do
|
56
|
+
data fields: {
|
57
|
+
project: { key: options[:project] },
|
58
|
+
summary: options[:summary],
|
59
|
+
issuetype: { name: options[:issuetype] },
|
60
|
+
description: options[:description]
|
61
|
+
}
|
62
|
+
end
|
60
63
|
url = Rujira::Configuration.url
|
61
64
|
puts "// A new task been posted, check it out at #{url}/browse/#{result.data['key']}"
|
62
65
|
end
|
@@ -66,9 +69,30 @@ module Rujira
|
|
66
69
|
@parser.on('-q JQL', '--jql=JQL') { |jql| @options[:jql] = jql }
|
67
70
|
end
|
68
71
|
|
69
|
-
|
72
|
+
options = @options
|
73
|
+
result = Rujira::Api::Search.get do
|
74
|
+
data jql: options[:jql]
|
75
|
+
end
|
70
76
|
result.iter.each { |i| puts JSON.pretty_generate(i.data) }
|
71
77
|
end
|
78
|
+
generate 'delete' do
|
79
|
+
parser do
|
80
|
+
@parser.banner = "Usage: rake jira:task:delete -- '[options]'"
|
81
|
+
@parser.on('-i ID', '--issue=ID') { |id| @options[:id] = id }
|
82
|
+
end
|
83
|
+
|
84
|
+
Rujira::Api::Issue.del @options[:id]
|
85
|
+
end
|
86
|
+
generate 'attach' do
|
87
|
+
parser do
|
88
|
+
@parser.banner = "Usage: rake jira:task:attach -- '[options]'"
|
89
|
+
@parser.on('-f FILE', '--file=FILE') { |file| @options[:file] = file }
|
90
|
+
@parser.on('-i ID', '--issue=ID') { |id| @options[:id] = id }
|
91
|
+
end
|
92
|
+
|
93
|
+
result = Rujira::Api::Issue.attachments @options[:id], @options[:file]
|
94
|
+
puts JSON.pretty_generate(result.data)
|
95
|
+
end
|
72
96
|
end
|
73
97
|
# rubocop:enable Metrics/AbcSize
|
74
98
|
# rubocop:enable Metrics/MethodLength
|
data/lib/rujira/version.rb
CHANGED
data/lib/rujira.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'faraday'
|
4
|
+
require 'faraday/multipart'
|
4
5
|
require 'json'
|
5
6
|
require_relative 'rujira/version'
|
6
7
|
require_relative 'rujira/connection'
|
@@ -11,6 +12,7 @@ require_relative 'rujira/api/search'
|
|
11
12
|
require_relative 'rujira/api/issue'
|
12
13
|
require_relative 'rujira/api/project'
|
13
14
|
require_relative 'rujira/api/comment'
|
15
|
+
require_relative 'rujira/api/attachments'
|
14
16
|
require_relative 'rujira/api/myself'
|
15
17
|
require_relative 'rujira/api/server_info'
|
16
18
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rujira
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrey Semenov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04
|
11
|
+
date: 2024-05-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: The library is developed for the purposes of the organization, new features
|
14
14
|
can be added as MR. Welcome!
|
@@ -25,6 +25,7 @@ files:
|
|
25
25
|
- Rakefile
|
26
26
|
- compose.yaml
|
27
27
|
- lib/rujira.rb
|
28
|
+
- lib/rujira/api/attachments.rb
|
28
29
|
- lib/rujira/api/comment.rb
|
29
30
|
- lib/rujira/api/issue.rb
|
30
31
|
- lib/rujira/api/item.rb
|