rujira 0.1.0 → 0.1.2
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 +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 +10 -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: b30eacffd8fe9cd8ffa883aba1c85fb7d825222205b456dcf8c1f3dc301e0c50
|
4
|
+
data.tar.gz: e4805fe425b509c840c9b71f6816399197022ef115598fc1bfd27324b635cff3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77b4be2293066b682f87a6150471dff71cd4849d85e93f189f26ec3ee3c7f7773f15c827fd79307982fe4c13ec8f519f3e143f8a2105fd0eebbb89f1eabdf54b
|
7
|
+
data.tar.gz: c3bb572c07824626af1524c741a0d9fc227ab629da8fe088e71e0298d7b38ed53cb3e737f196ffd8d9529935668333ce9603040537c1f8c925b39a09c40a35ef
|
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,21 @@
|
|
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
|
+
url: Configuration.url
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
def run
|
14
|
+
Faraday.new(@options) do |builder|
|
15
|
+
builder.request :authorization, 'Bearer', -> { @token }
|
10
16
|
builder.request :json
|
11
17
|
builder.response :json
|
12
18
|
builder.response :raise_error
|
13
19
|
builder.response :logger if Configuration.debug
|
14
20
|
end
|
15
21
|
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
def self.token
|
20
|
-
Configuration.token
|
21
|
-
end
|
22
22
|
end
|
23
23
|
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.2
|
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
|