montrose 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -3
- data/Gemfile +3 -3
- data/Rakefile +1 -0
- data/lib/montrose/clock.rb +2 -1
- data/lib/montrose/frequency.rb +2 -0
- data/lib/montrose/frequency/secondly.rb +9 -0
- data/lib/montrose/options.rb +10 -3
- data/lib/montrose/utils.rb +2 -3
- data/lib/montrose/version.rb +1 -1
- data/montrose.gemspec +5 -5
- metadata +15 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1758f372166c8d12789ce067a940bffb82a236f9
|
4
|
+
data.tar.gz: 33ad0ed697c5466871a45c6c7145d0fa55117773
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b65b6a0746f8bcc4f220fdf644e30cd0808f2ca443fc6186df120978c3998d5f676f31368b1fba3732a16d66f1065e8bff778815976fd0175b4a0410192958dc
|
7
|
+
data.tar.gz: 69a6a474689ef0b837df731add4409acf5d1213cc953eeb736060c6a09230f893955ed0422e5e95e13dcb0b6c91b2609256486c7ecbd7bfe2d55de787b7d126c
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -4,9 +4,9 @@ gemspec
|
|
4
4
|
|
5
5
|
group :development do
|
6
6
|
gem "pry-byebug", platforms: [:ruby_21, :ruby_22, :ruby_23]
|
7
|
-
gem "guard"
|
8
|
-
gem "guard-minitest"
|
9
|
-
gem "guard-rubocop"
|
7
|
+
gem "guard", platforms: [:ruby_22, :ruby_23] # Guard no longer supports ruby 2.1
|
8
|
+
gem "guard-minitest", platforms: [:ruby_22, :ruby_23]
|
9
|
+
gem "guard-rubocop", platforms: [:ruby_22, :ruby_23]
|
10
10
|
gem "yard"
|
11
11
|
gem "coveralls"
|
12
12
|
end
|
data/Rakefile
CHANGED
data/lib/montrose/clock.rb
CHANGED
data/lib/montrose/frequency.rb
CHANGED
@@ -10,6 +10,7 @@ module Montrose
|
|
10
10
|
include Montrose::Rule
|
11
11
|
|
12
12
|
FREQUENCY_TERMS = {
|
13
|
+
"second" => "Secondly",
|
13
14
|
"minute" => "Minutely",
|
14
15
|
"hour" => "Hourly",
|
15
16
|
"day" => "Daily",
|
@@ -59,5 +60,6 @@ require "montrose/frequency/daily"
|
|
59
60
|
require "montrose/frequency/hourly"
|
60
61
|
require "montrose/frequency/minutely"
|
61
62
|
require "montrose/frequency/monthly"
|
63
|
+
require "montrose/frequency/secondly"
|
62
64
|
require "montrose/frequency/weekly"
|
63
65
|
require "montrose/frequency/yearly"
|
data/lib/montrose/options.rb
CHANGED
@@ -308,22 +308,29 @@ module Montrose
|
|
308
308
|
end
|
309
309
|
|
310
310
|
def parse_frequency(input)
|
311
|
-
if input.
|
311
|
+
if input.respond_to?(:parts)
|
312
312
|
frequency, interval = duration_to_frequency_parts(input)
|
313
|
+
{ every: frequency.to_s.singularize.to_sym, interval: interval }
|
314
|
+
elsif input.is_a?(Numeric)
|
315
|
+
frequency, interval = numeric_to_frequency_parts(input)
|
313
316
|
{ every: frequency, interval: interval }
|
314
317
|
else
|
315
318
|
{ every: Frequency.assert(input) }
|
316
319
|
end
|
317
320
|
end
|
318
321
|
|
319
|
-
def
|
322
|
+
def numeric_to_frequency_parts(number)
|
320
323
|
parts = nil
|
321
324
|
[:year, :month, :week, :day, :hour, :minute].each do |freq|
|
322
|
-
div, mod =
|
325
|
+
div, mod = number.divmod(1.send(freq))
|
323
326
|
parts = [freq, div]
|
324
327
|
return parts if mod.zero?
|
325
328
|
end
|
326
329
|
parts
|
327
330
|
end
|
331
|
+
|
332
|
+
def duration_to_frequency_parts(duration)
|
333
|
+
duration.parts.first
|
334
|
+
end
|
328
335
|
end
|
329
336
|
end
|
data/lib/montrose/utils.rb
CHANGED
@@ -13,10 +13,9 @@ module Montrose
|
|
13
13
|
def as_time(time)
|
14
14
|
return nil unless time
|
15
15
|
|
16
|
-
|
17
|
-
when time.is_a?(String)
|
16
|
+
if time.is_a?(String)
|
18
17
|
parse_time(time)
|
19
|
-
|
18
|
+
elsif time.respond_to?(:to_time)
|
20
19
|
time.to_time
|
21
20
|
else
|
22
21
|
Array(time).flat_map { |d| as_time(d) }
|
data/lib/montrose/version.rb
CHANGED
data/montrose.gemspec
CHANGED
@@ -21,12 +21,12 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
spec.required_ruby_version = ">= 2.1.0"
|
23
23
|
|
24
|
-
spec.add_dependency "activesupport"
|
24
|
+
spec.add_dependency "activesupport", "~> 4.0"
|
25
25
|
|
26
|
-
spec.add_development_dependency "bundler", "~> 1.
|
27
|
-
spec.add_development_dependency "rake", "~>
|
28
|
-
spec.add_development_dependency "minitest", "~> 5.
|
26
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
27
|
+
spec.add_development_dependency "rake", "~> 11.0"
|
28
|
+
spec.add_development_dependency "minitest", "~> 5.9"
|
29
29
|
spec.add_development_dependency "m", "~> 1.4"
|
30
|
-
spec.add_development_dependency "rubocop", "~> 0.
|
30
|
+
spec.add_development_dependency "rubocop", "~> 0.41"
|
31
31
|
spec.add_development_dependency "timecop"
|
32
32
|
end
|
metadata
CHANGED
@@ -1,71 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: montrose
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ross Kaffenberger
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04
|
11
|
+
date: 2016-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
19
|
+
version: '4.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
26
|
+
version: '4.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
33
|
+
version: '1.12'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.12'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '11.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '11.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: minitest
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '5.
|
61
|
+
version: '5.9'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '5.
|
68
|
+
version: '5.9'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: m
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0.
|
89
|
+
version: '0.41'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0.
|
96
|
+
version: '0.41'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: timecop
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,6 +142,7 @@ files:
|
|
142
142
|
- lib/montrose/frequency/hourly.rb
|
143
143
|
- lib/montrose/frequency/minutely.rb
|
144
144
|
- lib/montrose/frequency/monthly.rb
|
145
|
+
- lib/montrose/frequency/secondly.rb
|
145
146
|
- lib/montrose/frequency/weekly.rb
|
146
147
|
- lib/montrose/frequency/yearly.rb
|
147
148
|
- lib/montrose/options.rb
|