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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 860d9ff5e15a0ab0bf99a0882c367d79629ebc8f
4
- data.tar.gz: 4366bbc4218a7f42f53f2b71e4cf42a12c2b53b4
3
+ metadata.gz: 1758f372166c8d12789ce067a940bffb82a236f9
4
+ data.tar.gz: 33ad0ed697c5466871a45c6c7145d0fa55117773
5
5
  SHA512:
6
- metadata.gz: a970bd59b217242a61e1c6dd485b8577537c60b0ed0f56dcaf2d274f52ec1f781ba239f8269a11eb3ff8df55c8dacb6a606e223883e3c2977ffb44e354cbbe38
7
- data.tar.gz: 04c563a8c68abd4480232873c9629b802fccfae66b25b477bbb82ed19ae855bb3665ecef2914497c5ec6f2579ef43cc9cc7c7875bb88060ff5e05ee74171e557
6
+ metadata.gz: b65b6a0746f8bcc4f220fdf644e30cd0808f2ca443fc6186df120978c3998d5f676f31368b1fba3732a16d66f1065e8bff778815976fd0175b4a0410192958dc
7
+ data.tar.gz: 69a6a474689ef0b837df731add4409acf5d1213cc953eeb736060c6a09230f893955ed0422e5e95e13dcb0b6c91b2609256486c7ecbd7bfe2d55de787b7d126c
@@ -1,6 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1
4
- - 2.2
5
- - 2.3.0
3
+ - 2.1.10
4
+ - 2.2.5
5
+ - 2.3.1
6
6
  before_install: gem install bundler -v 1.11.2
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
@@ -8,6 +8,7 @@ Rake::TestTask.new(:spec) do |t|
8
8
  t.libs << "spec"
9
9
  t.libs << "lib"
10
10
  t.test_files = FileList["spec/**/*_spec.rb"]
11
+ t.warning = false
11
12
  end
12
13
 
13
14
  task test: :spec
@@ -43,7 +43,8 @@ module Montrose
43
43
  end
44
44
 
45
45
  def smallest_step
46
- unit_step(:minute) ||
46
+ unit_step(:second) ||
47
+ unit_step(:minute) ||
47
48
  unit_step(:hour) ||
48
49
  unit_step(:day, :mday, :yday) ||
49
50
  unit_step(:week) ||
@@ -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"
@@ -0,0 +1,9 @@
1
+ module Montrose
2
+ class Frequency
3
+ class Secondly < Frequency
4
+ def include?(time)
5
+ matches_interval?((time - @starts) / 1.second)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -308,22 +308,29 @@ module Montrose
308
308
  end
309
309
 
310
310
  def parse_frequency(input)
311
- if input.is_a?(Numeric)
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 duration_to_frequency_parts(duration)
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 = duration.divmod(1.send(freq))
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
@@ -13,10 +13,9 @@ module Montrose
13
13
  def as_time(time)
14
14
  return nil unless time
15
15
 
16
- case
17
- when time.is_a?(String)
16
+ if time.is_a?(String)
18
17
  parse_time(time)
19
- when time.respond_to?(:to_time)
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) }
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Montrose
3
- VERSION = "0.4.0".freeze
3
+ VERSION = "0.4.1".freeze
4
4
  end
@@ -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.10"
27
- spec.add_development_dependency "rake", "~> 10.0"
28
- spec.add_development_dependency "minitest", "~> 5.8"
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.36"
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.0
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-20 00:00:00.000000000 Z
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.10'
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.10'
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: '10.0'
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: '10.0'
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.8'
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.8'
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.36'
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.36'
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