duration-formatter 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/duration-formatter-1.0.0.gem +0 -0
- data/lib/duration_formatter/version.rb +1 -1
- data/lib/formatted_duration.rb +9 -9
- data/test/lib/formatted_duration_test.rb +4 -4
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 507104638a4a8b8cf7adb5692c352c021a33275a
|
4
|
+
data.tar.gz: 7f95937db867be224021df525f7b5c2eef7490c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed666090e24594bbb499ce93e2fd000f24950c5e50a8f0de22d37163f37892471936e01257f49dd5a48bbb4cb9b2cab290a9a6e25c62696b5fad82ce6dc9ec85
|
7
|
+
data.tar.gz: 5ea244b725e9334b8af6501122a6b9f42bfd6804b88081873aeedb2a9d8b12cab26142ac5f82ee1c66c4b3b01986ece413d7e7dbd0b7e7660d3e49401338f201
|
data/Gemfile.lock
CHANGED
Binary file
|
data/lib/formatted_duration.rb
CHANGED
@@ -22,22 +22,22 @@ class FormattedDuration
|
|
22
22
|
output << Duration.new(weeks: @weeks).format('%w %~w')
|
23
23
|
end
|
24
24
|
|
25
|
-
if
|
26
|
-
output << Duration.new(days: weekless_days).format('%d %~d')
|
27
|
-
elsif @days > 0 && @constraint == 2
|
25
|
+
if @days > 0 && @constraint == 2
|
28
26
|
output << Duration.new(days: @days).format('%tdu')
|
27
|
+
elsif weekless_days != 0 && @constraint > 1
|
28
|
+
output << Duration.new(days: weekless_days).format('%d %~d')
|
29
29
|
end
|
30
30
|
|
31
|
-
if
|
32
|
-
output << Duration.new(hours: dayless_hours).format('%h %~h')
|
33
|
-
elsif @hours > 0 && @constraint == 1
|
31
|
+
if @hours > 0 && @constraint == 1
|
34
32
|
output << Duration.new(hours: @hours).format('%thu')
|
33
|
+
elsif dayless_hours != 0 && @constraint > 0
|
34
|
+
output << Duration.new(hours: dayless_hours).format('%h %~h')
|
35
35
|
end
|
36
36
|
|
37
|
-
if
|
38
|
-
output << Duration.new(minutes: hourless_minutes).format('%m %~m')
|
39
|
-
elsif @minutes > 0 && @constraint == 0
|
37
|
+
if @minutes > 0 && @constraint == 0
|
40
38
|
output << Duration.new(minutes: @minutes).format('%tmu')
|
39
|
+
elsif hourless_minutes != 0
|
40
|
+
output << Duration.new(minutes: hourless_minutes).format('%m %~m')
|
41
41
|
end
|
42
42
|
|
43
43
|
output.join(', ')
|
@@ -58,8 +58,8 @@ class FormattedDurationTest < Minitest::Test
|
|
58
58
|
# Constraints
|
59
59
|
|
60
60
|
def test_days_constraint
|
61
|
-
text = '
|
62
|
-
output = FormattedDuration.new(
|
61
|
+
text = '8 days'
|
62
|
+
output = FormattedDuration.new(11520, :days).format
|
63
63
|
|
64
64
|
assert_equal text, output
|
65
65
|
end
|
@@ -72,8 +72,8 @@ class FormattedDurationTest < Minitest::Test
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def test_minutes_constraint
|
75
|
-
text = '
|
76
|
-
output = FormattedDuration.new(
|
75
|
+
text = '80 minutes'
|
76
|
+
output = FormattedDuration.new(80, :minutes).format
|
77
77
|
|
78
78
|
assert_equal text, output
|
79
79
|
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.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Venneman
|
@@ -95,6 +95,7 @@ files:
|
|
95
95
|
- Guardfile
|
96
96
|
- README.md
|
97
97
|
- Rakefile
|
98
|
+
- duration-formatter-1.0.0.gem
|
98
99
|
- duration-formatter.gemspec
|
99
100
|
- lib/duration-formatter.rb
|
100
101
|
- lib/duration_formatter/version.rb
|