teamcity-rest-client 0.2.2 → 0.3.0

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.3.0
@@ -98,6 +98,15 @@ module TeamcityRestClient
98
98
  end
99
99
 
100
100
  class Authentication
101
+
102
+ def initialize openuri_options
103
+ @openuri_options = openuri_options
104
+ end
105
+
106
+ def get path, params = {}
107
+ open(url(path, params), @openuri_options).read
108
+ end
109
+
101
110
  def query_string_for params
102
111
  pairs = []
103
112
  params.each_pair { |k,v| pairs << "#{k}=#{v}" }
@@ -106,14 +115,12 @@ module TeamcityRestClient
106
115
  end
107
116
 
108
117
  class HttpBasicAuthentication < Authentication
109
- def initialize host, port, user, password
118
+
119
+ def initialize host, port, user, password, openuri_options = {}
120
+ super({:http_basic_authentication => [user, password]}.merge(openuri_options))
110
121
  @host, @port, @user, @password = host, port, user, password
111
122
  end
112
123
 
113
- def get path, params = {}
114
- open(url(path, params), :http_basic_authentication => [@user, @password]).read
115
- end
116
-
117
124
  def url path, params = {}
118
125
  auth_path = path.start_with?("/httpAuth/") ? path : "/httpAuth#{path}"
119
126
  query_string = !params.empty? ? "?#{query_string_for(params)}" : ""
@@ -126,14 +133,12 @@ module TeamcityRestClient
126
133
  end
127
134
 
128
135
  class Open < Authentication
129
- def initialize host, port
136
+
137
+ def initialize host, port, options = {}
138
+ super(options)
130
139
  @host, @port = host, port
131
140
  end
132
141
 
133
- def get path, params = {}
134
- open(url(path, params)).read
135
- end
136
-
137
142
  def url path, params = {}
138
143
  query_string = !params.empty? ? "?#{query_string_for(params)}" : ""
139
144
  "http://#{@host}:#{@port}#{path}#{query_string}"
@@ -160,12 +165,12 @@ class Teamcity
160
165
 
161
166
  attr_reader :host, :port, :authentication
162
167
 
163
- def initialize host, port, user = nil, password = nil
168
+ def initialize host, port, options = {}
164
169
  @host, @port = host, port
165
- if user != nil && password != nil
166
- @authentication = TeamcityRestClient::HttpBasicAuthentication.new host, port, user, password
170
+ if options[:user] && options[:password]
171
+ @authentication = TeamcityRestClient::HttpBasicAuthentication.new(host, port, options[:user], options[:password], options)
167
172
  else
168
- @authentication = TeamcityRestClient::Open.new host, port
173
+ @authentication = TeamcityRestClient::Open.new(host, port, options)
169
174
  end
170
175
  end
171
176
 
@@ -253,8 +253,9 @@ module TeamcityRestClient
253
253
 
254
254
  describe HttpBasicAuthentication do
255
255
  before :each do
256
+ @openuri_options = { :proxy => 'http://proxy:9999' }
256
257
  @host, @port, @user, @password = "auth.example.com", 2233, "john", "wayne"
257
- @auth = HttpBasicAuthentication.new @host, @port, @user, @password
258
+ @auth = HttpBasicAuthentication.new @host, @port, @user, @password, @openuri_options
258
259
  @io = stub(:read => "<xml/>")
259
260
  end
260
261
 
@@ -273,11 +274,11 @@ module TeamcityRestClient
273
274
  end
274
275
 
275
276
  describe "get" do
276
- it "should call open with http basic auth options" do
277
+ it "should call open with http basic auth options, and openuri option" do
277
278
  path, options = "/something", {:id => 1}
278
279
  url = "http://localhost:1324"
279
280
  @auth.should_receive(:url).with(path, options).and_return url
280
- @auth.should_receive(:open).with(url, :http_basic_authentication=>[@user, @password]).and_return(@io)
281
+ @auth.should_receive(:open).with(url, {:http_basic_authentication=>[@user, @password], :proxy => 'http://proxy:9999'}).and_return(@io)
281
282
  @auth.get(path, options)
282
283
  end
283
284
  end
@@ -286,7 +287,8 @@ module TeamcityRestClient
286
287
  describe Open do
287
288
  before :each do
288
289
  @host, @port = "auth.example.com", 2233
289
- @auth = Open.new @host, @port
290
+ @openuri_options = { :proxy => 'http://localhost:1234' }
291
+ @auth = Open.new @host, @port, @openuri_options
290
292
  @io = stub(:read => "<xml/>")
291
293
  end
292
294
 
@@ -305,7 +307,7 @@ module TeamcityRestClient
305
307
  path, options = "/something", {:id => 1}
306
308
  url = "http://localhost:1324"
307
309
  @auth.should_receive(:url).with(path, options).and_return url
308
- @auth.should_receive(:open).with(url).and_return(@io)
310
+ @auth.should_receive(:open).with(url, @openuri_options).and_return(@io)
309
311
  @auth.get(path, options)
310
312
  end
311
313
  end
@@ -364,12 +366,13 @@ describe Teamcity do
364
366
  describe "specifying username and password" do
365
367
  before :each do
366
368
  @host, @port, @user, @password = "authtc.example.com", 8877, "bob", "marley"
369
+ @options = {:user => @user, :password => @password, :proxy => 'dog'}
367
370
  @authentication = mock('authentication')
368
- TeamcityRestClient::HttpBasicAuthentication.should_receive(:new).with(@host, @port, @user, @password).and_return(@authentication)
369
- @tc = Teamcity.new @host, @port, @user, @password
371
+ TeamcityRestClient::HttpBasicAuthentication.should_receive(:new).with(@host, @port, @user, @password, @options).and_return(@authentication)
372
+ @tc = Teamcity.new @host, @port, @options
370
373
  end
371
374
 
372
- it "should create HttpBasicAuthentication" do
375
+ it "should create HttpBasicAuthentication, passing through the options" do
373
376
  @tc.authentication.should === @authentication
374
377
  end
375
378
  end
@@ -377,12 +380,13 @@ describe Teamcity do
377
380
  describe "specifying no username and password" do
378
381
  before :each do
379
382
  @host, @port = "authtc.example.com", 8877
383
+ @options = { :proxy => 'cat' }
380
384
  @authentication = mock('authentication')
381
- TeamcityRestClient::Open.should_receive(:new).with(@host, @port).and_return(@authentication)
382
- @tc = Teamcity.new @host, @port
385
+ TeamcityRestClient::Open.should_receive(:new).with(@host, @port, @options).and_return(@authentication)
386
+ @tc = Teamcity.new @host, @port, @options
383
387
  end
384
388
 
385
- it "should create HttpBasicAuthetication" do
389
+ it "should create Open authentication" do
386
390
  @tc.authentication.should === @authentication
387
391
  end
388
392
  end
@@ -460,7 +464,7 @@ HTML
460
464
  XML
461
465
  @authentication.should_receive(:get).with("/app/rest/projects", {}).and_return(xml)
462
466
  TeamcityRestClient::HttpBasicAuthentication.should_receive(:new).and_return(@authentication)
463
- @tc = Teamcity.new @host, @port, @user, @password
467
+ @tc = Teamcity.new @host, @port, { :user => @user, :password => @password }
464
468
  @projects = @tc.projects
465
469
  end
466
470
 
@@ -496,7 +500,7 @@ XML
496
500
  XML
497
501
  @authentication.should_receive(:get).with("/app/rest/buildTypes", {}).and_return(xml)
498
502
  TeamcityRestClient::HttpBasicAuthentication.should_receive(:new).and_return(@authentication)
499
- @tc = Teamcity.new @host, @port, @user, @password
503
+ @tc = Teamcity.new @host, @port, :user => @user, :password => @password
500
504
  @build_types = @tc.build_types
501
505
  end
502
506
 
@@ -550,7 +554,7 @@ XML
550
554
  @options = {:buildType => "id:bt212", :count => 1}
551
555
  @authentication.should_receive(:get).with("/app/rest/builds", @options).and_return(xml)
552
556
  TeamcityRestClient::HttpBasicAuthentication.should_receive(:new).and_return(@authentication)
553
- @tc = Teamcity.new @host, @port, @user, @password
557
+ @tc = Teamcity.new @host, @port, :user => @user, :password => @password
554
558
  @builds = @tc.builds @options
555
559
  end
556
560
 
@@ -570,7 +574,7 @@ XML
570
574
  XML
571
575
  @authentication.should_receive(:get).with("/app/rest/builds", {}).and_return(xml)
572
576
  TeamcityRestClient::HttpBasicAuthentication.should_receive(:new).and_return(@authentication)
573
- @tc = Teamcity.new @host, @port, @user, @password
577
+ @tc = Teamcity.new @host, @port, :user => @user, :password => @password
574
578
  @builds = @tc.builds
575
579
  end
576
580
 
@@ -604,7 +608,7 @@ XML
604
608
  XML
605
609
  @authentication.should_receive(:get).with("/app/rest/builds", {}).and_return(xml)
606
610
  TeamcityRestClient::HttpBasicAuthentication.should_receive(:new).and_return(@authentication)
607
- @tc = Teamcity.new @host, @port, @user, @password
611
+ @tc = Teamcity.new @host, @port, :user => @user, :password => @password
608
612
  @builds = @tc.builds
609
613
  end
610
614
 
@@ -638,4 +642,4 @@ XML
638
642
  end
639
643
  end
640
644
  end
641
- end
645
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "teamcity-rest-client"
8
- s.version = "0.2.2"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["simon"]
12
- s.date = "2011-11-03"
12
+ s.date = "2012-01-20"
13
13
  s.description = "Teamcity rest api client (readonly)"
14
14
  s.email = "simojenki@gmail.com"
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teamcity-rest-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-03 00:00:00.000000000Z
12
+ date: 2012-01-20 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &2157516220 !ruby/object:Gem::Requirement
16
+ requirement: &80597140 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 2.3.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2157516220
24
+ version_requirements: *80597140
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: bundler
27
- requirement: &2157515740 !ruby/object:Gem::Requirement
27
+ requirement: &80596870 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.0.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2157515740
35
+ version_requirements: *80596870
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: jeweler
38
- requirement: &2157515240 !ruby/object:Gem::Requirement
38
+ requirement: &80596630 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.6.4
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2157515240
46
+ version_requirements: *80596630
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rcov
49
- requirement: &2157514760 !ruby/object:Gem::Requirement
49
+ requirement: &80596360 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *2157514760
57
+ version_requirements: *80596360
58
58
  description: Teamcity rest api client (readonly)
59
59
  email: simojenki@gmail.com
60
60
  executables: []
@@ -94,7 +94,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
94
94
  version: '0'
95
95
  segments:
96
96
  - 0
97
- hash: 1926460357061401344
97
+ hash: -787692387
98
98
  required_rubygems_version: !ruby/object:Gem::Requirement
99
99
  none: false
100
100
  requirements: