rujira 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/rujira/api/issue.rb +20 -8
- data/lib/rujira/api/item.rb +14 -0
- data/lib/rujira/api/project.rb +7 -5
- data/lib/rujira/api/search.rb +8 -3
- data/lib/rujira/connection.rb +14 -10
- data/lib/rujira/entity.rb +42 -6
- data/lib/rujira/version.rb +1 -1
- data/lib/rujira.rb +1 -3
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 118679fb7732b4578123d0b46d84866c53dfec033371ee23340c1577b8a617f9
|
4
|
+
data.tar.gz: 2eb948f7e8396d29e85846305be17467474999b1181c60c9d5df2bfab58c2dbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a83a70d2874424eb0d184c9d72984e492de8a45517a70743666842237f4bbd3554caafef8fd6a2eea18233070c7ce87cd6e45d04ade74ab355b2a87ec0c22bc5
|
7
|
+
data.tar.gz: e506438b768f8e415af31d5b7c0dca388b6b0ed7e6efecadde015a1d31bfec367dd1558da7e92ad7cb5040c26ffbc0b450d024e5dc3322f6e4dd3a381345721b
|
data/README.md
CHANGED
@@ -7,7 +7,6 @@
|
|
7
7
|
## Usage in the code
|
8
8
|
|
9
9
|
Rujira::Api::Project.get 'ITMG'
|
10
|
-
Rujira::Api::Issue.get 'ITMG-1'
|
11
10
|
Rujira::Api::Issue.create fields: {
|
12
11
|
project: { key: 'ITMG' },
|
13
12
|
assignee: { name: 'wilful' },
|
@@ -16,10 +15,12 @@
|
|
16
15
|
issuetype: { name: 'Task' },
|
17
16
|
labels: ['bot']
|
18
17
|
}
|
18
|
+
Rujira::Api::Issue.get 'ITMG-1'
|
19
19
|
Rujira::Api::Search.get jql: 'project = ITMG and status IN ("To Do", "In Progress") ORDER BY issuekey',
|
20
20
|
maxResults: 10,
|
21
21
|
startAt: 0,
|
22
22
|
fields: ['id', 'key']
|
23
|
+
Rujira::Api::Issue.del 'ITMG-1'
|
23
24
|
|
24
25
|
## Testing
|
25
26
|
|
data/lib/rujira/api/issue.rb
CHANGED
@@ -3,18 +3,30 @@
|
|
3
3
|
module Rujira
|
4
4
|
module Api
|
5
5
|
# TODO
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
# https://docs.atlassian.com/software/jira/docs/api/REST/8.17.1/#api/2/issue
|
7
|
+
class Issue < Item
|
8
|
+
def self.get(id_or_key)
|
9
|
+
entity = Entity.build do
|
10
|
+
path "rest/api/2/issue/#{id_or_key}"
|
11
|
+
end
|
12
|
+
new(entity.commit)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.del(id_or_key)
|
16
|
+
entity = Entity.build do
|
17
|
+
path "rest/api/2/issue/#{id_or_key}"
|
18
|
+
method :DELETE
|
19
|
+
end
|
20
|
+
entity.commit
|
11
21
|
end
|
12
22
|
|
13
23
|
def self.create(**data)
|
14
|
-
Entity.build do
|
24
|
+
entity = Entity.build do
|
15
25
|
path 'rest/api/2/issue'
|
16
|
-
|
17
|
-
|
26
|
+
method :POST
|
27
|
+
data data if data
|
28
|
+
end
|
29
|
+
new(entity.commit)
|
18
30
|
end
|
19
31
|
end
|
20
32
|
end
|
data/lib/rujira/api/project.rb
CHANGED
@@ -3,11 +3,13 @@
|
|
3
3
|
module Rujira
|
4
4
|
module Api
|
5
5
|
# TODO
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
6
|
+
# https://docs.atlassian.com/software/jira/docs/api/REST/8.17.1/#api/2/project
|
7
|
+
class Project < Item
|
8
|
+
def self.get(id_or_key)
|
9
|
+
entity = Entity.build do
|
10
|
+
path "rest/api/2/project/#{id_or_key}"
|
11
|
+
end
|
12
|
+
new(entity.commit)
|
11
13
|
end
|
12
14
|
end
|
13
15
|
end
|
data/lib/rujira/api/search.rb
CHANGED
@@ -3,12 +3,17 @@
|
|
3
3
|
module Rujira
|
4
4
|
module Api
|
5
5
|
# TODO
|
6
|
-
|
6
|
+
# https://docs.atlassian.com/software/jira/docs/api/REST/8.17.1/#api/2/search
|
7
|
+
class Search < Item
|
7
8
|
def self.get(**data)
|
8
|
-
Entity.build do
|
9
|
+
entity = Entity.build do
|
9
10
|
path 'rest/api/2/search'
|
10
11
|
data data
|
11
|
-
|
12
|
+
method :POST
|
13
|
+
end
|
14
|
+
entity.commit['issues'].map do |issue|
|
15
|
+
Issue.new(issue)
|
16
|
+
end
|
12
17
|
end
|
13
18
|
end
|
14
19
|
end
|
data/lib/rujira/connection.rb
CHANGED
@@ -3,21 +3,25 @@
|
|
3
3
|
module Rujira
|
4
4
|
# TODO
|
5
5
|
class Connection
|
6
|
-
def
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
def initialize
|
7
|
+
@token = Configuration.token
|
8
|
+
@options = {
|
9
|
+
request: {
|
10
|
+
open_timeout: 5,
|
11
|
+
timeout: 5
|
12
|
+
},
|
13
|
+
url: Configuration.url
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
def run
|
18
|
+
Faraday.new(@options) do |builder|
|
19
|
+
builder.request :authorization, 'Bearer', -> { @token }
|
10
20
|
builder.request :json
|
11
21
|
builder.response :json
|
12
22
|
builder.response :raise_error
|
13
23
|
builder.response :logger if Configuration.debug
|
14
24
|
end
|
15
25
|
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def self.token
|
20
|
-
Configuration.token
|
21
|
-
end
|
22
26
|
end
|
23
27
|
end
|
data/lib/rujira/entity.rb
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
module Rujira
|
4
4
|
# TODO
|
5
5
|
class Entity
|
6
|
+
def initialize
|
7
|
+
@method = :GET
|
8
|
+
end
|
9
|
+
|
6
10
|
def self.build(&block)
|
7
11
|
entity = new
|
8
12
|
return entity unless block_given?
|
@@ -12,6 +16,10 @@ module Rujira
|
|
12
16
|
entity
|
13
17
|
end
|
14
18
|
|
19
|
+
def method(method)
|
20
|
+
@method = method
|
21
|
+
end
|
22
|
+
|
15
23
|
def path(path = nil)
|
16
24
|
@path ||= path
|
17
25
|
|
@@ -28,20 +36,48 @@ module Rujira
|
|
28
36
|
raise ArgumentError, "No argument to 'data' was given."
|
29
37
|
end
|
30
38
|
|
39
|
+
def commit
|
40
|
+
case @method
|
41
|
+
when :GET
|
42
|
+
get.body
|
43
|
+
when :POST
|
44
|
+
post.body
|
45
|
+
when :DELETE
|
46
|
+
delete.body
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def request
|
53
|
+
yield
|
54
|
+
rescue Faraday::Error => e
|
55
|
+
raise "Status #{e.response[:status]}: #{e.response[:body]}"
|
56
|
+
end
|
57
|
+
|
31
58
|
def get
|
32
|
-
|
59
|
+
request do
|
60
|
+
client.get path
|
61
|
+
end
|
33
62
|
end
|
34
63
|
|
35
|
-
def
|
36
|
-
|
37
|
-
|
64
|
+
def delete
|
65
|
+
request do
|
66
|
+
client.delete path
|
38
67
|
end
|
39
68
|
end
|
40
69
|
|
41
|
-
|
70
|
+
def post
|
71
|
+
request do
|
72
|
+
client.post path do |req|
|
73
|
+
req.body = data.to_json
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
42
77
|
|
43
78
|
def client
|
44
|
-
Rujira::Connection.new
|
79
|
+
conn = Rujira::Connection.new
|
80
|
+
conn.run
|
45
81
|
end
|
46
82
|
end
|
47
83
|
end
|
data/lib/rujira/version.rb
CHANGED
data/lib/rujira.rb
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# https://tomdebruijn.com/posts/ruby-write-your-own-domain-specific-language/
|
4
|
-
# https://docs.atlassian.com/software/jira/docs/api/REST/8.17.1/
|
5
|
-
|
6
3
|
require 'faraday'
|
7
4
|
require 'json'
|
8
5
|
require_relative 'rujira/version'
|
9
6
|
require_relative 'rujira/connection'
|
10
7
|
require_relative 'rujira/configuration'
|
11
8
|
require_relative 'rujira/entity'
|
9
|
+
require_relative 'rujira/api/item'
|
12
10
|
require_relative 'rujira/api/search'
|
13
11
|
require_relative 'rujira/api/issue'
|
14
12
|
require_relative 'rujira/api/project'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrey Semenov
|
@@ -26,6 +26,7 @@ files:
|
|
26
26
|
- compose.yaml
|
27
27
|
- lib/rujira.rb
|
28
28
|
- lib/rujira/api/issue.rb
|
29
|
+
- lib/rujira/api/item.rb
|
29
30
|
- lib/rujira/api/project.rb
|
30
31
|
- lib/rujira/api/search.rb
|
31
32
|
- lib/rujira/configuration.rb
|