duration-formatter 1.2.0 → 1.2.1

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: d7e09efaf9e97304ec46ee26493ab16e2f7d6c55
4
- data.tar.gz: 1b4d5d142340debdb646d1b135db0b66ebcb14b9
3
+ metadata.gz: df4d194657d59865ae0d44290263010138427489
4
+ data.tar.gz: f34c0b4ad810fcf299d7e7bb763b004b5c14576c
5
5
  SHA512:
6
- metadata.gz: 36c3a9b63bf0fba1aa0f01a85b3131d71ac189a60eae37eb1e9b45dd3d647199f8a4ae104b192c01bff11f05fe3066fb705ed484e3a4fbe3cc07aa429540d12f
7
- data.tar.gz: c1ee518358905e5e5b25d6131b5e197e7b88543c3f3f84d1139cfd682fc98d5e61f13494fac8834a3ee1a0e7f76307360f8afbee6c43fb73f0884eede8a9da0a
6
+ metadata.gz: f8d825ca8858478a595d726f5549124ea73ba26fb011b3e3e36a3efc597e932fdc10701e0b3f2bd2f53d60d0843d4818bd9e5189d52fac2b5e3b474546917d32
7
+ data.tar.gz: a0b8929d9e5d3403c7ff4bfc53f7ca2d290e19fad216d0ada0ef22f4598cbace0b5d919423e8233a4a9eeff6b470d99c53f170b541e885ae29696ce3800121c2
@@ -1,3 +1,3 @@
1
1
  module DurationFormatter
2
- VERSION = '1.2.0'
2
+ VERSION = '1.2.1'
3
3
  end
@@ -16,7 +16,7 @@ class FormattedDuration
16
16
  end
17
17
 
18
18
  def format
19
- append(:weeks, @weeks, '%w %~w') if @weeks.positive? && @constraint > 2
19
+ append(:weeks, @weeks, '%w %~w') if @weeks > 0 && @constraint > 2
20
20
  add(:days, @days, 2)
21
21
  add(:hours, @hours, 1)
22
22
  add(:minutes, @minutes, 0)
@@ -34,9 +34,9 @@ class FormattedDuration
34
34
  def add(unit, value, constraint)
35
35
  bare = value % BARE[unit]
36
36
 
37
- if value.positive? && @constraint == constraint
37
+ if value > 0 && @constraint == constraint
38
38
  append(unit, value, FORMATS[unit])
39
- elsif bare.positive? && @constraint > constraint - 1
39
+ elsif bare > 0 && @constraint > constraint - 1
40
40
  append(unit, bare, BARE_FORMATS[unit])
41
41
  end
42
42
  end
@@ -6,7 +6,7 @@ class FormattedDurationTest < Minitest::Test
6
6
 
7
7
  def test_weeks_only_duration
8
8
  text = '1 week'
9
- output = FormattedDuration.new(100_80).format
9
+ output = FormattedDuration.new(10080).format
10
10
 
11
11
  assert_equal text, output
12
12
  end
@@ -36,7 +36,7 @@ class FormattedDurationTest < Minitest::Test
36
36
 
37
37
  def test_weeks_and_days_duration
38
38
  text = '1 week, 4 days'
39
- output = FormattedDuration.new(158_40).format
39
+ output = FormattedDuration.new(15840).format
40
40
 
41
41
  assert_equal text, output
42
42
  end
@@ -59,7 +59,7 @@ class FormattedDurationTest < Minitest::Test
59
59
 
60
60
  def test_days_constraint
61
61
  text = '8 days'
62
- output = FormattedDuration.new(115_20, :days).format
62
+ output = FormattedDuration.new(11520, :days).format
63
63
 
64
64
  assert_equal text, output
65
65
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duration-formatter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Venneman