backstop-deploys 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/backstop-deploys/version.rb +1 -1
- data/lib/backstop-deploys/web.rb +6 -5
- data/spec/backstop-deploys/web_spec.rb +4 -4
- metadata +13 -13
data/lib/backstop-deploys/web.rb
CHANGED
@@ -28,24 +28,25 @@ module Backstop
|
|
28
28
|
data = nil
|
29
29
|
|
30
30
|
begin
|
31
|
-
json = RestClient.get "#{api_endpoint}/annotations/deploys
|
31
|
+
json = RestClient.get "#{api_endpoint}/annotations/deploys?sources[]=#{source}&start_time=#{start_time}"
|
32
32
|
data = JSON.parse(json)
|
33
33
|
rescue RestClient::ResourceNotFound
|
34
34
|
stream_exists = false
|
35
35
|
end
|
36
36
|
|
37
|
-
if stream_exists and events = data['events']
|
37
|
+
if stream_exists and events = data['events'][source]
|
38
38
|
# events already exists, we just need to update
|
39
|
-
event = events
|
39
|
+
event = events.first
|
40
40
|
event_id = event['id']
|
41
41
|
payload = { :title => "#{app}.#{version}" }
|
42
42
|
payload[:end_time] = params[:end_time] if params[:end_time]
|
43
43
|
RestClient.put "#{api_endpoint}/annotations/deploys/#{event_id}", payload
|
44
44
|
else
|
45
45
|
# new event needs to be created
|
46
|
-
payload = { :start_time => start_time, :title => "#{app}.#{version}" }
|
46
|
+
payload = { :start_time => start_time, :title => "#{app}.#{version}", :source => source }
|
47
47
|
payload[:end_time] = end_time if end_time
|
48
|
-
|
48
|
+
q = payload.map { |k,v| "#{k}=#{v}" }.sort.join("&")
|
49
|
+
RestClient.post "#{api_endpoint}/annotations/deploys", q
|
49
50
|
end
|
50
51
|
end
|
51
52
|
end
|
@@ -31,7 +31,7 @@ describe Backstop::Deploys::Web do
|
|
31
31
|
context 'existing annotation' do
|
32
32
|
let(:event_id) { 12345 }
|
33
33
|
let(:stub_events) { [{:title => title, :source => source, :start_time => t.to_i, :id => event_id}] }
|
34
|
-
let(:stub_get_existing_body) { {:name => 'deploys', :events =>
|
34
|
+
let(:stub_get_existing_body) { {:name => 'deploys', :events => {source => stub_events}} }
|
35
35
|
let(:stub_get_existing_request) { stub_request(:get, "#{api_endpoint}/annotations/deploys").with(:query => { :sources => [source], :start_time => t.to_i }).to_return(:body => stub_get_existing_body.to_json)}
|
36
36
|
let(:stub_update_request) { stub_request(:put, "#{api_endpoint}/annotations/deploys/#{event_id}").with(:body => {:title => title}) }
|
37
37
|
before(:each) do
|
@@ -46,7 +46,7 @@ describe Backstop::Deploys::Web do
|
|
46
46
|
|
47
47
|
context 'non-existent annotation stream' do
|
48
48
|
let(:stub_missing_stream) { stub_request(:get, "#{api_endpoint}/annotations/deploys").with(:query => { :sources => [source], :start_time => t.to_i }).to_return(:status => 404) }
|
49
|
-
let(:stub_new_request) { stub_request(:post, "#{api_endpoint}/annotations/deploys").with(:body => "
|
49
|
+
let(:stub_new_request) { stub_request(:post, "#{api_endpoint}/annotations/deploys").with(:body => "source=#{source}&start_time=#{t.to_i}&title=#{title}") }
|
50
50
|
before(:each) do
|
51
51
|
stub_missing_stream
|
52
52
|
stub_new_request
|
@@ -58,9 +58,9 @@ describe Backstop::Deploys::Web do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
context 'non-existent annotation' do
|
61
|
-
let(:stub_get_missing_body) { {:name => 'deploys', :events =>
|
61
|
+
let(:stub_get_missing_body) { {:name => 'deploys', :events => {}} }
|
62
62
|
let(:stub_get_missing_request) { stub_request(:get, "#{api_endpoint}/annotations/deploys").with(:query => { :sources => [source], :start_time => t.to_i }).to_return(:body => stub_get_missing_body.to_json)}
|
63
|
-
let(:stub_new_request) { stub_request(:post, "#{api_endpoint}/annotations/deploys").with(:body => "
|
63
|
+
let(:stub_new_request) { stub_request(:post, "#{api_endpoint}/annotations/deploys").with(:body => "source=#{source}&start_time=#{t.to_i}&title=#{title}") }
|
64
64
|
before(:each) do
|
65
65
|
stub_get_missing_request
|
66
66
|
stub_new_request
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: backstop-deploys
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-10-18 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rack-test
|
16
|
-
requirement: &
|
16
|
+
requirement: &70282066218840 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70282066218840
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70282066217880 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70282066217880
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rspec
|
38
|
-
requirement: &
|
38
|
+
requirement: &70282066217260 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70282066217260
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: webmock
|
49
|
-
requirement: &
|
49
|
+
requirement: &70282066216820 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70282066216820
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rest-client
|
60
|
-
requirement: &
|
60
|
+
requirement: &70282066216280 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :runtime
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70282066216280
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: sinatra
|
71
|
-
requirement: &
|
71
|
+
requirement: &70282066215580 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,7 +76,7 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70282066215580
|
80
80
|
description: An extension to backstop to allow submission to Librato Metrics
|
81
81
|
email:
|
82
82
|
- michael.gorsuch@gmail.com
|