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.
@@ -2,5 +2,7 @@ History.txt
2
2
  Manifest.txt
3
3
  README.txt
4
4
  Rakefile
5
+ examples/issue_status.rb
6
+ examples/last_tickets.rb
5
7
  examples/post_ticket.rb
6
8
  lib/redmine-ticket/client.rb
data/README.txt CHANGED
@@ -12,5 +12,10 @@ http://github.com/thoughtbot/hoptoad_notifier
12
12
  INSTALLATION
13
13
  ------------
14
14
 
15
- CONFIGURATION
15
+ Install the rubygem from http://gemcutter.org
16
+
17
+ EXAMPLES
16
18
  -------------
19
+ see examples/ dir
20
+
21
+
@@ -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
@@ -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 => 'API_KEY_HERE',
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 => 'malabaristic',
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 = '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.)
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.1'
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
- puts "Redmine Success: #{response.class}"
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: "0.1"
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-06 00:00:00 +02:00
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