rujira 0.1.4 → 0.1.5
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 +16 -1
- data/Rakefile +20 -2
- data/lib/rujira/api/search.rb +5 -1
- data/lib/rujira/api/server_info.rb +1 -1
- data/lib/rujira/entity.rb +6 -0
- data/lib/rujira/tasks/jira.rb +55 -26
- data/lib/rujira/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 96e27cf9c81ca531b4420dd97af3d4bd9a05707667e4027e47356e28d701ffd1
|
4
|
+
data.tar.gz: 696c3a16896f5b5147efdcb8e1f4a8aa7d621af24da5b658e958cfbbbd9c50c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36b03ae34cb00d9af66ca8680c2809fc97b9039bddbc803d12f4067535c7a689b3adb5a5a1a9edf2fa5de044e7136e73306a2838b26f18009cf3989bc400e34a
|
7
|
+
data.tar.gz: 440e05d095d25d262942abcde295ebb48568a22b12a66bdaeb24531f9e2ed17cdd4c3d969ec9c1d5169f6e5cb34d26be353c3491b8c93dc7fe53e7a96d53e3fc
|
data/README.md
CHANGED
@@ -17,10 +17,11 @@
|
|
17
17
|
}
|
18
18
|
Rujira::Api::Issue.watchers 'ITMG-1', 'wilful'
|
19
19
|
Rujira::Api::Issue.get 'ITMG-1'
|
20
|
-
Rujira::Api::Search.get jql: 'project = ITMG and status IN ("To Do", "In Progress") ORDER BY issuekey',
|
20
|
+
result = Rujira::Api::Search.get jql: 'project = ITMG and status IN ("To Do", "In Progress") ORDER BY issuekey',
|
21
21
|
maxResults: 10,
|
22
22
|
startAt: 0,
|
23
23
|
fields: ['id', 'key']
|
24
|
+
result.iter
|
24
25
|
Rujira::Api::Issue.comment 'ITMG-1', body: 'Adding a new comment'
|
25
26
|
Rujira::Api::Issue.edit 'ITMG-1', update: {
|
26
27
|
labels:[{add: 'rujira'},{remove: 'bot'}],
|
@@ -31,9 +32,23 @@
|
|
31
32
|
}
|
32
33
|
Rujira::Api::Issue.del 'ITMG-1'
|
33
34
|
|
35
|
+
## Rake tasks
|
36
|
+
|
37
|
+
require 'rujira/tasks/jira'
|
38
|
+
rake jira::whoami
|
39
|
+
rake jira:create -- '--project=ITMG' \
|
40
|
+
'--summary=The short summary information' \
|
41
|
+
'--description=The base description of task' \
|
42
|
+
'--issuetype=Task'
|
43
|
+
rake jira:search -- '-q project = ITMG'
|
44
|
+
|
34
45
|
## Testing
|
35
46
|
|
36
47
|
### Run the instance of jira
|
37
48
|
|
38
49
|
docker compose up -d
|
39
50
|
open http://localhost:8080
|
51
|
+
|
52
|
+
### Example with Curl
|
53
|
+
|
54
|
+
curl -H "Authorization: Bearer <JIRA_ACCESS_TOKEN>" 'http://localhost:8080/rest/api/2/search?expand=summary'
|
data/Rakefile
CHANGED
@@ -1,4 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rake/testtask'
|
5
|
+
|
6
|
+
$LOAD_PATH.unshift File.expand_path('lib', __dir__)
|
7
|
+
require 'rujira'
|
8
|
+
require 'rujira/tasks/jira'
|
9
|
+
|
10
|
+
task default: %i[test]
|
11
|
+
|
12
|
+
Rake::TestTask.new do |t|
|
13
|
+
t.libs << 'test'
|
14
|
+
t.test_files = FileList['test/test*.rb']
|
15
|
+
t.verbose = false
|
16
|
+
end
|
17
|
+
|
18
|
+
Rujira::Tasks::Jira.new
|
19
|
+
|
20
|
+
task :version do
|
21
|
+
puts Rujira::VERSION
|
22
|
+
end
|
data/lib/rujira/api/search.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
module Rujira
|
4
4
|
module Api
|
5
5
|
# TODO
|
6
|
-
# https://docs.atlassian.com/software/jira/docs/api/REST/8.17.1/#api/2/
|
6
|
+
# https://docs.atlassian.com/software/jira/docs/api/REST/8.17.1/#api/2/serverInfo
|
7
7
|
class ServerInfo < Item
|
8
8
|
def self.get
|
9
9
|
entity = Entity.build do
|
data/lib/rujira/entity.rb
CHANGED
@@ -5,6 +5,7 @@ module Rujira
|
|
5
5
|
class Entity
|
6
6
|
def initialize
|
7
7
|
@method = :GET
|
8
|
+
@params = {}
|
8
9
|
@rest_api = 'rest/api/2'
|
9
10
|
end
|
10
11
|
|
@@ -17,6 +18,10 @@ module Rujira
|
|
17
18
|
entity
|
18
19
|
end
|
19
20
|
|
21
|
+
def params(params)
|
22
|
+
@params = params
|
23
|
+
end
|
24
|
+
|
20
25
|
def method(method)
|
21
26
|
@method = method
|
22
27
|
end
|
@@ -73,6 +78,7 @@ module Rujira
|
|
73
78
|
def post
|
74
79
|
request do
|
75
80
|
client.post path do |req|
|
81
|
+
req.params = @params
|
76
82
|
req.body = data.to_json
|
77
83
|
end
|
78
84
|
end
|
data/lib/rujira/tasks/jira.rb
CHANGED
@@ -11,47 +11,76 @@ module Rujira
|
|
11
11
|
include ::Rake::DSL if defined?(::Rake::DSL)
|
12
12
|
|
13
13
|
def initialize
|
14
|
+
@options = {
|
15
|
+
issuetype: 'Task'
|
16
|
+
}
|
17
|
+
@parser = OptionParser.new
|
14
18
|
define
|
15
19
|
end
|
16
20
|
|
17
|
-
def
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
+
def parser
|
22
|
+
yield
|
23
|
+
args = @parser.order!(ARGV) {}
|
24
|
+
@parser.parse!(args)
|
21
25
|
end
|
22
26
|
|
23
|
-
def
|
24
|
-
name
|
25
|
-
desc 'Request my real name in Jira'
|
26
|
-
|
27
|
-
Rake::Task[name].clear if Rake::Task.task_defined?(name)
|
28
|
-
namespace :jira do
|
29
|
-
task name do
|
30
|
-
puts Rujira::Api::Myself.get.name
|
31
|
-
end
|
32
|
-
end
|
27
|
+
def options(name)
|
28
|
+
@options[name]
|
33
29
|
end
|
34
30
|
|
35
|
-
|
36
|
-
|
37
|
-
|
31
|
+
# rubocop:disable Metrics/AbcSize
|
32
|
+
# rubocop:disable Metrics/MethodLength
|
33
|
+
def define
|
34
|
+
generate 'whoami' do
|
35
|
+
puts Rujira::Api::Myself.get.name
|
36
|
+
end
|
37
|
+
generate 'url' do
|
38
|
+
puts Rujira::Configuration.url
|
39
|
+
end
|
40
|
+
generate 'server_info' do
|
41
|
+
puts Rujira::Api::ServerInfo.get.data.to_json
|
42
|
+
end
|
43
|
+
generate 'create' do
|
44
|
+
parser do
|
45
|
+
@parser.banner = "Usage: rake jira:task:create -- '[options]'"
|
46
|
+
@parser.on('-p PROJECT', '--project=PROJECT') { |project| @options[:project] = project.strip }
|
47
|
+
@parser.on('-s SUMMARY', '--summary=SUMMARY') { |summary| @options[:summary] = summary.strip }
|
48
|
+
@parser.on('-d DESCRIPTION', '--description=DESCRIPTION') do |description|
|
49
|
+
@options[:description] = description.strip
|
50
|
+
end
|
51
|
+
@parser.on('-i ISSUETYPE', '--issuetype=ISSUETYPE') { |issuetype| @options[:issuetype] = issuetype.strip }
|
52
|
+
end
|
38
53
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
54
|
+
result = Rujira::Api::Issue.create fields: {
|
55
|
+
project: { key: @options[:project] },
|
56
|
+
summary: @options[:summary],
|
57
|
+
issuetype: { name: @options[:issuetype] },
|
58
|
+
description: @options[:description]
|
59
|
+
}
|
60
|
+
url = Rujira::Configuration.url
|
61
|
+
puts "// A new task been posted, check it out at #{url}/browse/#{result.data['key']}"
|
62
|
+
end
|
63
|
+
generate 'search' do
|
64
|
+
parser do
|
65
|
+
@parser.banner = "Usage: rake jira:task:search -- '[options]'"
|
66
|
+
@parser.on('-q JQL', '--jql=JQL') { |jql| @options[:jql] = jql }
|
43
67
|
end
|
68
|
+
|
69
|
+
result = Rujira::Api::Search.get jql: @options[:jql]
|
70
|
+
result.iter.each { |i| puts JSON.pretty_generate(i.data) }
|
44
71
|
end
|
45
72
|
end
|
73
|
+
# rubocop:enable Metrics/AbcSize
|
74
|
+
# rubocop:enable Metrics/MethodLength
|
46
75
|
|
47
|
-
def
|
48
|
-
|
49
|
-
desc
|
76
|
+
def generate(name, &block)
|
77
|
+
fullname = "jira:#{name}"
|
78
|
+
desc "Run #{fullname}"
|
50
79
|
|
51
|
-
Rake::Task[
|
80
|
+
Rake::Task[fullname].clear if Rake::Task.task_defined?(fullname)
|
52
81
|
namespace :jira do
|
53
82
|
task name do
|
54
|
-
|
83
|
+
instance_eval(&block)
|
55
84
|
end
|
56
85
|
end
|
57
86
|
end
|
data/lib/rujira/version.rb
CHANGED
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.5
|
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-04-20 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!
|