gitlab_chronic_duration 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90ed911722678aa8c57973bd8cf733877d32bd06b0e313764502100bd0e36bf7
4
- data.tar.gz: 5a5afd28caceefa29332d8774a161b811a1340344fdff23a33cd33f7d91aaaea
3
+ metadata.gz: fd977f94bc4ee464a30cfacd01d6253b80257a12954999177ceea000d5062e3c
4
+ data.tar.gz: df6259ba488ea8602b07fde675dda671a4c935e66fba40e394ac7dc958010a1c
5
5
  SHA512:
6
- metadata.gz: '085d3ef7649df9ff93e215b41cea7d77739c415c9295f201a5e005da90c52309d395459bf0543512e729c0feb73a4520d4123d7250191888212f6c12f7f2c0d8'
7
- data.tar.gz: 374eaf5cfee394c835a28bad82214de21a921a4cbc11a99f58844e43b7f240c804f757b941294924927a7b88a33e3925a44c86e6f8defc893c0533e00bc969e2
6
+ metadata.gz: 820338929f8edee97de15fcdc6a3de01f5ea02ab327628c48805f3b02fa4a5a05d168fd75f63843873f3ce078369bdbd2d731fbffa7db0052fcc99765e42b85a
7
+ data.tar.gz: deac822896c3f81c5f776fa1375ed6e23aad9ee27213b1192e863502f9419d56fba805a30f7c276707353dd98a97a8d4e3bd937a8ebf683e87e2a8731a75783b
@@ -1,3 +1,3 @@
1
1
  module ChronicDuration
2
- VERSION = '0.11.0'.freeze
2
+ VERSION = '0.12.0'.freeze
3
3
  end
@@ -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
- use_complete_matcher = opts.fetch(:use_complete_matcher, false)
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, use_complete_matcher = false)
191
+ def cleanup(string)
193
192
  res = string.downcase
194
- res = filter_by_type(Numerizer.numerize(res), use_complete_matcher)
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, use_complete_matcher = false)
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(' ', '') =~ matcher
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
- context 'when using the legacy time matcher' do
275
- it "outputs a duration for #{seconds} that parses back to the same thing when using the #{format} format" do
276
- expect(ChronicDuration.parse(
277
- ChronicDuration.output(seconds, format: format, use_complete_matcher: false)
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.11.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-08-29 00:00:00.000000000 Z
11
+ date: 2023-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: numerizer