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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f8c058b742c804d99d3746ce3c4f449263e52b0fc63d1e9d38e47daebcdf4cc6
4
- data.tar.gz: e49f3c04de61502417b5226ede6f15720f3728269d199a2cff0a8b097a53b72b
3
+ metadata.gz: fe8aaa434da2e0e4c315401e4d6fcd45d4a78221d73fa65c56c6660de700b6be
4
+ data.tar.gz: 7691262188a91f5f1ad2d520cb3c725e1db2dc056331ac9bf99fd744495a9570
5
5
  SHA512:
6
- metadata.gz: deb5cce8a9e77fa73d092c0f6b0edd3a08bf981c1ad501147c168c22a42c273719efcab19284ed6a0b0aefd14dac234fc8996efea34bca0f157f542a7ffc246c
7
- data.tar.gz: '098bb2a16ebfbf291abd62f6395895fbe13714a0176897d697fed665a251dc7015e5ca71273b726c0f457195e0e15fdd42c2429dcadb797a51ba58982c756e23'
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\|Symbol>` | `(:s..:d)` | Unit range to display |
106
- | `empty` | `OnEmpty\|Symbol` | `:skip` | How to handle zero values |
107
- | `zeros` | `OnZero\|Symbol` | `:single` | Zero-padding style |
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\|String\|Proc` | `:ignore` | Negative value handling |
109
+ | `minus` | `OnMinus`, `String` or `Proc` | `:ignore` | Negative value handling |
110
110
 
111
111
  ### Empty Value Handling (`empty`)
112
112
 
@@ -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>
@@ -7,7 +7,7 @@ end
7
7
  # @private
8
8
  module IS::Duration::Info
9
9
  NAME = 'is-duration'
10
- VERSION = '0.8.2'
10
+ VERSION = '0.8.4'
11
11
  SUMMARY = 'Utilities for string representation of durations'
12
12
  AUTHOR = 'Ivan Shikhalev'
13
13
  LICENSE = 'LGPL-3.0-only'
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
- '%2d'
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
- item = case u
168
- when Unit::from(:s .. :h)
169
- Kernel::format fmt2, value
170
- when Unit::from(:ns .. :ms)
171
- Kernel::format fmt3, value
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
- Kernel::format '%d', value
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.2
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