ampel_extase 0.5.1 → 0.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 98397c6d3db5a5951ba8eb4b6eadb6a78babbeac
4
- data.tar.gz: 366beb6df5bf0b866f4c92888d7587d4204320f0
3
+ metadata.gz: 0f658e5e1398b0e1b6e3d07d7b518fd3b2d8f4ec
4
+ data.tar.gz: ccf8b388f855d95651b61a2d282e065e62f40226
5
5
  SHA512:
6
- metadata.gz: b5db8988d151209942500312d96381605cd6d079627f4fdeef70620f9d70f02a25652c9381db8f0ab5357a739a25c8c50a89421c2119bc2966b91d1d79ea83ea
7
- data.tar.gz: 2e8f4244d62306c792f683356773846e5aabc1e76fcf027f8e16f5006d83341f6ac935d909f76cbcb88dd6dfe754da97ecb5e1f028b4b2defdf05da920305cb5
6
+ metadata.gz: 15ae5b5d1d0f71355d32f56b296f487915240f28bee940204fd360e2b2ec9cb0d2515b3e4d91e86724f368bff8d6c7872727e292f076e5a95a3e2a89ac98a373
7
+ data.tar.gz: 7eba9b6d9ac585ccc41193ea1adb2d96e05cf7cedce27da7eebdf3887d67288e9fff72beeabcad0e21c5072734e1821359549c95f80c8515380e9b86ed01663c
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.1
1
+ 0.6.0
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: ampel_extase 0.5.1 ruby lib
2
+ # stub: ampel_extase 0.6.0 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "ampel_extase"
6
- s.version = "0.5.1"
6
+ s.version = "0.6.0"
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"]
@@ -14,6 +14,10 @@ class AmpelExtase::BuildState
14
14
  !!@is_building
15
15
  end
16
16
 
17
+ def success?
18
+ %w[SUCCESS N/A].include? @last_result
19
+ end
20
+
17
21
  def to_a
18
22
  return @last_result, @is_building
19
23
  end
@@ -41,6 +41,8 @@ class AmpelExtase::JenkinsStateObserver
41
41
  self
42
42
  end
43
43
 
44
+ attr_reader :build_state
45
+
44
46
  attr_reader :state_changed_at
45
47
 
46
48
  def fetch_new_state
@@ -31,11 +31,12 @@ class AmpelExtase::JenkinsWarningStateObserver
31
31
  self
32
32
  end
33
33
 
34
- def last_state_change
35
- @observers.map(&:state_changed_at).max
34
+ def last_failure_at
35
+ @observers.reject { |o| o.build_state.success? }.
36
+ map(&:state_changed_at).max || Time.at(0)
36
37
  end
37
38
 
38
39
  def expired?(duration)
39
- Time.now - last_state_change > duration
40
+ Time.now - last_failure_at > duration
40
41
  end
41
42
  end
@@ -1,6 +1,6 @@
1
1
  module AmpelExtase
2
2
  # AmpelExtase version
3
- VERSION = '0.5.1'
3
+ VERSION = '0.6.0'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
@@ -21,18 +21,25 @@ describe AmpelExtase::BuildState do
21
21
  it 'reads N/A as a string' do
22
22
  expect(bs.to_s).to eq 'N/A'
23
23
  end
24
+
25
+ it 'is a success, provisionally' do
26
+ expect(bs).to be_success
27
+ end
24
28
  end
25
29
 
26
- describe 'an intermediate state' do
30
+ describe 'a success state' do
27
31
  let :bs do
28
32
  described_class.for [ 'SUCCESS', true ]
29
33
  end
30
34
 
31
-
32
35
  it 'has SUCCESS as the last result' do
33
36
  expect(bs.last_result).to eq 'SUCCESS'
34
37
  end
35
38
 
39
+ it 'is a success' do
40
+ expect(bs).to be_success
41
+ end
42
+
36
43
  describe 'building' do
37
44
  it 'has a to_a' do
38
45
  expect(bs.to_a).to eq [ 'SUCCESS', true ]
@@ -66,6 +73,16 @@ describe AmpelExtase::BuildState do
66
73
  end
67
74
  end
68
75
 
76
+ describe 'a failed state' do
77
+ let :bs do
78
+ described_class.for [ 'FAILURE', true ]
79
+ end
80
+
81
+ it 'is not a success' do
82
+ expect(bs).not_to be_success
83
+ end
84
+ end
85
+
69
86
  describe 'equality' do
70
87
  it 'can be equal or unequal' do
71
88
  foo_true = described_class.for([ 'FOO', true ])
@@ -75,6 +92,5 @@ describe AmpelExtase::BuildState do
75
92
  expect(foo_true).not_to eq foo_false
76
93
  expect(foo_true).not_to eq bar_true
77
94
  end
78
-
79
95
  end
80
96
  end
@@ -73,9 +73,8 @@ describe AmpelExtase::JenkinsWarningStateObserver do
73
73
 
74
74
  describe '#expired?' do
75
75
  it 'checks if all of its observers are expired' do
76
- expect(observer).to receive(:state_changed_at).and_return Time.now - 666
76
+ expect(jenkins_warning_state_observer).to receive(:last_failure_at).and_return Time.now - 666
77
77
  expect(jenkins_warning_state_observer).to be_expired(60)
78
78
  end
79
79
  end
80
80
  end
81
-
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ampel_extase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank