jirarest2 0.0.4 → 0.0.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.
- data.tar.gz.sig +0 -0
- data/History.txt +19 -0
- data/Manifest.txt +4 -2
- data/README.txt +1 -1
- data/Rakefile +1 -0
- data/bin/create_issue.rb +3 -275
- data/bin/jira_create_issue.rb +366 -0
- data/lib/connect.rb +21 -24
- data/lib/credentials.rb +7 -12
- data/lib/exceptions.rb +1 -3
- data/lib/issue.rb +46 -58
- data/lib/jirarest2.rb +1 -1
- data/lib/jirarest2/result.rb +34 -30
- data/lib/madbitconfig.rb +82 -0
- data/lib/services.rb +12 -17
- data/lib/services/issuelink.rb +21 -15
- data/lib/services/issuelinktype.rb +17 -17
- data/lib/services/watcher.rb +15 -15
- data/test/data/test.config.data +3 -0
- data/test/test_madbitconfig.rb +33 -0
- metadata +30 -16
- metadata.gz.sig +0 -0
- data/lib/config.rb +0 -55
- data/lib/issuelink.rb +0 -74
data/lib/services.rb
CHANGED
@@ -15,39 +15,34 @@
|
|
15
15
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
16
|
#
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
Trying to keep the services together in one class so I don't have to write so much
|
21
|
-
=end
|
18
|
+
require_relative "connect"
|
19
|
+
|
20
|
+
# Trying to keep the services together in one class so I don't have to write so much
|
22
21
|
class Services
|
23
22
|
|
24
|
-
|
25
|
-
We expect to receive an existing
|
26
|
-
:connection
|
27
|
-
=end
|
23
|
+
# @param [Connection]
|
28
24
|
def initialize(connection)
|
29
25
|
@connection = connection
|
30
26
|
# to be set in each subclass;
|
31
27
|
# @uritail = ""
|
32
28
|
end
|
33
29
|
|
34
|
-
|
35
|
-
|
36
|
-
=end
|
30
|
+
# Send the GET request
|
31
|
+
# @param [Hash] data to be sent to Connection.execute
|
37
32
|
def get(data = "")
|
38
33
|
return @connection.execute("Get",@uritail,data).result
|
39
34
|
end
|
40
35
|
|
41
|
-
|
42
|
-
Send the POST request
|
43
|
-
|
36
|
+
|
37
|
+
# Send the POST request
|
38
|
+
# @param [Hash] data to be sent to Connection.execute
|
44
39
|
def post(data = "")
|
45
40
|
return @connection.execute("Post",@uritail,data)
|
46
41
|
end
|
47
42
|
|
48
|
-
|
49
|
-
Send the DELETE request
|
50
|
-
|
43
|
+
|
44
|
+
# Send the DELETE request
|
45
|
+
# @param [Hash] data to be sent to Connection.execute
|
51
46
|
def delete(data = "")
|
52
47
|
return @connection.execute("Delete",@uritail,data)
|
53
48
|
end
|
data/lib/services/issuelink.rb
CHANGED
@@ -21,10 +21,8 @@ require "issue"
|
|
21
21
|
require "services/issuelinktype"
|
22
22
|
require "exceptions"
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
No real getter as of yet (I just didn't need it)
|
27
|
-
=end
|
24
|
+
# This class is responsible for the Linking of Issues
|
25
|
+
# No real getter as of yet (I just didn't need it)
|
28
26
|
class IssueLink < Services
|
29
27
|
|
30
28
|
def initialize(connection)
|
@@ -33,9 +31,10 @@ class IssueLink < Services
|
|
33
31
|
end
|
34
32
|
|
35
33
|
private
|
36
|
-
|
37
|
-
return the issuekey
|
38
|
-
|
34
|
+
|
35
|
+
# return the issuekey regardless whether we got an Issue or just the Key
|
36
|
+
# @param [String, Issue] issue
|
37
|
+
# @return [String]
|
39
38
|
def key(issue)
|
40
39
|
if issue.instance_of?(Issue) then
|
41
40
|
return issue.issuekey
|
@@ -45,10 +44,14 @@ class IssueLink < Services
|
|
45
44
|
end
|
46
45
|
|
47
46
|
public
|
48
|
-
|
49
|
-
Links two issues
|
50
|
-
Right now the visibility feature for comments is not supported
|
51
|
-
|
47
|
+
|
48
|
+
# Links two issues
|
49
|
+
# Right now the visibility feature for comments is not supported
|
50
|
+
# @param [String, Issue] thisIssue Issue to connect from
|
51
|
+
# @param [String, Issue] remoteIssue Issue to connect to
|
52
|
+
# @param [String] type Link type
|
53
|
+
# @param [String] comment If a comment should be set while linking
|
54
|
+
# @return [Jirarest2::Result] The result of the linking
|
52
55
|
def link_issue(thisIssue,remoteIssue,type,comment = nil)
|
53
56
|
inwardIssue = key(thisIssue)
|
54
57
|
outwardIssue = key(remoteIssue)
|
@@ -80,9 +83,12 @@ class IssueLink < Services
|
|
80
83
|
return post(json)
|
81
84
|
end
|
82
85
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
+
# does the linking ig you don't want to bother with the exact result
|
87
|
+
# @param [String, Issue] thisIssue Issue to connect from
|
88
|
+
# @param [String, Issue] remoteIssue Issue to connect to
|
89
|
+
# @param [String] type Link type
|
90
|
+
# @param [String] comment If a comment should be set while linking
|
91
|
+
# @return [Boolean] Only true if successfully linked false if something happened. Elseway exactly as link_issue.
|
86
92
|
def link(thisIssue,remoteIssue,type,comment = nil)
|
87
93
|
if link_issue(thisIssue,remoteIssue,type,comment).code == "201" then
|
88
94
|
return true
|
@@ -90,5 +96,5 @@ class IssueLink < Services
|
|
90
96
|
return false
|
91
97
|
end
|
92
98
|
end
|
93
|
-
|
99
|
+
|
94
100
|
end # class
|
@@ -17,15 +17,13 @@
|
|
17
17
|
|
18
18
|
require "services"
|
19
19
|
|
20
|
-
|
21
|
-
An IssueLinkType Object represents one or all IssueLinkTypes
|
22
|
-
=end
|
20
|
+
# An IssueLinkType Object represents one or all IssueLinkTypes
|
23
21
|
class IssueLinkType < Services
|
24
22
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
|
24
|
+
# @param [Connection] connection
|
25
|
+
# @param [String] data issueLinkType ID
|
26
|
+
# @return [Jirarest2::Result]
|
29
27
|
def initialize(connection,data = "")
|
30
28
|
if data == "" then
|
31
29
|
@uritail = "issueLinkType"
|
@@ -37,9 +35,11 @@ class IssueLinkType < Services
|
|
37
35
|
end
|
38
36
|
|
39
37
|
private
|
40
|
-
|
41
|
-
do the search for each block
|
42
|
-
|
38
|
+
|
39
|
+
# do the search for each block
|
40
|
+
# @param [Hash] hash One LinkIssueType in a hash representation
|
41
|
+
# @param [String] uiname the way the linktype is shown in the browser
|
42
|
+
# @return [Array] Actual name oft the LinkIssueType
|
43
43
|
def name_block_search(hash,uiname)
|
44
44
|
name = nil
|
45
45
|
direction = nil
|
@@ -58,10 +58,10 @@ private
|
|
58
58
|
|
59
59
|
|
60
60
|
public
|
61
|
-
|
62
|
-
Get the internal name and direction instead of the one in the UI.
|
63
|
-
|
64
|
-
|
61
|
+
|
62
|
+
#Get the internal name and direction instead of the one in the UI.
|
63
|
+
# @param [String] uiname the way the linktype is shown in the browser
|
64
|
+
# @return [Array, nil] Array with the name and the direction ("inward" or "outward") if successfull , nil if not
|
65
65
|
def name(uiname)
|
66
66
|
if @all["issueLinkTypes"].instance_of?(Array) then
|
67
67
|
@all["issueLinkTypes"].each{ |hash|
|
@@ -74,9 +74,9 @@ public
|
|
74
74
|
return nil # Nothing found don't want to return @all
|
75
75
|
end # name
|
76
76
|
|
77
|
-
|
78
|
-
|
79
|
-
|
77
|
+
# Is the name realy the internal name we need to use?
|
78
|
+
# @param [String] test String to test agains the names of IssueLinkTypes
|
79
|
+
# @return [Boolean]
|
80
80
|
def internal_name?(test)
|
81
81
|
if @all["issueLinkTypes"].instance_of?(Array) then
|
82
82
|
@all["issueLinkTypes"].each{ |hash|
|
data/lib/services/watcher.rb
CHANGED
@@ -18,22 +18,20 @@
|
|
18
18
|
require "connect"
|
19
19
|
require "services"
|
20
20
|
|
21
|
-
|
22
|
-
Watchers do have their own calling
|
23
|
-
=end
|
21
|
+
# Watchers do have their own calling
|
24
22
|
class Watcher < Services
|
25
23
|
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
# Set our uritail
|
25
|
+
# @param [Connection] connection
|
26
|
+
# @param [String] issueid The id or key of the issue in question
|
29
27
|
def initialize(connection, issueid)
|
30
28
|
@uritail = "issue/#{issueid}/watchers"
|
31
29
|
super(connection)
|
32
30
|
end
|
33
31
|
|
34
|
-
|
35
|
-
Return all the watchers of the issue
|
36
|
-
|
32
|
+
|
33
|
+
# Return all the watchers of the issue
|
34
|
+
# @return [String] Usernames of watching users
|
37
35
|
def get_watchers
|
38
36
|
ret = get
|
39
37
|
watchers = Array.new
|
@@ -43,9 +41,10 @@ class Watcher < Services
|
|
43
41
|
return watchers
|
44
42
|
end
|
45
43
|
|
46
|
-
|
47
|
-
Adds a new watcher for the issue
|
48
|
-
|
44
|
+
|
45
|
+
# Adds a new watcher for the issue
|
46
|
+
# @param [String] username Username of the new watcher
|
47
|
+
# @return [Boolean] Success
|
49
48
|
def add_watcher(username)
|
50
49
|
ret = post(username)
|
51
50
|
case ret.code
|
@@ -56,9 +55,10 @@ class Watcher < Services
|
|
56
55
|
end
|
57
56
|
end
|
58
57
|
|
59
|
-
|
60
|
-
|
61
|
-
|
58
|
+
|
59
|
+
# remove one watcher from the issue
|
60
|
+
# @param [String] username Username of the watcher to delete
|
61
|
+
# @return [Boolean] Success
|
62
62
|
def remove_watcher(username)
|
63
63
|
query = {"username" => username}
|
64
64
|
ret = delete(query)
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "madbitconfig"
|
3
|
+
require "pp"
|
4
|
+
|
5
|
+
class TestConfig < MiniTest::Unit::TestCase
|
6
|
+
|
7
|
+
def test_read_configfile
|
8
|
+
testdir = File.dirname($0)
|
9
|
+
testfile = testdir + "/test/data/test.config.data"
|
10
|
+
# Should work
|
11
|
+
testdata = {"username"=>"UsErNaMe", "password"=>"pAsSw0rD;", "URL"=>"https://jira.localhost:2990/jira"}
|
12
|
+
assert_equal testdata,MadbitConfig::read_configfile(testfile)
|
13
|
+
# And fail
|
14
|
+
assert_raises(IOError) { MadbitConfig::read_configfile(testfile+"blah") }
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_write_configfile
|
18
|
+
testdir = File.dirname($0)
|
19
|
+
testfile = testdir + "/test/data/test.config.tmp"
|
20
|
+
#make sure
|
21
|
+
File.delete(testfile) if File.exists?(testfile)
|
22
|
+
#test
|
23
|
+
confighash = {"Param1" => "Value1", "Parameter 2" => "Value 2", "password" => " pAsSw0rD;21"}
|
24
|
+
assert_equal confighash,MadbitConfig::write_configfile(testfile,confighash)
|
25
|
+
assert_raises(MadbitConfig::FileExistsException) { MadbitConfig::write_configfile(testfile,confighash) }
|
26
|
+
assert_equal confighash,MadbitConfig::write_configfile(testfile,confighash,:force)
|
27
|
+
# cleanup
|
28
|
+
File.delete(testfile) if File.exists?(testfile)
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
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.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -50,7 +50,7 @@ cert_chain:
|
|
50
50
|
-----END CERTIFICATE-----
|
51
51
|
|
52
52
|
'
|
53
|
-
date: 2012-07-
|
53
|
+
date: 2012-07-18 00:00:00.000000000 Z
|
54
54
|
dependencies:
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: json
|
@@ -84,6 +84,22 @@ dependencies:
|
|
84
84
|
- - ! '>='
|
85
85
|
- !ruby/object:Gem::Version
|
86
86
|
version: 1.1.0
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: hoe-yard
|
89
|
+
requirement: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 0.1.2
|
95
|
+
type: :development
|
96
|
+
prerelease: false
|
97
|
+
version_requirements: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 0.1.2
|
87
103
|
- !ruby/object:Gem::Dependency
|
88
104
|
name: hoe
|
89
105
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,18 +116,12 @@ dependencies:
|
|
100
116
|
- - ! '>='
|
101
117
|
- !ruby/object:Gem::Version
|
102
118
|
version: 2.9.4
|
103
|
-
description:
|
104
|
-
. This one for Ruby1.9.1\n\nIt is intended to be called within the shell to create
|
105
|
-
and verify JIRA(tm) issues fast without a browser. There was no particular need
|
106
|
-
for perfomance at the time of writing.\n\nThis implementation is still a for cry
|
107
|
-
from others like http://rubygems.org/gems/jira-ruby which required oauth authentification.
|
108
|
-
\n\nThe script allows you to create new issues with watchers and link those to existing
|
109
|
-
issues\n\n *Use it at your own risk. Most of the API features are not implemented.*\n\n
|
110
|
-
*Ruby1.9.1 is needed. Ruby1.8 doesn't work!*"
|
119
|
+
description: ''
|
111
120
|
email:
|
112
121
|
- cebit-jirarest@gunnet.de
|
113
122
|
executables:
|
114
123
|
- create_issue.rb
|
124
|
+
- jira_create_issue.rb
|
115
125
|
extensions: []
|
116
126
|
extra_rdoc_files:
|
117
127
|
- History.txt
|
@@ -126,33 +136,36 @@ files:
|
|
126
136
|
- README.txt
|
127
137
|
- Rakefile
|
128
138
|
- bin/create_issue.rb
|
139
|
+
- bin/jira_create_issue.rb
|
129
140
|
- copyright
|
130
|
-
- lib/config.rb
|
131
141
|
- lib/connect.rb
|
132
142
|
- lib/credentials.rb
|
133
143
|
- lib/exceptions.rb
|
134
144
|
- lib/issue.rb
|
135
|
-
- lib/issuelink.rb
|
136
145
|
- lib/jirarest2.rb
|
137
146
|
- lib/jirarest2/result.rb
|
147
|
+
- lib/madbitconfig.rb
|
138
148
|
- lib/services.rb
|
139
149
|
- lib/services/issuelink.rb
|
140
150
|
- lib/services/issuelinktype.rb
|
141
151
|
- lib/services/watcher.rb
|
152
|
+
- test/data/test.config.data
|
142
153
|
- test/test_connect.rb
|
143
154
|
- test/test_credentials.rb
|
144
155
|
- test/test_issue.rb
|
145
156
|
- test/test_issuelink.rb
|
146
157
|
- test/test_issuelinktype.rb
|
158
|
+
- test/test_madbitconfig.rb
|
147
159
|
- test/test_result.rb
|
148
160
|
- test/test_watcher.rb
|
149
161
|
- .gemtest
|
150
|
-
homepage:
|
162
|
+
homepage:
|
151
163
|
licenses: []
|
152
164
|
post_install_message:
|
153
165
|
rdoc_options:
|
154
|
-
- --
|
155
|
-
-
|
166
|
+
- --title
|
167
|
+
- Jirarest2 Documentation
|
168
|
+
- --quiet
|
156
169
|
require_paths:
|
157
170
|
- lib
|
158
171
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -172,8 +185,9 @@ rubyforge_project: jirarest2
|
|
172
185
|
rubygems_version: 1.8.24
|
173
186
|
signing_key:
|
174
187
|
specification_version: 3
|
175
|
-
summary:
|
188
|
+
summary: ''
|
176
189
|
test_files:
|
190
|
+
- test/test_madbitconfig.rb
|
177
191
|
- test/test_connect.rb
|
178
192
|
- test/test_issuelinktype.rb
|
179
193
|
- test/test_credentials.rb
|
metadata.gz.sig
CHANGED
Binary file
|
data/lib/config.rb
DELETED
@@ -1,55 +0,0 @@
|
|
1
|
-
# Module to handle configuration files
|
2
|
-
# Copyright (C) 2012 Cyril Bitterich
|
3
|
-
#
|
4
|
-
# This program is free software: you can redistribute it and/or modify
|
5
|
-
# it under the terms of the GNU General Public License as published by
|
6
|
-
# the Free Software Foundation, either version 3 of the License, or
|
7
|
-
# (at your option) any later version.
|
8
|
-
#
|
9
|
-
# This program is distributed in the hope that it will be useful,
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
-
# GNU General Public License for more details.
|
13
|
-
#
|
14
|
-
# You should have received a copy of the GNU General Public License
|
15
|
-
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16
|
-
#
|
17
|
-
|
18
|
-
=begin
|
19
|
-
Module to handle configuration files
|
20
|
-
=end
|
21
|
-
module Config
|
22
|
-
=begin
|
23
|
-
Inspired by http://www.erickcantwell.com/2011/01/simple-configuration-file-reading-with-ruby/
|
24
|
-
reads a config-file and returns a hash
|
25
|
-
=end
|
26
|
-
def self.read_configfile(config_file)
|
27
|
-
config_file = File.expand_path(config_file)
|
28
|
-
|
29
|
-
unless File.exists?(config_file) then
|
30
|
-
raise "Unable to find config file"
|
31
|
-
end
|
32
|
-
|
33
|
-
regexp = Regexp.new(/\s+|"|\[|\]/)
|
34
|
-
|
35
|
-
temp = Array.new
|
36
|
-
vars = Hash.new
|
37
|
-
|
38
|
-
IO.foreach(config_file) { |line|
|
39
|
-
if line.match(/^\s*#/) # don't care about lines starting with an # (even after whitespace)
|
40
|
-
next
|
41
|
-
elsif line.match(/^\s*$/) # no text, no content
|
42
|
-
next
|
43
|
-
else
|
44
|
-
# 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.
|
45
|
-
# temp[0],temp[1] = line.to_s.scan(/^.*$/).to_s.split("=")
|
46
|
-
temp[0],temp[1] = line.to_s.split("=")
|
47
|
-
temp.collect! { |val|
|
48
|
-
val.gsub(regexp, "")
|
49
|
-
}
|
50
|
-
vars[temp[0]] = temp[1]
|
51
|
-
end
|
52
|
-
}
|
53
|
-
return vars
|
54
|
-
end
|
55
|
-
end
|