redmine-ticket-client 0.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest.txt +2 -0
- data/README.txt +6 -1
- data/examples/issue_status.rb +19 -0
- data/examples/last_tickets.rb +29 -0
- data/examples/post_ticket.rb +10 -6
- data/lib/redmine-ticket/client.rb +22 -2
- metadata +4 -2
data/Manifest.txt
CHANGED
data/README.txt
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Display de status of a given issue
|
4
|
+
#
|
5
|
+
require File.join(File.dirname(__FILE__), '../lib/redmine-ticket/client')
|
6
|
+
|
7
|
+
params = {
|
8
|
+
:api_key => 'API KEY',
|
9
|
+
:issue_id => 10
|
10
|
+
}
|
11
|
+
|
12
|
+
RedmineTicketClient.configure do |config|
|
13
|
+
config.params = params
|
14
|
+
config.host = 'redmine.local' # the hostname your Redmine runs at
|
15
|
+
config.port = 80 # the port your Redmine runs at
|
16
|
+
config.secure = false # sends data to your server via SSL (optional.)
|
17
|
+
end
|
18
|
+
|
19
|
+
pp RedmineTicketClient.issue_status
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# Display tickets created in the last hour
|
4
|
+
#
|
5
|
+
require File.join(File.dirname(__FILE__), '../lib/redmine-ticket/client')
|
6
|
+
require 'rubygems'
|
7
|
+
require 'json'
|
8
|
+
require 'time'
|
9
|
+
|
10
|
+
|
11
|
+
params = {
|
12
|
+
:api_key => 'APIKEY',
|
13
|
+
:issue_id => 646
|
14
|
+
}
|
15
|
+
|
16
|
+
RedmineTicketClient.configure do |config|
|
17
|
+
config.params = params
|
18
|
+
config.host = 'redmine.sistemas.cti.csic.es'
|
19
|
+
config.port = 80
|
20
|
+
config.secure = false
|
21
|
+
end
|
22
|
+
|
23
|
+
JSON.parse(RedmineTicketClient.issues).each do |t|
|
24
|
+
time = Time.parse t['updated_on']
|
25
|
+
offset = Time.now - time
|
26
|
+
if (offset < 3600)
|
27
|
+
puts t['subject']
|
28
|
+
end
|
29
|
+
end
|
data/examples/post_ticket.rb
CHANGED
@@ -5,7 +5,7 @@ params = {
|
|
5
5
|
# the name of your Tracker of choice in Redmine
|
6
6
|
:tracker => 'Bug',
|
7
7
|
# the key you generated before in Redmine
|
8
|
-
:api_key => '
|
8
|
+
:api_key => 'API KEY',
|
9
9
|
# the name of a ticket category (optional.)
|
10
10
|
:category => 'Development',
|
11
11
|
|
@@ -15,16 +15,20 @@ params = {
|
|
15
15
|
# the default priority (use a number, not a name. optional.)
|
16
16
|
#:priority => 5,
|
17
17
|
|
18
|
-
:subject =>
|
19
|
-
:description => 'description text'
|
18
|
+
:subject => "Test RTS #{rand * 100}",
|
19
|
+
:description => 'description text',
|
20
|
+
:custom_fields => {
|
21
|
+
:field1 => 'bar',
|
22
|
+
:field2 => 'foo'
|
23
|
+
}
|
20
24
|
|
21
25
|
}.to_yaml
|
22
26
|
|
23
27
|
RedmineTicketClient.configure do |config|
|
24
28
|
config.params = params
|
25
|
-
config.host = '
|
26
|
-
config.port =
|
27
|
-
config.secure = false
|
29
|
+
config.host = 'redmine.local'
|
30
|
+
config.port = 80
|
31
|
+
config.secure = false
|
28
32
|
end
|
29
33
|
|
30
34
|
RedmineTicketClient.post_ticket
|
@@ -1,10 +1,12 @@
|
|
1
1
|
require 'net/http'
|
2
2
|
require 'net/https'
|
3
3
|
require 'rubygems'
|
4
|
+
require 'rest_client'
|
5
|
+
require 'pp'
|
4
6
|
|
5
7
|
module RedmineTicketClient
|
6
8
|
|
7
|
-
VERSION = '0.
|
9
|
+
VERSION = '0.2.2'
|
8
10
|
|
9
11
|
class << self
|
10
12
|
attr_accessor :host, :port, :secure, :params, :http_open_timeout, :http_read_timeout,
|
@@ -52,10 +54,27 @@ module RedmineTicketClient
|
|
52
54
|
:environment => ENV.to_hash
|
53
55
|
}
|
54
56
|
end
|
57
|
+
|
58
|
+
def default_request_params
|
59
|
+
{}.merge RedmineTicketClient.params
|
60
|
+
end
|
55
61
|
|
56
62
|
def post_ticket
|
57
63
|
Sender.new.post_to_redmine( default_ticket_options )
|
58
64
|
end
|
65
|
+
|
66
|
+
def issue_status
|
67
|
+
RestClient.post("#{protocol}://#{host}:#{port}/ticket_server/issue_status", :api_key => default_request_params[:api_key], :issue_id => default_request_params[:issue_id])
|
68
|
+
end
|
69
|
+
def issues
|
70
|
+
RestClient.post("#{protocol}://#{host}:#{port}/ticket_server/issues", :api_key => default_request_params[:api_key], :issue_id => default_request_params[:issue_id])
|
71
|
+
end
|
72
|
+
def projects
|
73
|
+
RestClient.post("#{protocol}://#{host}:#{port}/ticket_server/projects", :api_key => default_request_params[:api_key], :issue_id => default_request_params[:issue_id])
|
74
|
+
end
|
75
|
+
def journals
|
76
|
+
RestClient.post("#{protocol}://#{host}:#{port}/ticket_server/journals", :api_key => default_request_params[:api_key], :issue_id => default_request_params[:issue_id])
|
77
|
+
end
|
59
78
|
end
|
60
79
|
|
61
80
|
class Sender
|
@@ -94,9 +113,10 @@ module RedmineTicketClient
|
|
94
113
|
|
95
114
|
case response
|
96
115
|
when Net::HTTPSuccess then
|
97
|
-
|
116
|
+
return response.body
|
98
117
|
else
|
99
118
|
$stderr.puts "Redmine Failure: #{response.class}\n#{response.body if response.respond_to? :body}"
|
119
|
+
return response.class
|
100
120
|
end
|
101
121
|
end
|
102
122
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: redmine-ticket-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Rubio
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-29 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -38,6 +38,8 @@ files:
|
|
38
38
|
- Manifest.txt
|
39
39
|
- README.txt
|
40
40
|
- Rakefile
|
41
|
+
- examples/issue_status.rb
|
42
|
+
- examples/last_tickets.rb
|
41
43
|
- examples/post_ticket.rb
|
42
44
|
- lib/redmine-ticket/client.rb
|
43
45
|
has_rdoc: true
|