rujira 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da8ad0745459d377638ecda7132f7b24cebe44f73802cc5ac58e089ed8d93fda
4
- data.tar.gz: 0e1d0d3ce944fc903b275981abf8238868579f52f5675648fb0bcff55d87ca03
3
+ metadata.gz: 96e27cf9c81ca531b4420dd97af3d4bd9a05707667e4027e47356e28d701ffd1
4
+ data.tar.gz: 696c3a16896f5b5147efdcb8e1f4a8aa7d621af24da5b658e958cfbbbd9c50c2
5
5
  SHA512:
6
- metadata.gz: 15262ee9a7f5a69116a033f3fbb6e72889db11694ca5c15f5dde5e734455afac197679eeab8a3ae3ecfc4aa3da97d230dea4507d337b5c577f2160d207e13c6a
7
- data.tar.gz: 57bf1f91fdc28d4d77f237a0a8c2efa4ac085ca2e6493bf7a354abbc952106019119487a389d1b0b33ee4923b26e0858464f88631176095db627785b2ed5d19a
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
@@ -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
@@ -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/myself
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
@@ -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 define
18
- whoami
19
- url
20
- server_info
21
+ def parser
22
+ yield
23
+ args = @parser.order!(ARGV) {}
24
+ @parser.parse!(args)
21
25
  end
22
26
 
23
- def whoami
24
- name = __method__
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
- def url
36
- name = __method__
37
- desc 'Request server url from Jira'
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
- Rake::Task[name].clear if Rake::Task.task_defined?(name)
40
- namespace :jira do
41
- task name do
42
- puts Rujira::Configuration.url
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 server_info
48
- name = __method__
49
- desc 'Request server information from Jira'
76
+ def generate(name, &block)
77
+ fullname = "jira:#{name}"
78
+ desc "Run #{fullname}"
50
79
 
51
- Rake::Task[name].clear if Rake::Task.task_defined?(name)
80
+ Rake::Task[fullname].clear if Rake::Task.task_defined?(fullname)
52
81
  namespace :jira do
53
82
  task name do
54
- puts Rujira::Api::ServerInfo.get.data.to_json
83
+ instance_eval(&block)
55
84
  end
56
85
  end
57
86
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Rujira
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.5"
5
5
  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.4
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!