is-duration 0.8.2 → 0.8.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 +4 -4
- data/README.md +4 -4
- data/coverage-badge.svg +6 -0
- data/lib/is-duration/info.rb +1 -1
- data/lib/is-duration.rb +11 -7
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fe8aaa434da2e0e4c315401e4d6fcd45d4a78221d73fa65c56c6660de700b6be
|
|
4
|
+
data.tar.gz: 7691262188a91f5f1ad2d520cb3c725e1db2dc056331ac9bf99fd744495a9570
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d99455021df22cc6b471136011866cfd6f40759fd6ac69c59854ca3ffe8b9d28c59dbba3053e640341784372a391035c2ca1234563f2b32e8f45562b10c38739
|
|
7
|
+
data.tar.gz: 3bf9661ea01342fb8f6980a2effa9cbe30a4ff648772134d590fc2901c4ef214a7b2f75d336cba511167a59f0f6228d745bee88902370e6d531630f337462c03
|
data/README.md
CHANGED
|
@@ -102,11 +102,11 @@ IS::Duration.format(3661) # => "1h1m1s" (default: seconds to days)
|
|
|
102
102
|
|
|
103
103
|
| Option | Type | Default | Description |
|
|
104
104
|
|--------|------|---------|-------------|
|
|
105
|
-
| `units` | `Range<Unit
|
|
106
|
-
| `empty` | `OnEmpty
|
|
107
|
-
| `zeros` | `OnZero
|
|
105
|
+
| `units` | `Range<Unit` or `Symbol>` | `(:s..:d)` | Unit range to display |
|
|
106
|
+
| `empty` | `OnEmpty` or `Symbol` | `:skip` | How to handle zero values |
|
|
107
|
+
| `zeros` | `OnZero` or `Symbol` | `:single` | Zero-padding style |
|
|
108
108
|
| `delim` | `String` | `""` | Delimiter between components |
|
|
109
|
-
| `minus` | `OnMinus
|
|
109
|
+
| `minus` | `OnMinus`, `String` or `Proc` | `:ignore` | Negative value handling |
|
|
110
110
|
|
|
111
111
|
### Empty Value Handling (`empty`)
|
|
112
112
|
|
data/coverage-badge.svg
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<?xml version="1.0"?><svg xmlns="http://www.w3.org/2000/svg" width="100" height="20">
|
|
2
|
+
<rect width="100" height="20" fill="#555"/>
|
|
3
|
+
<rect x="63" width="37" height="20" fill="green"/>
|
|
4
|
+
<text x="8" y="14" fill="#fff" font-family="Verdana" font-size="11">coverage</text>
|
|
5
|
+
<text x="66" y="14" fill="#fff" font-family="Verdana" font-size="11">91%</text>
|
|
6
|
+
</svg>
|
data/lib/is-duration/info.rb
CHANGED
data/lib/is-duration.rb
CHANGED
|
@@ -154,7 +154,7 @@ module IS::Duration
|
|
|
154
154
|
when OnZero::fill
|
|
155
155
|
'%03d'
|
|
156
156
|
when OnZero::align
|
|
157
|
-
'%
|
|
157
|
+
'%3d'
|
|
158
158
|
else
|
|
159
159
|
'%d'
|
|
160
160
|
end
|
|
@@ -163,16 +163,20 @@ module IS::Duration
|
|
|
163
163
|
units_array.each do |u|
|
|
164
164
|
value = map[u]
|
|
165
165
|
next if value == 0 && (empty == OnEmpty::skip || (empty == OnEmpty::minor && !started))
|
|
166
|
+
first = true if !started
|
|
166
167
|
started = true
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
168
|
+
fmt = if first
|
|
169
|
+
'%d'
|
|
170
|
+
elsif Unit::from(:s..:h) === u
|
|
171
|
+
fmt2
|
|
172
|
+
elsif Unit::from(:ns..:ms) === u
|
|
173
|
+
fmt3
|
|
172
174
|
else
|
|
173
|
-
|
|
175
|
+
'%d'
|
|
174
176
|
end
|
|
177
|
+
item = Kernel::format fmt, value
|
|
175
178
|
result << item + u.to_s
|
|
179
|
+
first = false
|
|
176
180
|
end
|
|
177
181
|
result = result.join(delim).strip
|
|
178
182
|
if sgn < 0
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: is-duration
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Ivan Shikhalev
|
|
@@ -113,6 +113,7 @@ extra_rdoc_files: []
|
|
|
113
113
|
files:
|
|
114
114
|
- LICENSE
|
|
115
115
|
- README.md
|
|
116
|
+
- coverage-badge.svg
|
|
116
117
|
- lib/is-duration.rb
|
|
117
118
|
- lib/is-duration/info.rb
|
|
118
119
|
homepage: https://github.com/inat-get/is-duration
|