rujira 0.1.3 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78fd0c99caf8fadbef2ae988ae8eabb606be5231e7346742efebbd72f7a0835c
4
- data.tar.gz: 04a6184b419f51c87c3afe9d34c38161934775cb41d1d78ab5d075ab61474a2d
3
+ metadata.gz: 96e27cf9c81ca531b4420dd97af3d4bd9a05707667e4027e47356e28d701ffd1
4
+ data.tar.gz: 696c3a16896f5b5147efdcb8e1f4a8aa7d621af24da5b658e958cfbbbd9c50c2
5
5
  SHA512:
6
- metadata.gz: 6be3f1dcc91ab2fecd80fab1f9def511680eee6422a4170e992ec49dabeaba9146b22273a5487e3113576192ca6aad29501b1d38f6675df6f941251e56e97387
7
- data.tar.gz: 9d534cb8e088303e3c5904fa8df26e0388f0253be179671ce6f8e207a8160472add3df8d475e58a6a914f75026dee36c7c0b8c2d925e0ee40e5f5c13d4c720d4
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 "bundler/gem_tasks"
4
- task default: %i[]
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
@@ -4,7 +4,7 @@ module Rujira
4
4
  module Api
5
5
  # TODO
6
6
  class Item
7
- attr_accessor :data
7
+ attr_reader :data
8
8
 
9
9
  def initialize(data = nil)
10
10
  @data = data
@@ -11,7 +11,11 @@ module Rujira
11
11
  data data
12
12
  method :POST
13
13
  end
14
- entity.commit['issues'].map do |issue|
14
+ new(entity.commit)
15
+ end
16
+
17
+ def iter
18
+ data['issues'].map do |issue|
15
19
  Issue.new(issue)
16
20
  end
17
21
  end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rujira
4
+ module Api
5
+ # TODO
6
+ # https://docs.atlassian.com/software/jira/docs/api/REST/8.17.1/#api/2/serverInfo
7
+ class ServerInfo < Item
8
+ def self.get
9
+ entity = Entity.build do
10
+ path 'serverInfo'
11
+ end
12
+ new(entity.commit)
13
+ end
14
+ end
15
+ end
16
+ end
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
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'rake'
4
+ require 'rake/tasklib'
5
+ require 'json'
6
+
7
+ module Rujira
8
+ module Tasks
9
+ # TODO
10
+ class Jira
11
+ include ::Rake::DSL if defined?(::Rake::DSL)
12
+
13
+ def initialize
14
+ @options = {
15
+ issuetype: 'Task'
16
+ }
17
+ @parser = OptionParser.new
18
+ define
19
+ end
20
+
21
+ def parser
22
+ yield
23
+ args = @parser.order!(ARGV) {}
24
+ @parser.parse!(args)
25
+ end
26
+
27
+ def options(name)
28
+ @options[name]
29
+ end
30
+
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
53
+
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 }
67
+ end
68
+
69
+ result = Rujira::Api::Search.get jql: @options[:jql]
70
+ result.iter.each { |i| puts JSON.pretty_generate(i.data) }
71
+ end
72
+ end
73
+ # rubocop:enable Metrics/AbcSize
74
+ # rubocop:enable Metrics/MethodLength
75
+
76
+ def generate(name, &block)
77
+ fullname = "jira:#{name}"
78
+ desc "Run #{fullname}"
79
+
80
+ Rake::Task[fullname].clear if Rake::Task.task_defined?(fullname)
81
+ namespace :jira do
82
+ task name do
83
+ instance_eval(&block)
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rujira
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.5"
5
5
  end
data/lib/rujira.rb CHANGED
@@ -12,6 +12,7 @@ require_relative 'rujira/api/issue'
12
12
  require_relative 'rujira/api/project'
13
13
  require_relative 'rujira/api/comment'
14
14
  require_relative 'rujira/api/myself'
15
+ require_relative 'rujira/api/server_info'
15
16
 
16
17
  module Rujira
17
18
  class Error < StandardError; end
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.3
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-15 00:00:00.000000000 Z
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!
@@ -31,9 +31,11 @@ files:
31
31
  - lib/rujira/api/myself.rb
32
32
  - lib/rujira/api/project.rb
33
33
  - lib/rujira/api/search.rb
34
+ - lib/rujira/api/server_info.rb
34
35
  - lib/rujira/configuration.rb
35
36
  - lib/rujira/connection.rb
36
37
  - lib/rujira/entity.rb
38
+ - lib/rujira/tasks/jira.rb
37
39
  - lib/rujira/version.rb
38
40
  - sig/rujira.rbs
39
41
  homepage: https://github.com/itmagelabs/rujira