bamboo-client 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 38822888e09b2105e0e6142f35de3a5f4fa11fa6
4
- data.tar.gz: 9567bc374446f4c83212ab531123a992fd09e21e
3
+ metadata.gz: 224a6b075dd5f763b1ad322838359cc57b9c089d
4
+ data.tar.gz: 66e9493a34ffbb55a0824e528e2880f137b895bc
5
5
  SHA512:
6
- metadata.gz: e8ccba78195cb35cc858d321e55e1206e9ad615e44c65c551a3dce3af1d56946ee69a47b67f6a991b747af181fe9d4769f21a620803cd687dc62b7fdc3db2e8e
7
- data.tar.gz: 0f8da5377be315763cfcdc6c15fc3bfaee098bebe97a3cb97013ec1e7be3f310554fbdaf3f2e26d12b79a3708622a57dc2afd3318018bcd1c5e3d95bf868e18e
6
+ metadata.gz: acabe3c2d0be4778d1bb148bde7ef10f63147aefe9a9fb51481f97e4f9bc4c8433c7ca9b90caace18a169dd6f24adda439ce642026bbe38a7cb11dffe1aed374
7
+ data.tar.gz: 6c96bdb30aa662164dcf38cb3a3f786dab380675ccb635651db6c6a0d9d66094c4d2acea498cbc6e9c122478d1f54175057c30efe3bcfecdf2b22cc057d4093b
@@ -1,5 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.8.7
4
3
  - 1.9.3
5
- - 2.0.0
4
+ - 2.0.0
5
+ - 2.1.0
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2010-2012 Jari Bakken
1
+ Copyright (c) 2010-2014 Jari Bakken
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
@@ -41,19 +41,20 @@ module Bamboo
41
41
 
42
42
  attr_reader :cookies
43
43
 
44
- def post(uri_or_path, data = {}, cookies = nil)
45
- resp = RestClient.post(uri_for(uri_or_path), data.to_json, :accept => :json, :content_type => :json, :cookies => cookies)
44
+ def post(uri_or_path, data = {})
45
+ resp = RestClient.post(uri_for(uri_or_path), data.to_json, default_headers.merge(:content_type => :json))
46
46
  Doc.from(resp) unless resp.empty?
47
47
  end
48
48
 
49
- def post_with_query(uri_or_path, query = {}, cookies = nil)
50
- resp = RestClient.post(uri_for(uri_or_path, query), '{}', :accept => :json, :content_type => :json, :cookies => cookies)
49
+ def post_with_query(uri_or_path, query = {})
50
+ resp = RestClient.post(uri_for(uri_or_path, query), '{}', default_headers.merge(:content_type => :json))
51
51
  Doc.from(resp) unless resp.empty?
52
52
  end
53
53
 
54
- def get(uri_or_path, params = nil, cookies = nil)
54
+ def get(uri_or_path, params = nil)
55
55
  uri = uri_for(uri_or_path, params)
56
- Doc.from RestClient.get(uri, :accept => :json, :cookies => cookies)
56
+ puts "Json.get: url: #{uri} cookies: #{cookies}" if $DEBUG
57
+ Doc.from RestClient.get(uri, default_headers)
57
58
  end
58
59
 
59
60
  def get_cookies(uri_or_path, params = nil)
@@ -62,6 +63,15 @@ module Bamboo
62
63
  @cookies = resp.cookies
63
64
  end
64
65
 
66
+ private
67
+
68
+ def default_headers
69
+ params = { :accept => :json }
70
+ params[:cookies] = @cookies if @cookies
71
+
72
+ params
73
+ end
74
+
65
75
  end # Json
66
76
  end # Http
67
77
  end # Client
@@ -93,14 +93,14 @@ module Bamboo
93
93
  path = File.join(SERVICE, "queue/#{URI.escape key}")
94
94
 
95
95
  if params
96
- @http.post_with_query path, params, @http.cookies
96
+ @http.post_with_query path, params
97
97
  else
98
- @http.post path, {}, @http.cookies
98
+ @http.post path, {}
99
99
  end
100
100
  end
101
101
 
102
- def results
103
- doc = @http.get File.join(SERVICE, "result/#{URI.escape key}"), {}, @http.cookies
102
+ def results(params = {})
103
+ doc = @http.get File.join(SERVICE, "result/#{URI.escape key}"), params
104
104
  doc.auto_expand Result, @http
105
105
  end
106
106
 
@@ -131,7 +131,7 @@ module Bamboo
131
131
  def plans
132
132
  @plans ||= (
133
133
  unless @data['plans'] && @data['plans']['plan']
134
- @data = @http.get(URI.parse(url), {:expand => 'plans'}, @http.cookies).data
134
+ @data = @http.get(URI.parse(url), :expand => 'plans').data
135
135
  end
136
136
 
137
137
  @data.fetch('plans').fetch('plan').map { |e| Plan.new(e, @http) }
@@ -256,6 +256,10 @@ module Bamboo
256
256
  @data['comment']
257
257
  end
258
258
 
259
+ def commit_url
260
+ @data['commitUrl']
261
+ end
262
+
259
263
  def files
260
264
  # could use expand here
261
265
  Array(@data.fetch('files')['file']).map do |data|
@@ -280,14 +284,14 @@ module Bamboo
280
284
  end
281
285
 
282
286
  def add(key)
283
- data = @http.post(File.join(SERVICE, "queue/#{URI.escape key}"), {}, @http.cookies).data
287
+ data = @http.post(File.join(SERVICE, "queue/#{URI.escape key}"), {}).data
284
288
  QueuedBuild.new(data, @http)
285
289
  end
286
290
 
287
291
  def queued_builds
288
292
  @queued_builds ||= (
289
293
  unless @data['queuedBuilds'] && @data['queuedBuilds']['queuedBuild']
290
- @data = @http.get(File.join(SERVICE, 'queue'), {:expand => 'queuedBuilds'}, @http.cookies).data
294
+ @data = @http.get(File.join(SERVICE, 'queue'), {:expand => 'queuedBuilds'}).data
291
295
  end
292
296
 
293
297
  begin
@@ -332,7 +336,7 @@ module Bamboo
332
336
  def changes
333
337
  @changes ||= (
334
338
  unless @data['changes'] && @data['changes']['change']
335
- @data = @http.get(URI.parse(url), {:expand => 'changes'}, @http.cookies).data
339
+ @data = @http.get(URI.parse(url), {:expand => 'changes'}).data
336
340
  end
337
341
 
338
342
  @data.fetch('changes').fetch('change').map { |e| Change.new(e, @http) }
@@ -1,5 +1,5 @@
1
1
  module Bamboo
2
2
  module Client
3
- VERSION = "0.1.7"
3
+ VERSION = "0.1.8"
4
4
  end
5
5
  end
@@ -9,7 +9,7 @@ module Bamboo
9
9
 
10
10
  it "does a GET" do
11
11
  RestClient.should_receive(:get).with(
12
- "#{url}/", :accept => :json, :cookies => nil
12
+ "#{url}/", :accept => :json
13
13
  ).and_return('{"some": "data"}')
14
14
 
15
15
  doc = json.get "/"
@@ -18,7 +18,7 @@ module Bamboo
18
18
 
19
19
  it "does a POST" do
20
20
  RestClient.should_receive(:post).with(
21
- "#{url}/", '{"some":"data"}', :accept => :json, :content_type => :json, :cookies => nil
21
+ "#{url}/", '{"some":"data"}', :accept => :json, :content_type => :json
22
22
  ).and_return('')
23
23
 
24
24
  json.post("/", :some => "data").should be_nil
@@ -26,18 +26,23 @@ module Bamboo
26
26
 
27
27
  it 'does a POST with query instead of JSON data' do
28
28
  RestClient.should_receive(:post).with(
29
- "#{url}/?some=data", '{}', :accept => :json, :content_type => :json, :cookies => nil
29
+ "#{url}/?some=data", '{}', :accept => :json, :content_type => :json
30
30
  ).and_return('')
31
31
 
32
32
  json.post_with_query("/", :some => "data").should be_nil
33
33
  end
34
34
 
35
35
  it "returns cookies from GET" do
36
- net_http_resp = Net::HTTPResponse.new(1.0, 200, "OK")
37
- net_http_resp.add_field 'Set-Cookie', 'Cookie=Value;'
38
- resp = RestClient::Response.create("",net_http_resp, nil)
36
+ resp = '{}'
37
+ def resp.cookies; {'Cookie' => 'Value'}; end
38
+
39
39
  RestClient.should_receive(:get).with("#{url}/", :params => nil).and_return(resp)
40
- cookies = json.get_cookies("/").should == {'Cookie' => 'Value'}
40
+
41
+ cookies = json.get_cookies("/")
42
+ cookies.should == {'Cookie' => 'Value'}
43
+
44
+ RestClient.should_receive(:get).with("#{url}/", :accept => :json, :cookies => cookies).and_return('{}')
45
+ json.get('/').should be_kind_of(Json::Doc)
41
46
  end
42
47
 
43
48
  end
@@ -110,21 +110,18 @@ module Bamboo
110
110
  end
111
111
 
112
112
  it "can be queued" do
113
- http.should_receive(:cookies).and_return("some" => "cookie")
114
- http.should_receive(:post).with("/rest/api/latest/queue/S2RB-REMWIN", {}, {"some" => "cookie"})
113
+ http.should_receive(:post).with("/rest/api/latest/queue/S2RB-REMWIN", {})
115
114
  plan.queue
116
115
  end
117
116
 
118
117
  it "can be queued with parameters" do
119
- http.should_receive(:cookies).and_return("some" => "cookie")
120
- http.should_receive(:post_with_query).with("/rest/api/latest/queue/S2RB-REMWIN", {:customRevision => 'test123'}, {"some" => "cookie"})
118
+ http.should_receive(:post_with_query).with("/rest/api/latest/queue/S2RB-REMWIN", {:customRevision => 'test123'})
121
119
  plan.queue(:customRevision => 'test123')
122
120
  end
123
121
 
124
122
  it 'can fetch results' do
125
123
  document.should_receive(:auto_expand).with(Rest::Result, http)
126
- http.should_receive(:cookies).and_return("some" => "cookie")
127
- http.should_receive(:get).with("/rest/api/latest/result/S2RB-REMWIN", {}, {"some" => "cookie"}).and_return(document)
124
+ http.should_receive(:get).with("/rest/api/latest/result/S2RB-REMWIN", {}).and_return(document)
128
125
 
129
126
  plan.results
130
127
  end
@@ -148,8 +145,7 @@ module Bamboo
148
145
 
149
146
  it 'can fetch plans' do
150
147
  document.should_receive(:data).and_return('plans' => {'plan' => []})
151
- http.should_receive(:cookies).and_return("some" => "cookie")
152
- http.should_receive(:get).with(URI.parse(project.url), {:expand => 'plans'}, {"some" => "cookie"}).and_return(document)
148
+ http.should_receive(:get).with(URI.parse(project.url), {:expand => 'plans'}).and_return(document)
153
149
 
154
150
  project.plans.should == []
155
151
  end
@@ -195,6 +191,7 @@ module Bamboo
195
191
  context "with details" do
196
192
  before do
197
193
  # TODO: arg/uri expectation?
194
+ http.stub(:cookies => {"some" => "cookie"})
198
195
  http.should_receive(:get).and_return Http::Json::Doc.new(json_fixture("result_with_changes"))
199
196
  end
200
197
 
@@ -258,6 +255,9 @@ module Bamboo
258
255
  change.comment.should == "Fixed the config thing."
259
256
  end
260
257
 
258
+ it "has a commit url" do
259
+ change.commit_url.should == "https://crucible/changelog/SVN?cs=1101"
260
+ end
261
261
  it "has a list of files" do
262
262
  change.files.first.should == {:name => "/trunk/server/src/main/resources/some-config.ini", :revision => "131"}
263
263
  end
@@ -273,19 +273,16 @@ module Bamboo
273
273
 
274
274
  it "has a list of queued builds when there are queued builds" do
275
275
  http.should_receive(:get).and_return Http::Json::Doc.new(json_fixture("queue_with_queued_builds"))
276
- http.should_receive(:cookies).and_return("some" => "cookie")
277
276
  queue.queued_builds.first.should be_kind_of(Rest::QueuedBuild)
278
277
  end
279
278
 
280
279
  it "has an empty list when there are no queued builds" do
281
280
  http.should_receive(:get).and_return Http::Json::Doc.new(json_fixture("queue_with_no_queued_builds"))
282
- http.should_receive(:cookies).and_return("some" => "cookie")
283
281
  queue.queued_builds.should be_empty
284
282
  end
285
283
 
286
284
  it "can add plan to queue" do
287
- http.should_receive(:cookies).and_return("some" => "cookie")
288
- http.should_receive(:post).with("/rest/api/latest/queue/DEMOPROJECT-CANARY", {}, {"some" => "cookie"}).and_return Http::Json::Doc.new(json_fixture("queued_build"))
285
+ http.should_receive(:post).with("/rest/api/latest/queue/DEMOPROJECT-CANARY", {}).and_return Http::Json::Doc.new(json_fixture("queued_build"))
289
286
  queue.add("DEMOPROJECT-CANARY").should be_kind_of(Rest::QueuedBuild)
290
287
  end
291
288
  end
@@ -6,6 +6,7 @@
6
6
  "expand": "files",
7
7
  "comment": "Fixed the config thing.",
8
8
  "date": "2011-01-20T10:04:47.000+01:00",
9
+ "commitUrl": "https://crucible/changelog/SVN?cs=1101",
9
10
  "files": {
10
11
  "size": 1,
11
12
  "max-result": 1,
@@ -54,6 +54,7 @@
54
54
  "expand": "files",
55
55
  "comment": "Fixed the config thing.",
56
56
  "date": "2011-01-20T10:04:47.000+01:00",
57
+ "commitUrl": "https://crucible/changelog/SVN?cs=1101",
57
58
  "files": {
58
59
  "size": 1,
59
60
  "max-result": 1,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bamboo-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jari Bakken
@@ -9,104 +9,104 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-10-16 00:00:00.000000000 Z
12
+ date: 2014-04-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ~>
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
20
  version: '2.5'
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ~>
25
+ - - "~>"
26
26
  - !ruby/object:Gem::Version
27
27
  version: '2.5'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: cucumber
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - '>='
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: 0.10.0
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - '>='
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: 0.10.0
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: simplecov
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - '>='
46
+ - - ">="
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - '>='
53
+ - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: rake
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - ~>
60
+ - - "~>"
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0.9'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ~>
67
+ - - "~>"
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0.9'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rest-client
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - '>='
74
+ - - ">="
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - '>='
81
+ - - ">="
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: json
86
86
  requirement: !ruby/object:Gem::Requirement
87
87
  requirements:
88
- - - '>='
88
+ - - ">="
89
89
  - !ruby/object:Gem::Version
90
90
  version: '0'
91
91
  type: :runtime
92
92
  prerelease: false
93
93
  version_requirements: !ruby/object:Gem::Requirement
94
94
  requirements:
95
- - - '>='
95
+ - - ">="
96
96
  - !ruby/object:Gem::Version
97
97
  version: '0'
98
98
  - !ruby/object:Gem::Dependency
99
99
  name: nokogiri
100
100
  requirement: !ruby/object:Gem::Requirement
101
101
  requirements:
102
- - - '>='
102
+ - - ">="
103
103
  - !ruby/object:Gem::Version
104
104
  version: '0'
105
105
  type: :runtime
106
106
  prerelease: false
107
107
  version_requirements: !ruby/object:Gem::Requirement
108
108
  requirements:
109
- - - '>='
109
+ - - ">="
110
110
  - !ruby/object:Gem::Version
111
111
  version: '0'
112
112
  description: Ruby client for Atlassian Bamboo's REST APIs
@@ -117,9 +117,9 @@ executables: []
117
117
  extensions: []
118
118
  extra_rdoc_files: []
119
119
  files:
120
- - .gitignore
121
- - .rspec
122
- - .travis.yml
120
+ - ".gitignore"
121
+ - ".rspec"
122
+ - ".travis.yml"
123
123
  - Gemfile
124
124
  - LICENSE
125
125
  - README
@@ -166,17 +166,17 @@ require_paths:
166
166
  - lib
167
167
  required_ruby_version: !ruby/object:Gem::Requirement
168
168
  requirements:
169
- - - '>='
169
+ - - ">="
170
170
  - !ruby/object:Gem::Version
171
171
  version: '0'
172
172
  required_rubygems_version: !ruby/object:Gem::Requirement
173
173
  requirements:
174
- - - '>='
174
+ - - ">="
175
175
  - !ruby/object:Gem::Version
176
176
  version: '0'
177
177
  requirements: []
178
178
  rubyforge_project: bamboo-client
179
- rubygems_version: 2.0.3
179
+ rubygems_version: 2.2.0
180
180
  signing_key:
181
181
  specification_version: 4
182
182
  summary: Ruby client for Atlassian Bamboo's REST APIs
@@ -203,3 +203,4 @@ test_files:
203
203
  - spec/fixtures/result.json
204
204
  - spec/fixtures/result_with_changes.json
205
205
  - spec/spec_helper.rb
206
+ has_rdoc: