hudson-remote-api 0.3.1 → 0.3.2

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/Rakefile CHANGED
@@ -17,4 +17,12 @@ rescue LoadError
17
17
  puts "Jeweler not available. Install it with: sudo gem install jeweler -s http://gemcutter.org"
18
18
  end
19
19
 
20
+ namespace :test do
21
+ desc "Run all tests"
22
+ task :all do
23
+ test_files = Dir.glob("test/*.rb")
24
+ test_files.each{|f| require f}
25
+ end
26
+ end
27
+
20
28
  Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.1
1
+ 0.3.2
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{hudson-remote-api}
8
- s.version = "0.3.1"
8
+ s.version = "0.3.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Dru Ibarra}]
12
- s.date = %q{2011-10-05}
12
+ s.date = %q{2011-10-10}
13
13
  s.description = %q{Connect to Hudson's remote web API}
14
14
  s.email = %q{Druwerd@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -35,8 +35,7 @@ Gem::Specification.new do |s|
35
35
  "test/test_hudson_build_queue.rb",
36
36
  "test/test_hudson_config.rb",
37
37
  "test/test_hudson_job.rb",
38
- "test/test_hudson_multicast.rb",
39
- "test/test_hudson_remote_api.rb"
38
+ "test/test_hudson_multicast.rb"
40
39
  ]
41
40
  s.homepage = %q{http://github.com/Druwerd/hudson-remote-api}
42
41
  s.rdoc_options = [%q{--charset=UTF-8}]
@@ -49,8 +48,7 @@ Gem::Specification.new do |s|
49
48
  "test/test_hudson_build_queue.rb",
50
49
  "test/test_hudson_config.rb",
51
50
  "test/test_hudson_job.rb",
52
- "test/test_hudson_multicast.rb",
53
- "test/test_hudson_remote_api.rb"
51
+ "test/test_hudson_multicast.rb"
54
52
  ]
55
53
 
56
54
  if s.respond_to? :specification_version then
@@ -15,6 +15,16 @@ module Hudson
15
15
  # Base class for all Hudson objects
16
16
  class HudsonObject
17
17
 
18
+ def self.hudson_request(uri,request)
19
+ Net::HTTP.start(uri.host, uri.port) do |http|
20
+ http = Net::HTTP.new(uri.host, uri.port)
21
+ if uri.scheme == 'https'
22
+ http.use_ssl = true
23
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE
24
+ end
25
+ http.request(request)
26
+ end
27
+ end
18
28
 
19
29
  def self.load_xml_api
20
30
  @@hudson_xml_api_path = File.join(Hudson[:url], "api/xml")
@@ -28,21 +38,14 @@ module Hudson
28
38
  end
29
39
 
30
40
  def self.get_xml(url)
31
- uri = URI.parse(url)
41
+ uri = URI.parse(URI.encode(url))
32
42
  host = uri.host
33
43
  port = uri.port
34
44
  path = uri.path
35
45
  request = Net::HTTP::Get.new(path)
36
46
  request.basic_auth(Hudson[:user], Hudson[:password]) if Hudson[:user] and Hudson[:password]
37
47
  request['Content-Type'] = "text/xml"
38
- response = Net::HTTP.start(host, port) do |http|
39
- http = Net::HTTP.new(uri.host, uri.port)
40
- if uri.scheme == 'https'
41
- http.use_ssl = true
42
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
43
- end
44
- http.request(request)
45
- end
48
+ response = hudson_request(uri,request)
46
49
 
47
50
  if response.is_a?(Net::HTTPSuccess) or response.is_a?(Net::HTTPRedirection)
48
51
  encoding = response.get_fields("Content-Encoding")
@@ -52,7 +55,7 @@ module Hudson
52
55
  return response.body
53
56
  end
54
57
  else
55
- puts response
58
+ $stderr.puts response.body
56
59
  raise APIError, "Error retrieving #{path}"
57
60
  end
58
61
  end
@@ -62,7 +65,7 @@ module Hudson
62
65
  end
63
66
 
64
67
  def self.send_post_request(url, data={})
65
- uri = URI.parse(url)
68
+ uri = URI.parse(URI.encode(url))
66
69
  host = uri.host
67
70
  port = uri.port
68
71
  path = uri.path
@@ -70,7 +73,7 @@ module Hudson
70
73
  request.basic_auth(Hudson[:user], Hudson[:password]) if Hudson[:user] and Hudson[:password]
71
74
  request.set_form_data(data)
72
75
  request.add_field(crumb.name, crumb.value) if crumb
73
- Net::HTTP.new(host, port).start{|http| http.request(request)}
76
+ hudson_request(uri,request)
74
77
  end
75
78
 
76
79
  def send_post_request(url, data={})
@@ -78,7 +81,7 @@ module Hudson
78
81
  end
79
82
 
80
83
  def self.send_xml_post_request(url, xml, data=nil)
81
- uri = URI.parse(url)
84
+ uri = URI.parse(URI.encode(url))
82
85
  host = uri.host
83
86
  port = uri.port
84
87
  path = uri.path
@@ -88,7 +91,7 @@ module Hudson
88
91
  request.set_form_data(data) if data
89
92
  request.add_field(crumb.name, crumb.value) if crumb
90
93
  request.body = xml
91
- Net::HTTP.new(host, port).start{|http| http.request(request)}
94
+ hudson_request(uri,request)
92
95
  end
93
96
 
94
97
  def send_xml_post_request(url, xml, data=nil)
@@ -59,4 +59,11 @@ class TestHudsonJob < Test::Unit::TestCase
59
59
  job = Hudson::Job.get("test_job")
60
60
  assert_equal(job.url, "http://localhost:8080/job/#{job.name}/")
61
61
  end
62
+
63
+ def test_job_with_spaces
64
+ job = Hudson::Job.create('test job with spaces')
65
+ assert job
66
+ assert job.name
67
+ assert job.delete
68
+ end
62
69
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hudson-remote-api
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 1
10
- version: 0.3.1
9
+ - 2
10
+ version: 0.3.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Dru Ibarra
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-05 00:00:00 Z
18
+ date: 2011-10-10 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: Connect to Hudson's remote web API
@@ -47,7 +47,6 @@ files:
47
47
  - test/test_hudson_config.rb
48
48
  - test/test_hudson_job.rb
49
49
  - test/test_hudson_multicast.rb
50
- - test/test_hudson_remote_api.rb
51
50
  homepage: http://github.com/Druwerd/hudson-remote-api
52
51
  licenses: []
53
52
 
@@ -87,4 +86,3 @@ test_files:
87
86
  - test/test_hudson_config.rb
88
87
  - test/test_hudson_job.rb
89
88
  - test/test_hudson_multicast.rb
90
- - test/test_hudson_remote_api.rb
@@ -1,2 +0,0 @@
1
- test_files = Dir.glob("*.rb")
2
- test_files.each{|f| require f}