knapsack 0.1.2 → 0.1.3
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/TODO.md +1 -1
- data/lib/knapsack/presenter.rb +10 -3
- data/lib/knapsack/version.rb +1 -1
- data/spec/knapsack/presenter_spec.rb +33 -4
- 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: 4e3602511178e7e6b3bb0168469029544f340147
|
4
|
+
data.tar.gz: 1fb89b2f440839a87138c1ae76d6da189b3d4543
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0806c636f359a05c237b87d5b552b685223913fc864ce34681603858b572e6cd033239f1439d22374fdfbe3e0c830376dc03b518947dcfd5b29c9f51fdb429c7
|
7
|
+
data.tar.gz: 90d5fdb32e0518574cc2aa1de6ab5d29f7733530e348b0ee34d37f0c560afdb1ee73935c1c0f32b0037c8093361b8d25c2129e93862b87ccc9f63d3fc9168665
|
data/CHANGELOG.md
CHANGED
data/TODO.md
CHANGED
data/lib/knapsack/presenter.rb
CHANGED
@@ -17,7 +17,8 @@ module Knapsack
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def global_time
|
20
|
-
|
20
|
+
global_time = pretty_seconds(Knapsack.tracker.global_time)
|
21
|
+
"\nKnapsack global time execution for specs: #{global_time}"
|
21
22
|
end
|
22
23
|
|
23
24
|
def time_offset
|
@@ -25,11 +26,13 @@ module Knapsack
|
|
25
26
|
end
|
26
27
|
|
27
28
|
def max_allowed_node_time_execution
|
28
|
-
|
29
|
+
max_node_time_execution = pretty_seconds(Knapsack.tracker.max_node_time_execution)
|
30
|
+
"Max allowed node time execution: #{max_node_time_execution}"
|
29
31
|
end
|
30
32
|
|
31
33
|
def exceeded_time
|
32
|
-
|
34
|
+
exceeded_time = pretty_seconds(Knapsack.tracker.exceeded_time)
|
35
|
+
"Exceeded time: #{exceeded_time}"
|
33
36
|
end
|
34
37
|
|
35
38
|
def time_offset_warning
|
@@ -52,6 +55,10 @@ Happy testing!}
|
|
52
55
|
str << "\n=================================================\n"
|
53
56
|
str
|
54
57
|
end
|
58
|
+
|
59
|
+
def pretty_seconds(seconds)
|
60
|
+
Time.at(seconds).gmtime.strftime('%Hh %Mm %Ss').gsub(/00(h|m|s)/, '').strip
|
61
|
+
end
|
55
62
|
end
|
56
63
|
end
|
57
64
|
end
|
data/lib/knapsack/version.rb
CHANGED
@@ -29,10 +29,10 @@ describe Knapsack::Presenter do
|
|
29
29
|
|
30
30
|
before do
|
31
31
|
expect(Knapsack).to receive(:tracker) { tracker }
|
32
|
-
expect(tracker).to receive(:global_time).and_return(
|
32
|
+
expect(tracker).to receive(:global_time).and_return(60*62+3)
|
33
33
|
end
|
34
34
|
|
35
|
-
it { should eql "\nKnapsack global time execution for specs:
|
35
|
+
it { should eql "\nKnapsack global time execution for specs: 01h 02m 03s" }
|
36
36
|
end
|
37
37
|
|
38
38
|
describe '.report_details' do
|
@@ -62,8 +62,8 @@ describe Knapsack::Presenter do
|
|
62
62
|
|
63
63
|
shared_examples 'knapsack time offset warning' do
|
64
64
|
it { should include 'Time offset: 30s' }
|
65
|
-
it { should include 'Max allowed node time execution:
|
66
|
-
it { should include 'Exceeded time:
|
65
|
+
it { should include 'Max allowed node time execution: 01m' }
|
66
|
+
it { should include 'Exceeded time: 03s' }
|
67
67
|
end
|
68
68
|
|
69
69
|
context 'when time exceeded' do
|
@@ -80,4 +80,33 @@ describe Knapsack::Presenter do
|
|
80
80
|
it { should include 'Global time execution for this CI node is fine.' }
|
81
81
|
end
|
82
82
|
end
|
83
|
+
|
84
|
+
describe '.pretty_seconds' do
|
85
|
+
subject { described_class.pretty_seconds(seconds) }
|
86
|
+
|
87
|
+
context 'when only seconds' do
|
88
|
+
let(:seconds) { 5 }
|
89
|
+
it { should eql '05s' }
|
90
|
+
end
|
91
|
+
|
92
|
+
context 'when only minutes' do
|
93
|
+
let(:seconds) { 120 }
|
94
|
+
it { should eql '02m' }
|
95
|
+
end
|
96
|
+
|
97
|
+
context 'when only hours' do
|
98
|
+
let(:seconds) { 60*60*3 }
|
99
|
+
it { should eql '03h' }
|
100
|
+
end
|
101
|
+
|
102
|
+
context 'when minutes and seconds' do
|
103
|
+
let(:seconds) { 180+9 }
|
104
|
+
it { should eql '03m 09s' }
|
105
|
+
end
|
106
|
+
|
107
|
+
context 'when all' do
|
108
|
+
let(:seconds) { 60*60*4+120+7 }
|
109
|
+
it { should eql '04h 02m 07s' }
|
110
|
+
end
|
111
|
+
end
|
83
112
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knapsack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ArturT
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-07-
|
11
|
+
date: 2014-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|