create_ticket 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +6 -0
- data/.rubocop_todo.yml +3 -14
- data/README.md +2 -0
- data/lib/create_ticket/cli.rb +32 -10
- data/lib/create_ticket/version.rb +1 -1
- data/lib/create_ticket.rb +31 -17
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0b70a06a98627c5931b90389ac2b5651ffd6a9e
|
4
|
+
data.tar.gz: f5b8363d2791be53cce0449130c6ae2169670102
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0c2c94c5960be16abc3beb7d2d4fe56f55127547bbb760067e3b9b1cbf26d27f4bb0953c4976c23e77d606f6427e471ed71c677dbced9790b8c1a4e80469b34
|
7
|
+
data.tar.gz: a5404444e86549be7a2239eac9bb95e7abd3fe500774351bf68d7da726866f1ca60ab0c668692a409b7f02c701d565d9dce4bb67856f72e8964b660be46f69a2
|
data/.rubocop.yml
CHANGED
data/.rubocop_todo.yml
CHANGED
@@ -1,24 +1,13 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2017-
|
3
|
+
# on 2017-10-05 11:18:01 -0500 using RuboCop version 0.50.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
# Offense count:
|
9
|
+
# Offense count: 1
|
10
10
|
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
11
11
|
# URISchemes: http, https
|
12
12
|
Metrics/LineLength:
|
13
|
-
Max:
|
14
|
-
|
15
|
-
# Offense count: 1
|
16
|
-
Style/Documentation:
|
17
|
-
Enabled: false
|
18
|
-
|
19
|
-
# Offense count: 1
|
20
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
21
|
-
# SupportedStyles: module_function, extend_self
|
22
|
-
Style/ModuleFunction:
|
23
|
-
Exclude:
|
24
|
-
- 'lib/create_ticket.rb'
|
13
|
+
Max: 95
|
data/README.md
CHANGED
data/lib/create_ticket/cli.rb
CHANGED
@@ -4,19 +4,41 @@ require 'create_ticket'
|
|
4
4
|
|
5
5
|
class CreateTicket
|
6
6
|
class CLI
|
7
|
-
def
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
def jira_url
|
8
|
+
ENV.fetch('JIRA_URL')
|
9
|
+
end
|
10
|
+
|
11
|
+
def project
|
12
|
+
ENV.fetch('JIRA_PROJECT')
|
13
|
+
end
|
14
|
+
|
15
|
+
def jira_token
|
16
|
+
ENV.fetch('JIRA_TOKEN')
|
17
|
+
end
|
18
|
+
|
19
|
+
def template_filename
|
20
|
+
ENV.fetch('TEMPLATE_FILENAME')
|
21
|
+
end
|
22
|
+
|
23
|
+
def assignee
|
24
|
+
ENV.fetch('JIRA_ASSIGNEE')
|
25
|
+
end
|
26
|
+
|
27
|
+
def issue_type
|
28
|
+
ENV.fetch('JIRA_ISSUE_TYPE')
|
29
|
+
end
|
30
|
+
|
31
|
+
def custom_fields
|
32
|
+
ENV.select { |k, _| k.start_with? 'JIRA_CUSTOMFIELD' }.to_a
|
33
|
+
.map { |k, v| [k.downcase.sub(/^jira_/, ''), v] }.to_h
|
34
|
+
end
|
35
|
+
|
36
|
+
def duedate
|
37
|
+
ENV['JIRA_DUEDATE']
|
16
38
|
end
|
17
39
|
|
18
40
|
def run!
|
19
|
-
CreateTicket.new(
|
41
|
+
CreateTicket.new(self).create_ticket!
|
20
42
|
end
|
21
43
|
end
|
22
44
|
end
|
data/lib/create_ticket.rb
CHANGED
@@ -7,17 +7,19 @@ require 'json'
|
|
7
7
|
require 'erb'
|
8
8
|
|
9
9
|
class CreateTicket
|
10
|
-
|
10
|
+
extend Forwardable
|
11
|
+
|
12
|
+
attr_reader :conf
|
11
13
|
|
12
14
|
def initialize(conf)
|
13
|
-
|
14
|
-
@
|
15
|
-
@jira_token = conf.fetch(:jira_token)
|
16
|
-
@template_filename = conf.fetch(:template_filename)
|
17
|
-
@assignee = conf.fetch(:assignee)
|
18
|
-
@issue_type = conf.fetch(:issue_type)
|
15
|
+
conf = OpenStruct.new(conf) if conf.is_a? Hash
|
16
|
+
@conf = conf
|
19
17
|
end
|
20
18
|
|
19
|
+
def_delegators :conf,
|
20
|
+
:jira_url, :project, :jira_token, :template_filename,
|
21
|
+
:assignee, :issue_type, :duedate, :custom_fields
|
22
|
+
|
21
23
|
def template
|
22
24
|
@template ||= File.open(template_filename).read
|
23
25
|
end
|
@@ -35,20 +37,32 @@ class CreateTicket
|
|
35
37
|
req.url '/rest/api/2/issue'
|
36
38
|
req.body = jira_ticket_json
|
37
39
|
end
|
38
|
-
|
39
|
-
|
40
|
+
begin
|
41
|
+
key = JSON.parse(response.body).fetch('key')
|
42
|
+
puts "#{jira_url}/browse/#{key}"
|
43
|
+
rescue KeyError, JSON::ParserError
|
44
|
+
puts 'Could not create a JIRA ticket.'
|
45
|
+
puts 'Response from server:'
|
46
|
+
puts response.body
|
47
|
+
exit 1
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def fields
|
52
|
+
{
|
53
|
+
project: { key: project },
|
54
|
+
issuetype: { name: issue_type },
|
55
|
+
summary: summary,
|
56
|
+
description: description,
|
57
|
+
assignee: { name: assignee },
|
58
|
+
reporter: { name: assignee },
|
59
|
+
duedate: duedate
|
60
|
+
}.merge(custom_fields)
|
40
61
|
end
|
41
62
|
|
42
63
|
def jira_ticket_json
|
43
64
|
{
|
44
|
-
fields:
|
45
|
-
project: { key: project },
|
46
|
-
issuetype: { name: issue_type },
|
47
|
-
summary: summary,
|
48
|
-
description: description,
|
49
|
-
assignee: { name: assignee },
|
50
|
-
reporter: { name: assignee }
|
51
|
-
}
|
65
|
+
fields: fields
|
52
66
|
}.to_json
|
53
67
|
end
|
54
68
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: create_ticket
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyle Marek-Spartz
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
153
|
version: '0'
|
154
154
|
requirements: []
|
155
155
|
rubyforge_project:
|
156
|
-
rubygems_version: 2.
|
156
|
+
rubygems_version: 2.6.13
|
157
157
|
signing_key:
|
158
158
|
specification_version: 4
|
159
159
|
summary: Create JIRA tickets
|