redmine-ticket-client 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +6 -0
- data/Manifest.txt +6 -0
- data/README.txt +16 -0
- data/Rakefile +14 -0
- data/examples/post_ticket.rb +30 -0
- data/lib/redmine-ticket/client.rb +110 -0
- metadata +73 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
Redmine Ticket Client
|
2
|
+
===============
|
3
|
+
|
4
|
+
This is the notifier plugin for integrating apps with Redmine Ticket Server:
|
5
|
+
|
6
|
+
http://github.com/rubiojr/redmine_ticket_server
|
7
|
+
|
8
|
+
Code based on hoptoad notifier by Thoughbot inc.
|
9
|
+
|
10
|
+
http://github.com/thoughtbot/hoptoad_notifier
|
11
|
+
|
12
|
+
INSTALLATION
|
13
|
+
------------
|
14
|
+
|
15
|
+
CONFIGURATION
|
16
|
+
-------------
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
require './lib/redmine-ticket/client.rb'
|
6
|
+
|
7
|
+
Hoe.new('redmine-ticket-client', RedmineTicketClient::VERSION) do |p|
|
8
|
+
p.developer('Sergio Rubio', 'sergio@rubio.name')
|
9
|
+
p.summary = 'Client library for the Redmine Ticket Server'
|
10
|
+
p.description = 'Client library for the Redmine Ticket Server'
|
11
|
+
p.url = 'http://github.com/rubiojr/redmine_ticket_client'
|
12
|
+
end
|
13
|
+
|
14
|
+
# vim: syntax=Ruby
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '../lib/redmine-ticket/client')
|
2
|
+
params = {
|
3
|
+
# the identifier you specified for your project
|
4
|
+
:project => 'test',
|
5
|
+
# the name of your Tracker of choice in Redmine
|
6
|
+
:tracker => 'Bug',
|
7
|
+
# the key you generated before in Redmine
|
8
|
+
:api_key => 'API_KEY_HERE',
|
9
|
+
# the name of a ticket category (optional.)
|
10
|
+
:category => 'Development',
|
11
|
+
|
12
|
+
# the login of a user the ticket should get assigned to by default
|
13
|
+
#:assigned_to => 'admin', #optional
|
14
|
+
|
15
|
+
# the default priority (use a number, not a name. optional.)
|
16
|
+
#:priority => 5,
|
17
|
+
|
18
|
+
:subject => 'malabaristic',
|
19
|
+
:description => 'description text'
|
20
|
+
|
21
|
+
}.to_yaml
|
22
|
+
|
23
|
+
RedmineTicketClient.configure do |config|
|
24
|
+
config.params = params
|
25
|
+
config.host = '127.0.0.1' # the hostname your Redmine runs at
|
26
|
+
config.port = 3000 # the port your Redmine runs at
|
27
|
+
config.secure = false # sends data to your server via SSL (optional.)
|
28
|
+
end
|
29
|
+
|
30
|
+
RedmineTicketClient.post_ticket
|
@@ -0,0 +1,110 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'net/https'
|
3
|
+
require 'rubygems'
|
4
|
+
|
5
|
+
module RedmineTicketClient
|
6
|
+
|
7
|
+
VERSION = '0.1'
|
8
|
+
|
9
|
+
class << self
|
10
|
+
attr_accessor :host, :port, :secure, :params, :http_open_timeout, :http_read_timeout,
|
11
|
+
:proxy_host, :proxy_port, :proxy_user, :proxy_pass
|
12
|
+
|
13
|
+
# The port on which your Redmine server runs.
|
14
|
+
def port
|
15
|
+
@port || (secure ? 443 : 80)
|
16
|
+
end
|
17
|
+
|
18
|
+
# The host to connect to.
|
19
|
+
def host
|
20
|
+
@host ||= 'hoptoadapp.com'
|
21
|
+
end
|
22
|
+
|
23
|
+
# The HTTP open timeout (defaults to 2 seconds).
|
24
|
+
def http_open_timeout
|
25
|
+
@http_open_timeout ||= 2
|
26
|
+
end
|
27
|
+
|
28
|
+
# The HTTP read timeout (defaults to 5 seconds).
|
29
|
+
def http_read_timeout
|
30
|
+
@http_read_timeout ||= 5
|
31
|
+
end
|
32
|
+
|
33
|
+
# NOTE: secure connections are not yet supported.
|
34
|
+
def configure
|
35
|
+
yield self
|
36
|
+
end
|
37
|
+
|
38
|
+
def protocol #:nodoc:
|
39
|
+
secure ? "https" : "http"
|
40
|
+
end
|
41
|
+
|
42
|
+
def url #:nodoc:
|
43
|
+
URI.parse("#{protocol}://#{host}:#{port}/ticket_server/")
|
44
|
+
end
|
45
|
+
|
46
|
+
def default_ticket_options #:nodoc:
|
47
|
+
{
|
48
|
+
:params => RedmineTicketClient.params,
|
49
|
+
:error_message => 'Notification',
|
50
|
+
:request => {},
|
51
|
+
:session => {},
|
52
|
+
:environment => ENV.to_hash
|
53
|
+
}
|
54
|
+
end
|
55
|
+
|
56
|
+
def post_ticket
|
57
|
+
Sender.new.post_to_redmine( default_ticket_options )
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class Sender
|
62
|
+
def rescue_action_in_public(exception)
|
63
|
+
end
|
64
|
+
|
65
|
+
def post_to_redmine hash_or_exception
|
66
|
+
ticket = hash_or_exception
|
67
|
+
send_to_redmine(:ticket => ticket)
|
68
|
+
end
|
69
|
+
|
70
|
+
def send_to_redmine data #:nodoc:
|
71
|
+
headers = {
|
72
|
+
'Content-type' => 'application/x-yaml',
|
73
|
+
'Accept' => 'text/xml, application/xml'
|
74
|
+
}
|
75
|
+
|
76
|
+
url = RedmineTicketClient.url
|
77
|
+
|
78
|
+
http = Net::HTTP::Proxy(RedmineTicketClient.proxy_host,
|
79
|
+
RedmineTicketClient.proxy_port,
|
80
|
+
RedmineTicketClient.proxy_user,
|
81
|
+
RedmineTicketClient.proxy_pass).new(url.host, url.port)
|
82
|
+
|
83
|
+
http.use_ssl = true
|
84
|
+
http.read_timeout = RedmineTicketClient.http_read_timeout
|
85
|
+
http.open_timeout = RedmineTicketClient.http_open_timeout
|
86
|
+
http.use_ssl = !!RedmineTicketClient.secure
|
87
|
+
|
88
|
+
response = begin
|
89
|
+
http.post(url.path, stringify_keys(data).to_yaml, headers)
|
90
|
+
rescue TimeoutError => e
|
91
|
+
$stderr.puts "Timeout while contacting the Redmine server."
|
92
|
+
nil
|
93
|
+
end
|
94
|
+
|
95
|
+
case response
|
96
|
+
when Net::HTTPSuccess then
|
97
|
+
puts "Redmine Success: #{response.class}"
|
98
|
+
else
|
99
|
+
$stderr.puts "Redmine Failure: #{response.class}\n#{response.body if response.respond_to? :body}"
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def stringify_keys(hash) #:nodoc:
|
104
|
+
hash.inject({}) do |h, pair|
|
105
|
+
h[pair.first.to_s] = pair.last.is_a?(Hash) ? stringify_keys(pair.last) : pair.last
|
106
|
+
h
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: redmine-ticket-client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: "0.1"
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sergio Rubio
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-10-06 00:00:00 +02:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: hoe
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 2.3.3
|
24
|
+
version:
|
25
|
+
description: Client library for the Redmine Ticket Server
|
26
|
+
email:
|
27
|
+
- sergio@rubio.name
|
28
|
+
executables: []
|
29
|
+
|
30
|
+
extensions: []
|
31
|
+
|
32
|
+
extra_rdoc_files:
|
33
|
+
- History.txt
|
34
|
+
- Manifest.txt
|
35
|
+
- README.txt
|
36
|
+
files:
|
37
|
+
- History.txt
|
38
|
+
- Manifest.txt
|
39
|
+
- README.txt
|
40
|
+
- Rakefile
|
41
|
+
- examples/post_ticket.rb
|
42
|
+
- lib/redmine-ticket/client.rb
|
43
|
+
has_rdoc: true
|
44
|
+
homepage: http://github.com/rubiojr/redmine_ticket_client
|
45
|
+
licenses: []
|
46
|
+
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options:
|
49
|
+
- --main
|
50
|
+
- README.txt
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
version:
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
65
|
+
requirements: []
|
66
|
+
|
67
|
+
rubyforge_project: redmine-ticket-client
|
68
|
+
rubygems_version: 1.3.3
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: Client library for the Redmine Ticket Server
|
72
|
+
test_files: []
|
73
|
+
|