knapsack 0.1.2 → 0.1.3

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: b9c0c3f2c4c9ade9a8b93a9285ae2ec1fef1810f
4
- data.tar.gz: ba827b1b39aa68a0df7052f579d635dc91331700
3
+ metadata.gz: 4e3602511178e7e6b3bb0168469029544f340147
4
+ data.tar.gz: 1fb89b2f440839a87138c1ae76d6da189b3d4543
5
5
  SHA512:
6
- metadata.gz: 210967c7a39fb22ee932848d362b15356173270e62e58cd427fecc9b4d6e732dfee5a4501d4947440d13a134b9a149e38bb160ebf052ef577dfaf24e978a533a
7
- data.tar.gz: 76ad4ccb462dd2e732add681a6db6274b300866fe4ef58266e812914c768ced59e88bbac60d1cf6f7e92a8c0c69ebbb9635d0ffca3d83dd3e71718b6eb60f225
6
+ metadata.gz: 0806c636f359a05c237b87d5b552b685223913fc864ce34681603858b572e6cd033239f1439d22374fdfbe3e0c830376dc03b518947dcfd5b29c9f51fdb429c7
7
+ data.tar.gz: 90d5fdb32e0518574cc2aa1de6ab5d29f7733530e348b0ee34d37f0c560afdb1ee73935c1c0f32b0037c8093361b8d25c2129e93862b87ccc9f63d3fc9168665
@@ -2,6 +2,10 @@
2
2
 
3
3
  * TODO
4
4
 
5
+ ### 0.1.3
6
+
7
+ * Better time presentation instead of seconds.
8
+
5
9
  ### 0.1.2
6
10
 
7
11
  * Fix case when someone removes spec file which exists in knapsack report.
data/TODO.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # TODO
2
2
 
3
- * Add other adapters than RSpec.
3
+ * Add other adapters and rake tasks than RSpec.
4
4
  * Add support for ENV CI node total and CI node index other than CircleCI.
5
5
 
@@ -17,7 +17,8 @@ module Knapsack
17
17
  end
18
18
 
19
19
  def global_time
20
- "\nKnapsack global time execution for specs: #{Knapsack.tracker.global_time}s"
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
- "Max allowed node time execution: #{Knapsack.tracker.max_node_time_execution}s"
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
- "Exceeded time: #{Knapsack.tracker.exceeded_time}s"
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
@@ -1,3 +1,3 @@
1
1
  module Knapsack
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3'
3
3
  end
@@ -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(4.2)
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: 4.2s" }
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: 60s' }
66
- it { should include 'Exceeded time: 3s' }
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.2
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-12 00:00:00.000000000 Z
11
+ date: 2014-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler