gitlab_chronic_duration 0.11.0 → 0.12.0
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/lib/chronic_duration/version.rb +1 -1
- data/lib/gitlab_chronic_duration.rb +5 -7
- data/spec/lib/chronic_duration_spec.rb +4 -14
- 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: fd977f94bc4ee464a30cfacd01d6253b80257a12954999177ceea000d5062e3c
|
4
|
+
data.tar.gz: df6259ba488ea8602b07fde675dda671a4c935e66fba40e394ac7dc958010a1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 820338929f8edee97de15fcdc6a3de01f5ea02ab327628c48805f3b02fa4a5a05d168fd75f63843873f3ce078369bdbd2d731fbffa7db0052fcc99765e42b85a
|
7
|
+
data.tar.gz: deac822896c3f81c5f776fa1375ed6e23aad9ee27213b1192e863502f9419d56fba805a30f7c276707353dd98a97a8d4e3bd937a8ebf683e87e2a8731a75783b
|
@@ -46,8 +46,7 @@ module ChronicDuration
|
|
46
46
|
# return an integer (or float, if fractions of a
|
47
47
|
# second are input)
|
48
48
|
def parse(string, opts = {})
|
49
|
-
|
50
|
-
result = calculate_from_words(cleanup(string, use_complete_matcher), opts)
|
49
|
+
result = calculate_from_words(cleanup(string), opts)
|
51
50
|
(!opts[:keep_zero] and result == 0) ? nil : result
|
52
51
|
end
|
53
52
|
|
@@ -189,9 +188,9 @@ private
|
|
189
188
|
val
|
190
189
|
end
|
191
190
|
|
192
|
-
def cleanup(string
|
191
|
+
def cleanup(string)
|
193
192
|
res = string.downcase
|
194
|
-
res = filter_by_type(Numerizer.numerize(res)
|
193
|
+
res = filter_by_type(Numerizer.numerize(res))
|
195
194
|
res = res.gsub(float_matcher) {|n| " #{n} "}.squeeze(' ').strip
|
196
195
|
res = filter_through_white_list(res)
|
197
196
|
end
|
@@ -223,11 +222,10 @@ private
|
|
223
222
|
end
|
224
223
|
|
225
224
|
# Parse 3:41:59 and return 3 hours 41 minutes 59 seconds
|
226
|
-
def filter_by_type(string
|
225
|
+
def filter_by_type(string)
|
227
226
|
chrono_units_list = duration_units_list.reject {|v| v == "weeks"}
|
228
|
-
matcher = use_complete_matcher ? time_matcher : /#{float_matcher}(:#{float_matcher})+/
|
229
227
|
|
230
|
-
if string.gsub(' ', '') =~
|
228
|
+
if string.gsub(' ', '') =~ time_matcher
|
231
229
|
res = []
|
232
230
|
string.gsub(' ', '').split(':').reverse.each_with_index do |v,k|
|
233
231
|
return unless chrono_units_list[k]
|
@@ -271,20 +271,10 @@ describe ChronicDuration do
|
|
271
271
|
|
272
272
|
@exemplars.each do |seconds, format_spec|
|
273
273
|
format_spec.each do |format, _|
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
)).to eq(seconds)
|
279
|
-
end
|
280
|
-
end
|
281
|
-
|
282
|
-
context 'when using the new time matcher' do
|
283
|
-
it "outputs a duration for #{seconds} that parses back to the same thing when using the #{format} format" do
|
284
|
-
expect(ChronicDuration.parse(
|
285
|
-
ChronicDuration.output(seconds, format: format, use_complete_matcher: true)
|
286
|
-
)).to eq(seconds)
|
287
|
-
end
|
274
|
+
it "outputs a duration for #{seconds} that parses back to the same thing when using the #{format} format" do
|
275
|
+
expect(ChronicDuration.parse(
|
276
|
+
ChronicDuration.output(seconds, format: format, use_complete_matcher: true)
|
277
|
+
)).to eq(seconds)
|
288
278
|
end
|
289
279
|
end
|
290
280
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitlab_chronic_duration
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- hpoydar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: numerizer
|