ampel_extase 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/ampel_extase.gemspec +3 -3
- data/lib/ampel_extase/jenkins_state_observer.rb +2 -0
- data/lib/ampel_extase/jenkins_warning_state_observer.rb +5 -2
- data/lib/ampel_extase/version.rb +1 -1
- data/spec/ampel_extase/jekins_state_observer_spec.rb +2 -2
- data/spec/ampel_extase/jenkins_warning_state_observer_spec.rb +30 -9
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98397c6d3db5a5951ba8eb4b6eadb6a78babbeac
|
4
|
+
data.tar.gz: 366beb6df5bf0b866f4c92888d7587d4204320f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b5db8988d151209942500312d96381605cd6d079627f4fdeef70620f9d70f02a25652c9381db8f0ab5357a739a25c8c50a89421c2119bc2966b91d1d79ea83ea
|
7
|
+
data.tar.gz: 2e8f4244d62306c792f683356773846e5aabc1e76fcf027f8e16f5006d83341f6ac935d909f76cbcb88dd6dfe754da97ecb5e1f028b4b2defdf05da920305cb5
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.1
|
data/ampel_extase.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: ampel_extase 0.5.
|
2
|
+
# stub: ampel_extase 0.5.1 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "ampel_extase"
|
6
|
-
s.version = "0.5.
|
6
|
+
s.version = "0.5.1"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib"]
|
10
10
|
s.authors = ["Florian Frank"]
|
11
|
-
s.date = "2015-08-
|
11
|
+
s.date = "2015-08-31"
|
12
12
|
s.description = "Library to control the build traffic light. Yes, we can\u{2026}"
|
13
13
|
s.email = "flori@ping.de"
|
14
14
|
s.executables = ["ampel_control"]
|
@@ -21,7 +21,6 @@ class AmpelExtase::JenkinsWarningStateObserver
|
|
21
21
|
|
22
22
|
def on_state_change(duration, &block)
|
23
23
|
@observers.each do |observer|
|
24
|
-
observer.expired?(duration) and next
|
25
24
|
observer.on_state_change do |state|
|
26
25
|
if %w[ FAILURE ABORTED ].include?(state.last_result)
|
27
26
|
block.(state)
|
@@ -32,7 +31,11 @@ class AmpelExtase::JenkinsWarningStateObserver
|
|
32
31
|
self
|
33
32
|
end
|
34
33
|
|
34
|
+
def last_state_change
|
35
|
+
@observers.map(&:state_changed_at).max
|
36
|
+
end
|
37
|
+
|
35
38
|
def expired?(duration)
|
36
|
-
|
39
|
+
Time.now - last_state_change > duration
|
37
40
|
end
|
38
41
|
end
|
data/lib/ampel_extase/version.rb
CHANGED
@@ -80,7 +80,7 @@ describe AmpelExtase::JenkinsStateObserver do
|
|
80
80
|
jso
|
81
81
|
end
|
82
82
|
expect(jso.instance_variable_get(:@build_state)).to eq bs_initial
|
83
|
-
expect(jso.
|
83
|
+
expect(jso.state_changed_at).to eq past
|
84
84
|
allow(client).to receive(:fetch_build).with(:last_completed_build).
|
85
85
|
and_return('result' => 'SUCCESS')
|
86
86
|
allow(client).to receive(:fetch_build).with(:last_build).
|
@@ -97,7 +97,7 @@ describe AmpelExtase::JenkinsStateObserver do
|
|
97
97
|
}.to yield_with_args(bs_success)
|
98
98
|
end
|
99
99
|
expect(jso.instance_variable_get(:@build_state)).to eq bs_success
|
100
|
-
expect(jso.
|
100
|
+
expect(jso.state_changed_at).to eq now
|
101
101
|
allow(client).to receive(:fetch_build).with(:last_completed_build).
|
102
102
|
and_return('result' => 'FAILURE')
|
103
103
|
allow(client).to receive(:fetch_build).with(:last_build).
|
@@ -5,8 +5,18 @@ describe AmpelExtase::JenkinsWarningStateObserver do
|
|
5
5
|
described_class.new [ observer ]
|
6
6
|
end
|
7
7
|
|
8
|
+
let :client do
|
9
|
+
double('AmpelExtase::JenkinsClient', url: 'http://foo/bar')
|
10
|
+
end
|
11
|
+
|
8
12
|
let :observer do
|
9
|
-
|
13
|
+
AmpelExtase::JenkinsStateObserver.new client
|
14
|
+
end
|
15
|
+
|
16
|
+
before do
|
17
|
+
allow(client).to receive(:fetch).and_return true
|
18
|
+
allow_any_instance_of(AmpelExtase::JenkinsStateObserver).to receive(:puts)
|
19
|
+
allow_any_instance_of(AmpelExtase::JenkinsClient).to receive(:puts)
|
10
20
|
end
|
11
21
|
|
12
22
|
describe '.for_urls' do
|
@@ -37,23 +47,34 @@ describe AmpelExtase::JenkinsWarningStateObserver do
|
|
37
47
|
AmpelExtase::BuildState.for [ 'FAILURE', true ]
|
38
48
|
end
|
39
49
|
|
40
|
-
it '
|
41
|
-
expect(observer).to receive(:
|
42
|
-
expect(observer).not_to receive(:on_state_change)
|
50
|
+
it 'delegates on_state_change to observers' do
|
51
|
+
expect(observer).to receive(:on_state_change)
|
43
52
|
jenkins_warning_state_observer.on_state_change(666)
|
44
53
|
end
|
45
54
|
|
55
|
+
it 'executes state change action on FAILURE/ABORTED result' do
|
56
|
+
allow(observer).to receive(:fetch_new_state).and_return bs_failure
|
57
|
+
executed = false
|
58
|
+
jenkins_warning_state_observer.on_state_change(666) do
|
59
|
+
executed = true
|
60
|
+
end
|
61
|
+
expect(executed).to eq true
|
62
|
+
end
|
63
|
+
|
46
64
|
it 'skips states where the last result is not FAILURE/ABORTED' do
|
47
|
-
|
48
|
-
|
49
|
-
jenkins_warning_state_observer.on_state_change(666)
|
65
|
+
allow(observer).to receive(:fetch_new_state).and_return bs_success
|
66
|
+
executed = false
|
67
|
+
jenkins_warning_state_observer.on_state_change(666) do
|
68
|
+
executed = true
|
69
|
+
end
|
70
|
+
expect(executed).to eq false
|
50
71
|
end
|
51
72
|
end
|
52
73
|
|
53
74
|
describe '#expired?' do
|
54
75
|
it 'checks if all of its observers are expired' do
|
55
|
-
expect(observer).to receive(:
|
56
|
-
jenkins_warning_state_observer.
|
76
|
+
expect(observer).to receive(:state_changed_at).and_return Time.now - 666
|
77
|
+
expect(jenkins_warning_state_observer).to be_expired(60)
|
57
78
|
end
|
58
79
|
end
|
59
80
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ampel_extase
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: gem_hadar
|