rujira 0.1.5 → 0.1.6
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/README.md +30 -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 +10 -0
- 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: b6c5b714472d56b23db8bfe6a5a96e60c3dfd6af7cb8176fbef27d839bc2ace3
|
4
|
+
data.tar.gz: 106ca92334c64b3129f4e66d8aaa570eaa4d09adcba9ac7dad1d4136d6c251a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae579ef0d21f37fb22002669d668ddf6f876a1940da8fd0e5cd6022f8458407913ea3ba398af98590daf75b8dcd4b4b783c0764c05081aef60e24a4db789450d
|
7
|
+
data.tar.gz: 19062bf410f45b08e1a1554743a7f179acb314d3e95a8a92c5d914b1147b64458797ea849da34c19e3867e6c726add88f23c810f186df2cd6f81c76794a1bb39
|
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
|
@@ -52,3 +61,5 @@
|
|
52
61
|
### Example with Curl
|
53
62
|
|
54
63
|
curl -H "Authorization: Bearer <JIRA_ACCESS_TOKEN>" 'http://localhost:8080/rest/api/2/search?expand=summary'
|
64
|
+
curl -D- -F "file=@upload.png" -X POST -H "X-Atlassian-Token: nocheck" \
|
65
|
+
-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
@@ -69,6 +69,16 @@ module Rujira
|
|
69
69
|
result = Rujira::Api::Search.get jql: @options[:jql]
|
70
70
|
result.iter.each { |i| puts JSON.pretty_generate(i.data) }
|
71
71
|
end
|
72
|
+
generate 'attach' do
|
73
|
+
parser do
|
74
|
+
@parser.banner = "Usage: rake jira:task:attach -- '[options]'"
|
75
|
+
@parser.on('-f FILE', '--file=FILE') { |jql| @options[:file] = jql }
|
76
|
+
@parser.on('-i ID', '--issue=ID') { |jql| @options[:id] = jql }
|
77
|
+
end
|
78
|
+
|
79
|
+
result = Rujira::Api::Issue.attachments @options[:id], @options[:file]
|
80
|
+
JSON.pretty_generate(result)
|
81
|
+
end
|
72
82
|
end
|
73
83
|
# rubocop:enable Metrics/AbcSize
|
74
84
|
# 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.6
|
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-
|
11
|
+
date: 2024-05-03 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
|