knapsack 0.1.3 → 0.1.4

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: 4e3602511178e7e6b3bb0168469029544f340147
4
- data.tar.gz: 1fb89b2f440839a87138c1ae76d6da189b3d4543
3
+ metadata.gz: 53cb2c59c972a7fe5a858ced2695d4bd6bf76631
4
+ data.tar.gz: d8c1d8bca8a3389d2da75e2e046a91b00621f504
5
5
  SHA512:
6
- metadata.gz: 0806c636f359a05c237b87d5b552b685223913fc864ce34681603858b572e6cd033239f1439d22374fdfbe3e0c830376dc03b518947dcfd5b29c9f51fdb429c7
7
- data.tar.gz: 90d5fdb32e0518574cc2aa1de6ab5d29f7733530e348b0ee34d37f0c560afdb1ee73935c1c0f32b0037c8093361b8d25c2129e93862b87ccc9f63d3fc9168665
6
+ metadata.gz: 29732cd69e2577317468c48d74543c50d2c811696d785aac4361f1863d1e64a796aa41e65c740cc825061a89991a5bff61fec751ffc0b7d61de941a1e43eabe4
7
+ data.tar.gz: c5ac456de00a76758094d53f1cdd412e3b836040c208956b5b55e3adc6ffdf9fca09bd673e74157b144a73801a749bf8450aacab848673dff5a126e588760ad1
@@ -2,6 +2,10 @@
2
2
 
3
3
  * TODO
4
4
 
5
+ ### 0.1.4
6
+
7
+ * Fix wrong time presentation for negative seconds.
8
+
5
9
  ### 0.1.3
6
10
 
7
11
  * Better time presentation instead of seconds.
@@ -57,7 +57,14 @@ Happy testing!}
57
57
  end
58
58
 
59
59
  def pretty_seconds(seconds)
60
- Time.at(seconds).gmtime.strftime('%Hh %Mm %Ss').gsub(/00(h|m|s)/, '').strip
60
+ sign = ''
61
+ if seconds < 0
62
+ seconds = seconds*-1
63
+ sign = '-'
64
+ end
65
+ time = Time.at(seconds).gmtime.strftime('%Hh %Mm %Ss')
66
+ time_without_zeros = time.gsub(/00(h|m|s)/, '').strip
67
+ sign + time_without_zeros
61
68
  end
62
69
  end
63
70
  end
@@ -1,3 +1,3 @@
1
1
  module Knapsack
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
@@ -108,5 +108,10 @@ describe Knapsack::Presenter do
108
108
  let(:seconds) { 60*60*4+120+7 }
109
109
  it { should eql '04h 02m 07s' }
110
110
  end
111
+
112
+ context 'when negative seconds' do
113
+ let(:seconds) { -67 }
114
+ it { should eql '-01m 07s' }
115
+ end
111
116
  end
112
117
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knapsack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - ArturT