human_duration 2.0.1 → 2.0.2
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/.travis.yml +8 -1
- data/CHANGELOG.md +6 -0
- data/example/example.rb +1 -0
- data/lib/human_duration.rb +7 -5
- data/lib/human_duration/constants.rb +2 -0
- data/lib/human_duration/overloads.rb +2 -0
- data/lib/human_duration/version.rb +3 -1
- data/spec/human_duration_spec.rb +2 -0
- data/spec/spec_helper.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 35a2dd7577c089777d6435ea8b027d8e3fe68fe70458736db2142e10a108e665
|
4
|
+
data.tar.gz: 9a5f19a3444966f689afa7dc3bc3e44644545d5dab613b17c16609bdbec7488d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 911fbe7d6c4daa436e8c59846b8e6127716ca631a915bc81d210f3d51fe73d940a00142fc54409c0ccf6ebc42770aa2489175cb8e240a053dfe28d57cea19473
|
7
|
+
data.tar.gz: f382c53f0bb81817bdcc331347de0dd944996b6189bef31c98af7debf2709906078833c4401716df56a0d019072f4950cabce659ce845d04a34776269977ee14
|
data/.travis.yml
CHANGED
@@ -1,23 +1,27 @@
|
|
1
|
-
sudo: required
|
2
1
|
matrix:
|
3
2
|
include:
|
4
3
|
- language: ruby
|
4
|
+
name: "Bundler (rvm 2.4.4 & bundler 1.17.3)"
|
5
5
|
rvm: 2.4.4
|
6
6
|
before_install:
|
7
7
|
- gem install bundler -v 1.17.3
|
8
8
|
- language: ruby
|
9
|
+
name: "Bundler (rvm 2.4.4 & bundler 2.0.1)"
|
9
10
|
rvm: 2.4.4
|
10
11
|
before_install:
|
11
12
|
- gem install bundler -v 2.0.1
|
12
13
|
- language: ruby
|
14
|
+
name: "Bundler (rvm 2.5.3 & bundler 2.0.1)"
|
13
15
|
rvm: 2.5.3
|
14
16
|
before_install:
|
15
17
|
- gem install bundler -v 2.0.1
|
16
18
|
- language: ruby
|
19
|
+
name: "Bundler (rvm 2.6.1 & bundler 2.0.1)"
|
17
20
|
rvm: 2.6.1
|
18
21
|
before_install:
|
19
22
|
- gem install bundler -v 2.0.1
|
20
23
|
- language: ruby
|
24
|
+
name: "Rubocop (rvm 2.4.4)"
|
21
25
|
env: SKIP_INTERPRETER=true
|
22
26
|
rvm: 2.4.4
|
23
27
|
before_install:
|
@@ -27,6 +31,7 @@ matrix:
|
|
27
31
|
script:
|
28
32
|
- ./rubocop-travis/scan.sh
|
29
33
|
- language: ruby
|
34
|
+
name: "Rubocop (rvm 2.5.3)"
|
30
35
|
env: SKIP_INTERPRETER=true
|
31
36
|
rvm: 2.5.3
|
32
37
|
before_install:
|
@@ -36,6 +41,7 @@ matrix:
|
|
36
41
|
script:
|
37
42
|
- ./rubocop-travis/scan.sh
|
38
43
|
- language: ruby
|
44
|
+
name: "Rubocop (rvm 2.6.1)"
|
39
45
|
env: SKIP_INTERPRETER=true
|
40
46
|
rvm: 2.6.1
|
41
47
|
before_install:
|
@@ -45,6 +51,7 @@ matrix:
|
|
45
51
|
script:
|
46
52
|
- ./rubocop-travis/scan.sh
|
47
53
|
- language: ruby
|
54
|
+
name: "Link Checker (rvm 2.6.1)"
|
48
55
|
rvm: 2.6.1
|
49
56
|
before_install:
|
50
57
|
- mkdir travis
|
data/CHANGELOG.md
CHANGED
data/example/example.rb
CHANGED
data/lib/human_duration.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require_relative 'human_duration/constants'
|
2
4
|
require_relative 'human_duration/overloads'
|
3
5
|
require_relative 'human_duration/version'
|
@@ -25,7 +27,7 @@ module HumanDuration
|
|
25
27
|
def self.human_duration(seconds)
|
26
28
|
reset
|
27
29
|
|
28
|
-
return 'negative' if seconds
|
30
|
+
return 'negative' if seconds.negative?
|
29
31
|
return 'now' if seconds.zero?
|
30
32
|
|
31
33
|
split_seconds(seconds)
|
@@ -58,18 +60,18 @@ module HumanDuration
|
|
58
60
|
def self.add_time(value, name, plural = true)
|
59
61
|
return if value < 1 && $type != 'full'
|
60
62
|
|
61
|
-
$output_buffer
|
63
|
+
$output_buffer += if plural
|
62
64
|
format('%<value>s %<name>s%<plural>s', value: value, name: name, plural: pluralize(value))
|
63
65
|
else
|
64
66
|
format('%<value>s %<name>s', value: value, name: name)
|
65
67
|
end
|
66
68
|
$item_count -= 1
|
67
|
-
$output_buffer
|
69
|
+
$output_buffer += comma_or_not($item_count)
|
68
70
|
end
|
69
71
|
|
70
72
|
def self.split_seconds(seconds)
|
71
73
|
SPLIT_TYPES.map do |count, name|
|
72
|
-
if seconds
|
74
|
+
if seconds.positive?
|
73
75
|
seconds, n = seconds.divmod(count)
|
74
76
|
$time_values[name] = n
|
75
77
|
else
|
@@ -80,7 +82,7 @@ module HumanDuration
|
|
80
82
|
|
81
83
|
def self.count_items
|
82
84
|
$time_values.each do |_name, value|
|
83
|
-
$item_count += 1 if value
|
85
|
+
$item_count += 1 if value.positive? || $type == 'full'
|
84
86
|
end
|
85
87
|
end
|
86
88
|
|
data/spec/human_duration_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: human_duration
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Gurney aka Wolf
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|