timing 0.2.6 → 0.2.7

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: b16375eacb664a9fc429038679b0d073c5696a02b6029bd51e502df688853acd
4
- data.tar.gz: df7628ee9e1376f999c733c267b2623bcd9319df9e1443d8d8295036da92c36e
3
+ metadata.gz: 666ee7049eb29d589431eec63fbf54a6e79a75f4ff418e5a3fa13c54cea11ae5
4
+ data.tar.gz: 6e32f64a0c6568637090b038f9d0f30ba936925ede0bb6b18c1168c429e38f14
5
5
  SHA512:
6
- metadata.gz: e53f8ab91e2a795f0c4d271a8303280e48f00d3cb34c8a7133ad893a3386dcb1ef3d0ef03339c47f6dbebbbf166d0cb4867e781ceba7e79dc2eaba585de9cacb
7
- data.tar.gz: 994ee3eb9511f14f5603384e0ca537c72aa333c76001efcee98387e99bd36dc39790e72be46b224f1ec3a9fcf907d5ba37757dff96620af2ebdab31e5dcbb836
6
+ metadata.gz: 0cd864c3df88c5bf92863df0becba24a1dd144797f317d529b2f10cdc880ab4fda53a64f0f664a2c4caf5f62c24419128edefacb75f255c0b2664cbaae26c75a
7
+ data.tar.gz: 20fb404748aa83b1bdd47e0d6c8e5565336d7c0007acaf885095a898a24208e333f6de3b348a68f15fc812e1a8189f3ab68b5da81fe7feded8eafc3681bc1fac
data/README.md CHANGED
@@ -4,7 +4,6 @@
4
4
  [![Build Status](https://travis-ci.org/gabynaiman/timing.svg?branch=master)](https://travis-ci.org/gabynaiman/timing)
5
5
  [![Coverage Status](https://coveralls.io/repos/github/gabynaiman/timing/badge.svg?branch=master)](https://coveralls.io/github/gabynaiman/timing?branch=master)
6
6
  [![Code Climate](https://codeclimate.com/github/gabynaiman/timing.svg)](https://codeclimate.com/github/gabynaiman/timing)
7
- [![Dependency Status](https://gemnasium.com/gabynaiman/timing.svg)](https://gemnasium.com/gabynaiman/timing)
8
7
 
9
8
  Time utils
10
9
 
@@ -70,6 +69,7 @@ Timing::Interval.parse('15m') # => 15m (900.0)
70
69
  Timing::Interval.parse('7h') # => 7h (25200.0)
71
70
  Timing::Interval.parse('5d') # => 5d (432000.0)
72
71
  Timing::Interval.parse('2w') # => 2w (1209600.0)
72
+ Timing::Interval.parse('1m 10s') # => 1m 10s (70.0)
73
73
 
74
74
  interval = Timing::Interval.weeks(1)
75
75
  interval.to_seconds # => 604800.0
@@ -1,12 +1,12 @@
1
1
  module Timing
2
2
  class Interval < TransparentProxy
3
-
3
+
4
4
  UNITS_NAMES = {
5
5
  s: :seconds,
6
6
  m: :minutes,
7
7
  h: :hours,
8
8
  d: :days,
9
- w: :weeks
9
+ w: :weeks
10
10
  }
11
11
 
12
12
  CONVERSIONS = {
@@ -30,9 +30,13 @@ module Timing
30
30
  REGEXP = /^([\d\.]+)([smhdw])$/
31
31
 
32
32
  def self.parse(expression)
33
- match = REGEXP.match expression.strip
34
- raise "Invalid interval expression #{expression}" unless match
35
- new match.captures[0].to_f * CONVERSIONS[match.captures[1].to_sym]
33
+ seconds = expression.split(' ').inject(0) do |total, value|
34
+ match = REGEXP.match value.strip
35
+ raise "Invalid interval expression #{expression}" unless match
36
+ total + match.captures[0].to_f * CONVERSIONS[match.captures[1].to_sym]
37
+ end
38
+
39
+ new seconds
36
40
  end
37
41
 
38
42
  def self.between(time_1, time_2)
@@ -1,3 +1,3 @@
1
1
  module Timing
2
- VERSION = '0.2.6'
2
+ VERSION = '0.2.7'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriel Naiman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-31 00:00:00.000000000 Z
11
+ date: 2020-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: treetop
@@ -208,8 +208,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
208
208
  - !ruby/object:Gem::Version
209
209
  version: '0'
210
210
  requirements: []
211
- rubyforge_project:
212
- rubygems_version: 2.7.3
211
+ rubygems_version: 3.0.6
213
212
  signing_key:
214
213
  specification_version: 4
215
214
  summary: Time utils