jirarest2 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +6 -0
- data/Manifest.txt +4 -1
- data/Rakefile +6 -1
- data/bin/jira_create_issue.rb +42 -18
- data/lib/jirarest2.rb +1 -1
- data/lib/madbitconfig.rb +51 -30
- data/test/data/test.json +6 -0
- data/test/data/test.nojson +4 -0
- data/test/data/test.nojson1 +4 -0
- data/test/data/ticket.json +3 -0
- data/test/test_madbitconfig.rb +12 -0
- metadata +16 -5
- metadata.gz.sig +0 -0
- data/README.md +0 -15
data.tar.gz.sig
CHANGED
Binary file
|
data/History.txt
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
=== 0.0.6 / 2012-07-18
|
2
|
+
|
3
|
+
* 1 minor enhancement:
|
4
|
+
|
5
|
+
* jira_create_issue.rb : Added the possibility to enter the issuefields ("-c") via STDIN or a file . Piping the data works only if URL,username and password are in the configfile (default: ~/.jiraconfig).
|
6
|
+
|
1
7
|
=== 0.0.5 / 2012-07-18
|
2
8
|
|
3
9
|
* 1 major enhancement:
|
data/Manifest.txt
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
GPLv3
|
3
3
|
History.txt
|
4
4
|
Manifest.txt
|
5
|
-
README.md
|
6
5
|
README.txt
|
7
6
|
Rakefile
|
8
7
|
bin/create_issue.rb
|
@@ -20,6 +19,10 @@ lib/services/issuelink.rb
|
|
20
19
|
lib/services/issuelinktype.rb
|
21
20
|
lib/services/watcher.rb
|
22
21
|
test/data/test.config.data
|
22
|
+
test/data/test.json
|
23
|
+
test/data/test.nojson
|
24
|
+
test/data/test.nojson1
|
25
|
+
test/data/ticket.json
|
23
26
|
test/test_connect.rb
|
24
27
|
test/test_credentials.rb
|
25
28
|
test/test_issue.rb
|
data/Rakefile
CHANGED
@@ -7,7 +7,7 @@ require 'hoe'
|
|
7
7
|
# Hoe.plugin :cucumberfeatures
|
8
8
|
Hoe.plugin :doofus
|
9
9
|
# Hoe.plugin :gem_prelude_sucks
|
10
|
-
|
10
|
+
Hoe.plugin :gemspec
|
11
11
|
Hoe.plugin :git
|
12
12
|
# Hoe.plugin :inline
|
13
13
|
# Hoe.plugin :manifest
|
@@ -25,6 +25,11 @@ Hoe.spec 'jirarest2' do
|
|
25
25
|
extra_deps << ['json', ">= 1.6.0"]
|
26
26
|
extra_deps << ['highline', ">= 1.1.0"]
|
27
27
|
|
28
|
+
|
29
|
+
# self.yard_title = 'Jirarest2'
|
30
|
+
# self.yard_markup = :markdown
|
31
|
+
self.yard_opts = ['--protected'] # any additional YARD options
|
32
|
+
|
28
33
|
# self.rubyforge_name = 'jirarest2x' # if different than 'jirarest2'
|
29
34
|
end
|
30
35
|
|
data/bin/jira_create_issue.rb
CHANGED
@@ -76,6 +76,10 @@ class ParseOptions
|
|
76
76
|
issueopts.content = list
|
77
77
|
end
|
78
78
|
|
79
|
+
opts.on("-C", "--content-file FILENAME", "JSON formatted file (or \"-\" for STDIN) with the contents of -c (Pipes work only if URL,username AND password are in the CONFIGFILE!)") do |contentfile|
|
80
|
+
scriptopts.contentfile = contentfile
|
81
|
+
end
|
82
|
+
|
79
83
|
opts.on("-w", "--watcher USERNAME,USERNAME", Array, "List of watchers") do |w|
|
80
84
|
issueopts.watchers = w
|
81
85
|
end
|
@@ -253,29 +257,49 @@ def show_scheme
|
|
253
257
|
exit
|
254
258
|
end
|
255
259
|
|
256
|
-
|
257
|
-
|
258
|
-
=
|
259
|
-
def prepare_new_ticket
|
260
|
-
issue = open_issue
|
261
|
-
valueNotAllowedRaised = false
|
260
|
+
# Split the content from the command line parameter "-c"
|
261
|
+
def split_content(issue)
|
262
|
+
fields = Hash.new
|
262
263
|
@issueopts.content.each { |value|
|
263
264
|
split = value.split("=")
|
264
|
-
|
265
|
-
if
|
266
|
-
|
267
|
-
split[1] = split[1].split(@scriptopts.arrayseperator)
|
268
|
-
end
|
265
|
+
if issue.fieldtype(split[0]) == "array" then # If the fieldtype is an array we want to use our arrayseparator to split the fields
|
266
|
+
if ! split[1].nil? then
|
267
|
+
split[1] = split[1].split(@scriptopts.arrayseperator)
|
269
268
|
end
|
270
|
-
issue.set_field(split[0],split[1])
|
271
|
-
rescue Jirarest2::WrongFieldnameException => e
|
272
|
-
no_issue("field",e)
|
273
|
-
rescue Jirarest2::ValueNotAllowedException => e
|
274
|
-
puts "Value #{split[1]} not allowed for field #{split[0]}."
|
275
|
-
puts "Please use one of: \"" + e.message.join("\", \"") + "\""
|
276
|
-
valueNotAllowedRaised = true
|
277
269
|
end
|
270
|
+
fields[split[0]] = split[1]
|
278
271
|
}
|
272
|
+
return fields
|
273
|
+
end
|
274
|
+
|
275
|
+
# Prepare a new ticket. It will not be persisted yet.
|
276
|
+
def prepare_new_ticket
|
277
|
+
issue = open_issue
|
278
|
+
begin
|
279
|
+
if @scriptopts.contentfile then
|
280
|
+
#Input from file or STDIN
|
281
|
+
puts "Your Input now"
|
282
|
+
fields = MadbitConfig::read_configfile(@scriptopts.contentfile)
|
283
|
+
else
|
284
|
+
#Input from the command line
|
285
|
+
fields = split_content(issue)
|
286
|
+
end
|
287
|
+
valueNotAllowedRaised = false
|
288
|
+
fields.each { |name,value|
|
289
|
+
issue.set_field(name,value)
|
290
|
+
}
|
291
|
+
rescue JSON::ParserError => e
|
292
|
+
raise JSON::ParserError, e # Maybe I want to make this nice sometimes
|
293
|
+
rescue Jirarest2::WrongFieldnameException => e
|
294
|
+
no_issue("field",e)
|
295
|
+
rescue Jirarest2::ValueNotAllowedException => e
|
296
|
+
puts "Value #{split[1]} not allowed for field #{split[0]}."
|
297
|
+
puts "Please use one of: \"" + e.message.join("\", \"") + "\""
|
298
|
+
valueNotAllowedRaised = true
|
299
|
+
end
|
300
|
+
=begin
|
301
|
+
}
|
302
|
+
=end
|
279
303
|
if valueNotAllowedRaised then
|
280
304
|
raise Jirarest2::ValueNotAllowedException
|
281
305
|
end
|
data/lib/jirarest2.rb
CHANGED
data/lib/madbitconfig.rb
CHANGED
@@ -18,6 +18,7 @@
|
|
18
18
|
# Module to handle configuration files
|
19
19
|
module MadbitConfig
|
20
20
|
|
21
|
+
require "json"
|
21
22
|
|
22
23
|
# Special exception to make the point why we threw it around
|
23
24
|
class FileExistsException < IOError ; end
|
@@ -25,43 +26,63 @@ module MadbitConfig
|
|
25
26
|
|
26
27
|
# Inspired by http://www.erickcantwell.com/2011/01/simple-configuration-file-reading-with-ruby/
|
27
28
|
|
28
|
-
# reads a config-file and returns a hash
|
29
|
-
#
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
29
|
+
# reads a config-file and returns a hash
|
30
|
+
# The config file can either contain key = value pairs or JSON data
|
31
|
+
# JSON and simple "key = value\n" lines work
|
32
|
+
# TODO make it work with "key = [value,value]\n" or even "key = value1 \n value2 \n ..."
|
33
|
+
# @param [String] configfile
|
34
|
+
# @param [Boolean] whitespace Keep whitespace characters?
|
35
|
+
# @return [Hash] Hash configparameters
|
36
|
+
def self.read_configfile(config_file,whitespace = false)
|
37
|
+
if whitespace then
|
38
|
+
regexp = Regexp.new(/"|\[|\]/)
|
39
|
+
else
|
40
|
+
regexp = Regexp.new(/\s+|"|\[|\]/)
|
35
41
|
end
|
36
42
|
|
37
|
-
regexp = Regexp.new(/\s+|"|\[|\]/)
|
38
|
-
|
39
43
|
temp = Array.new
|
40
44
|
vars = Hash.new
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
temp.collect! { |val|
|
52
|
-
val.gsub(regexp, "")
|
53
|
-
}
|
54
|
-
vars[temp[0]] = temp[1]
|
45
|
+
file = String.new
|
46
|
+
|
47
|
+
if config_file == "-" then
|
48
|
+
# caller wants STDIN
|
49
|
+
file = ARGF.read
|
50
|
+
else
|
51
|
+
# caller wants real file
|
52
|
+
config_file = File.expand_path(config_file)
|
53
|
+
unless File.exists?(config_file) then
|
54
|
+
raise IOError, "Unable to find config file \"#{config_file}\""
|
55
55
|
end
|
56
|
-
|
56
|
+
file = IO.read(config_file)
|
57
|
+
end
|
58
|
+
if file =~ /^\s*{/ then
|
59
|
+
vars = JSON.parse(file)
|
60
|
+
else
|
61
|
+
file.each_line { |line|
|
62
|
+
if line.match(/^\s*#/) # don't care about lines starting with an # (even after whitespace)
|
63
|
+
next
|
64
|
+
elsif line.match(/^\s*$/) # no text, no content
|
65
|
+
next
|
66
|
+
else
|
67
|
+
# Right now I don't know what to use scan for. It will escape " nice enough. But once that is excaped the regexp doesn't work any longer.
|
68
|
+
temp[0],temp[1] = line.to_s.scan(/^.*$/).to_s.split("=")
|
69
|
+
#temp[0],temp[1] = line.to_s.split("=")
|
70
|
+
temp.collect! { |val|
|
71
|
+
val.gsub(regexp, "")
|
72
|
+
}
|
73
|
+
vars[temp[0]] = temp[1]
|
74
|
+
end
|
75
|
+
}
|
76
|
+
end # JSON or not?
|
77
|
+
|
57
78
|
return vars
|
58
79
|
end # read.configfile
|
59
|
-
|
60
|
-
|
61
|
-
# write a configfile
|
62
|
-
# @param [String] config_file Name (and path) of the config file
|
63
|
-
# @param [Hash] configoptions Hash of "option" => "value" pairs
|
64
|
-
# @param [Symbol] save Determines if an existing file is to be kept. :force replaces an existing file
|
80
|
+
|
81
|
+
|
82
|
+
# write a configfile
|
83
|
+
# @param [String] config_file Name (and path) of the config file
|
84
|
+
# @param [Hash] configoptions Hash of "option" => "value" pairs
|
85
|
+
# @param [Symbol] save Determines if an existing file is to be kept. :force replaces an existing file
|
65
86
|
def self.write_configfile(config_file, configoptions, save = :noforce)
|
66
87
|
config_file = File.expand_path(config_file) # Be save
|
67
88
|
|
data/test/data/test.json
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
{
|
2
|
+
"Summary" : "This is a summary. We prefer to use it, as is",
|
3
|
+
"Description" : " Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor \n incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud \n exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute \n irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla \n pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia\n deserunt mollit anim id est laborum.\n",
|
4
|
+
"Many Values" : ["One","Two","Three","Four"]
|
5
|
+
|
6
|
+
}
|
@@ -0,0 +1,4 @@
|
|
1
|
+
"Summary" = "This is a summary. We prefer to use it, as is"
|
2
|
+
"Description" = " Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor \n incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud \n exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute \n irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla \n pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia\n deserunt mollit anim id est laborum.\n"
|
3
|
+
"Many Values" = ["One", "Two", "Three", "Four"]
|
4
|
+
|
@@ -0,0 +1,4 @@
|
|
1
|
+
Summary = This is a summary. We prefer to use it, as is
|
2
|
+
Description = Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor \n incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud \n exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute \n irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla \n pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia\n deserunt mollit anim id est laborum.\n
|
3
|
+
Many Values = [One, Two, Three, Four]
|
4
|
+
|
data/test/test_madbitconfig.rb
CHANGED
@@ -29,5 +29,17 @@ class TestConfig < MiniTest::Unit::TestCase
|
|
29
29
|
|
30
30
|
end
|
31
31
|
|
32
|
+
def test_readjfile
|
33
|
+
testdir = File.dirname($0)
|
34
|
+
testfile = testdir + "/test/data/test.json"
|
35
|
+
assert_equal ["One", "Two", "Three", "Four"],MadbitConfig::read_configfile(testfile)["Many Values"]
|
36
|
+
testfile = testdir + "/test/data/test.nojson"
|
37
|
+
assert_equal " \\This is a summary. We prefer to use it, as is\\", MadbitConfig::read_configfile(testfile, true)["\\Summary\\ "] # Not really what we want but didn't know how to fix now
|
38
|
+
testfile = testdir + "/test/data/test.nojson1"
|
39
|
+
assert_equal " One, Two, Three, Four",MadbitConfig::read_configfile(testfile, true)["Many Values "]
|
40
|
+
|
41
|
+
# I dont' know how to run this test in a automated setup. How do we feed one of the files above to STDIN so the testscript gets the data?
|
42
|
+
# pp MadbitConfig::read_configfile("-")
|
43
|
+
end
|
32
44
|
|
33
45
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jirarest2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -116,7 +116,14 @@ dependencies:
|
|
116
116
|
- - ! '>='
|
117
117
|
- !ruby/object:Gem::Version
|
118
118
|
version: 2.9.4
|
119
|
-
description:
|
119
|
+
description: ! "jirarest2 is yet another implementation of the JIRA(tm) REST-API[https://developer.atlassian.com/display/JIRADEV/JIRA+Remote+API+Reference]
|
120
|
+
. This one for Ruby1.9.1\n\nIt is intended to be called within the shell to create
|
121
|
+
and verify JIRA(tm) issues fast without a browser. There was no particular need
|
122
|
+
for perfomance at the time of writing.\n\nThis implementation is still a for cry
|
123
|
+
from others like http://rubygems.org/gems/jira-ruby which required oauth authentification.
|
124
|
+
\n\nThe script allows you to create new issues with watchers and link those to existing
|
125
|
+
issues\n\n *Use it at your own risk. Most of the API features are not implemented.*\n\n
|
126
|
+
*Ruby1.9.1 is needed. Ruby1.8 doesn't work!*"
|
120
127
|
email:
|
121
128
|
- cebit-jirarest@gunnet.de
|
122
129
|
executables:
|
@@ -132,7 +139,6 @@ files:
|
|
132
139
|
- GPLv3
|
133
140
|
- History.txt
|
134
141
|
- Manifest.txt
|
135
|
-
- README.md
|
136
142
|
- README.txt
|
137
143
|
- Rakefile
|
138
144
|
- bin/create_issue.rb
|
@@ -150,6 +156,10 @@ files:
|
|
150
156
|
- lib/services/issuelinktype.rb
|
151
157
|
- lib/services/watcher.rb
|
152
158
|
- test/data/test.config.data
|
159
|
+
- test/data/test.json
|
160
|
+
- test/data/test.nojson
|
161
|
+
- test/data/test.nojson1
|
162
|
+
- test/data/ticket.json
|
153
163
|
- test/test_connect.rb
|
154
164
|
- test/test_credentials.rb
|
155
165
|
- test/test_issue.rb
|
@@ -159,10 +169,11 @@ files:
|
|
159
169
|
- test/test_result.rb
|
160
170
|
- test/test_watcher.rb
|
161
171
|
- .gemtest
|
162
|
-
homepage:
|
172
|
+
homepage: https://github.com/cybit/jirarest2#readme
|
163
173
|
licenses: []
|
164
174
|
post_install_message:
|
165
175
|
rdoc_options:
|
176
|
+
- --protected
|
166
177
|
- --title
|
167
178
|
- Jirarest2 Documentation
|
168
179
|
- --quiet
|
@@ -185,7 +196,7 @@ rubyforge_project: jirarest2
|
|
185
196
|
rubygems_version: 1.8.24
|
186
197
|
signing_key:
|
187
198
|
specification_version: 3
|
188
|
-
summary:
|
199
|
+
summary: jirarest2 is yet another implementation of the JIRA(tm) REST-API[https://developer.atlassian.com/display/JIRADEV/JIRA+Remote+API+Reference]
|
189
200
|
test_files:
|
190
201
|
- test/test_madbitconfig.rb
|
191
202
|
- test/test_connect.rb
|
metadata.gz.sig
CHANGED
Binary file
|
data/README.md
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
jirarest2
|
2
|
-
=========
|
3
|
-
|
4
|
-
Another ruby gem for the REST2 interface of JIRA(tm)
|
5
|
-
|
6
|
-
This is still a very early alpha state and a lot of features are not yet implemented. Classes and their work might undergo major changes. (especially "Issue")
|
7
|
-
|
8
|
-
What works?
|
9
|
-
|
10
|
-
* creation of issues
|
11
|
-
* add watchers to the issues
|
12
|
-
* link new issues to issues that are already there
|
13
|
-
* ruby script (create-issue.rb) that enables you to do this from the command line
|
14
|
-
|
15
|
-
Ruby1.9.1 is needed! Ruby1.8 will fail.
|