montrose 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +19 -0
- data/.rubocop.yml +6 -0
- data/.travis.yml +9 -0
- data/Appraisals +4 -0
- data/CHANGELOG.md +21 -1
- data/Gemfile +3 -2
- data/Guardfile +1 -0
- data/README.md +13 -2
- data/Rakefile +1 -0
- data/bin/appraisal +17 -0
- data/gemfiles/activesupport_4.1.gemfile +6 -6
- data/gemfiles/activesupport_4.2.gemfile +6 -6
- data/gemfiles/activesupport_5.0.gemfile +6 -6
- data/gemfiles/activesupport_5.1.gemfile +16 -0
- data/lib/montrose.rb +1 -0
- data/lib/montrose/chainable.rb +1 -0
- data/lib/montrose/clock.rb +1 -0
- data/lib/montrose/errors.rb +1 -0
- data/lib/montrose/frequency.rb +1 -0
- data/lib/montrose/frequency/daily.rb +1 -0
- data/lib/montrose/frequency/hourly.rb +1 -0
- data/lib/montrose/frequency/minutely.rb +1 -0
- data/lib/montrose/frequency/monthly.rb +1 -0
- data/lib/montrose/frequency/secondly.rb +1 -0
- data/lib/montrose/frequency/weekly.rb +1 -0
- data/lib/montrose/frequency/yearly.rb +1 -0
- data/lib/montrose/options.rb +8 -9
- data/lib/montrose/recurrence.rb +12 -2
- data/lib/montrose/refinements/array_concat.rb +1 -0
- data/lib/montrose/rule.rb +4 -2
- data/lib/montrose/rule/after.rb +2 -1
- data/lib/montrose/rule/between.rb +28 -0
- data/lib/montrose/rule/day_of_month.rb +1 -0
- data/lib/montrose/rule/day_of_week.rb +1 -0
- data/lib/montrose/rule/day_of_year.rb +1 -0
- data/lib/montrose/rule/except.rb +1 -0
- data/lib/montrose/rule/hour_of_day.rb +1 -0
- data/lib/montrose/rule/month_of_year.rb +1 -0
- data/lib/montrose/rule/nth_day_matcher.rb +1 -0
- data/lib/montrose/rule/nth_day_of_month.rb +1 -0
- data/lib/montrose/rule/nth_day_of_year.rb +1 -0
- data/lib/montrose/rule/time_of_day.rb +1 -0
- data/lib/montrose/rule/total.rb +6 -5
- data/lib/montrose/rule/until.rb +31 -0
- data/lib/montrose/rule/week_of_year.rb +1 -0
- data/lib/montrose/schedule.rb +1 -0
- data/lib/montrose/stack.rb +4 -2
- data/lib/montrose/utils.rb +1 -0
- data/lib/montrose/version.rb +1 -1
- data/montrose.gemspec +7 -6
- metadata +20 -17
- data/lib/montrose/rule/before.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 177a7778b6014cbf29338af5d999c7214662f15d
|
4
|
+
data.tar.gz: 7a375b6e47b4399277246f490714983b1ce7bf69
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79edb791f61f1bf5b9a4250eaaeee275c81241aa7ddf2312de365726b48977c12b4d51793a6e0027e5d6debb12415dad710bba5cf029f8a5ccf022b12fdfd97a
|
7
|
+
data.tar.gz: c9f41be8ea24bc7f686c91aaf3f842e3ce6e2b39fbacbcbacb0bba4a059e4e70a55a5194a05427b1ae65abb6d493378be68ed795a0674f78e046f05d9592307f
|
data/.codeclimate.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
---
|
2
|
+
engines:
|
3
|
+
bundler-audit:
|
4
|
+
enabled: true
|
5
|
+
duplication:
|
6
|
+
enabled: true
|
7
|
+
config:
|
8
|
+
languages:
|
9
|
+
- ruby
|
10
|
+
fixme:
|
11
|
+
enabled: true
|
12
|
+
rubocop:
|
13
|
+
enabled: true
|
14
|
+
ratings:
|
15
|
+
paths:
|
16
|
+
- Gemfile.lock
|
17
|
+
- "**.rb"
|
18
|
+
exclude_paths:
|
19
|
+
- spec/
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
bundler_args: "--jobs 4 --retry 3"
|
2
2
|
cache: bundler
|
3
3
|
gemfile:
|
4
|
+
- gemfiles/activesupport_5.1.gemfile
|
4
5
|
- gemfiles/activesupport_5.0.gemfile
|
5
6
|
- gemfiles/activesupport_4.2.gemfile
|
6
7
|
- gemfiles/activesupport_4.1.gemfile
|
@@ -9,9 +10,17 @@ matrix:
|
|
9
10
|
exclude:
|
10
11
|
- rvm: 2.1.10
|
11
12
|
gemfile: gemfiles/activesupport_5.0.gemfile # Requires Ruby 2.2+
|
13
|
+
- rvm: 2.1.10
|
14
|
+
gemfile: gemfiles/activesupport_5.1.gemfile # Requires Ruby 2.2+
|
15
|
+
- rvm: 2.4.0
|
16
|
+
gemfile: gemfiles/activesupport_4.1.gemfile # Requires json 1.8.5+
|
12
17
|
fast_finish: true
|
13
18
|
rvm:
|
14
19
|
- 2.1.10
|
15
20
|
- 2.2.6
|
16
21
|
- 2.3.3
|
22
|
+
- 2.4.0
|
17
23
|
sudo: false
|
24
|
+
before_install:
|
25
|
+
- gem update --system
|
26
|
+
- gem --version
|
data/Appraisals
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,24 @@
|
|
1
|
-
### 0.
|
1
|
+
### 0.7.0 - (2017-09-18)
|
2
|
+
|
3
|
+
* enhancements
|
4
|
+
* Adds the :exclude_end option can be used to determine whether :until value
|
5
|
+
is included in the recurrence. Mimics the API to Ruby's Range.
|
6
|
+
* Support activesupport-5.1 (by @fauxparse)
|
7
|
+
* Support ruby-2.4
|
8
|
+
|
9
|
+
* bug fixes
|
10
|
+
* Recurrence#to_json accepts arguments for JSON.dump
|
11
|
+
|
12
|
+
* breaking changes
|
13
|
+
* Previously, the :between option served as a shorthand for :starts to :until.
|
14
|
+
Now, when both :starts and :between are provided, the recurrence will behave
|
15
|
+
as if anchored by the given :starts option, but filtered through the given
|
16
|
+
:betweeen option.
|
17
|
+
* The :exclude_end option changes the default behavior of :until--when the
|
18
|
+
timestamp of the interval matches the :until timestamp, it will be included
|
19
|
+
by default unless the :exclude_end option is set to true.
|
20
|
+
|
21
|
+
### 0.6.0 - (2017-01-05)
|
2
22
|
|
3
23
|
* enhancements
|
4
24
|
* Alias `every` to `frequency`
|
data/Gemfile
CHANGED
@@ -1,12 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
source "https://rubygems.org"
|
2
3
|
|
3
4
|
gemspec
|
4
5
|
|
5
6
|
group :development do
|
6
|
-
gem "
|
7
|
+
gem "coveralls"
|
7
8
|
gem "guard", platforms: [:ruby_22, :ruby_23] # Guard no longer supports ruby 2.1
|
8
9
|
gem "guard-minitest", platforms: [:ruby_22, :ruby_23]
|
9
10
|
gem "guard-rubocop", platforms: [:ruby_22, :ruby_23]
|
11
|
+
gem "pry-byebug", platforms: [:ruby_21, :ruby_22, :ruby_23]
|
10
12
|
gem "yard"
|
11
|
-
gem "coveralls"
|
12
13
|
end
|
data/Guardfile
CHANGED
data/README.md
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# Montrose
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/rossta/montrose.svg?branch=master)](https://travis-ci.org/rossta/montrose)
|
4
|
-
[![Coverage Status](https://coveralls.io/repos/rossta/montrose/badge.svg?branch=master&service=github)](https://coveralls.io/github/rossta/montrose?branch=master)
|
5
4
|
[![Code Climate](https://codeclimate.com/github/rossta/montrose/badges/gpa.svg)](https://codeclimate.com/github/rossta/montrose)
|
5
|
+
[![Coverage Status](https://coveralls.io/repos/rossta/montrose/badge.svg?branch=master&service=github)](https://coveralls.io/github/rossta/montrose?branch=master)
|
6
6
|
[![Dependency Status](https://gemnasium.com/rossta/montrose.svg)](https://gemnasium.com/rossta/montrose)
|
7
7
|
|
8
8
|
Montrose is an easy-to-use library for defining recurring events in Ruby. It uses a simple chaining system for building recurrences, inspired heavily by the design principles of [HTTP.rb](https://github.com/httprb/http) and rule definitions available in [Recurrence](https://github.com/fnando/recurrence).
|
9
9
|
|
10
10
|
* [Introductory blog post](http://bit.ly/1PA68Zb)
|
11
11
|
* [NYC.rb
|
12
|
-
presentation](https://
|
12
|
+
presentation](https://speakerdeck.com/rossta/recurring-events-with-montrose)
|
13
13
|
|
14
14
|
## Installation
|
15
15
|
|
@@ -370,6 +370,17 @@ r.events.take(10).each { |date| puts date.to_s }
|
|
370
370
|
r.events.lazy.select { |time| time > 1.month.from_now }.take(3).each { |date| puts date.to_s }
|
371
371
|
```
|
372
372
|
|
373
|
+
### Ruby on Rails
|
374
|
+
|
375
|
+
Instances of `Montrose::Recurrence` support the ActiveRecord serialization API so recurrence objects can be marshalled to and from a single database column:
|
376
|
+
|
377
|
+
```ruby
|
378
|
+
class RecurringEvent < ApplicationRecord
|
379
|
+
serialize :recurrence, Montrose::Recurrence
|
380
|
+
|
381
|
+
end
|
382
|
+
```
|
383
|
+
|
373
384
|
## Inspiration
|
374
385
|
|
375
386
|
Montrose is named after the beautifully diverse and artistic [neighborhood in Houston, Texas](https://en.wikipedia.org/wiki/Montrose,_Houston).
|
data/Rakefile
CHANGED
data/bin/appraisal
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
#
|
4
|
+
# This file was generated by Bundler.
|
5
|
+
#
|
6
|
+
# The application 'appraisal' is installed as part of a gem, and
|
7
|
+
# this file is here to facilitate running it.
|
8
|
+
#
|
9
|
+
|
10
|
+
require "pathname"
|
11
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
12
|
+
Pathname.new(__FILE__).realpath)
|
13
|
+
|
14
|
+
require "rubygems"
|
15
|
+
require "bundler/setup"
|
16
|
+
|
17
|
+
load Gem.bin_path("appraisal", "appraisal")
|
@@ -5,12 +5,12 @@ source "https://rubygems.org"
|
|
5
5
|
gem "activesupport", "~> 4.1.0"
|
6
6
|
|
7
7
|
group :development do
|
8
|
-
gem "pry-byebug", :platforms => [:ruby_21, :ruby_22, :ruby_23]
|
9
|
-
gem "guard", :platforms => [:ruby_22, :ruby_23]
|
10
|
-
gem "guard-minitest", :platforms => [:ruby_22, :ruby_23]
|
11
|
-
gem "guard-rubocop", :platforms => [:ruby_22, :ruby_23]
|
12
|
-
gem "yard"
|
13
8
|
gem "coveralls"
|
9
|
+
gem "guard", platforms: [:ruby_22, :ruby_23]
|
10
|
+
gem "guard-minitest", platforms: [:ruby_22, :ruby_23]
|
11
|
+
gem "guard-rubocop", platforms: [:ruby_22, :ruby_23]
|
12
|
+
gem "pry-byebug", platforms: [:ruby_21, :ruby_22, :ruby_23]
|
13
|
+
gem "yard"
|
14
14
|
end
|
15
15
|
|
16
|
-
gemspec :
|
16
|
+
gemspec path: "../"
|
@@ -5,12 +5,12 @@ source "https://rubygems.org"
|
|
5
5
|
gem "activesupport", "~> 4.2.0"
|
6
6
|
|
7
7
|
group :development do
|
8
|
-
gem "pry-byebug", :platforms => [:ruby_21, :ruby_22, :ruby_23]
|
9
|
-
gem "guard", :platforms => [:ruby_22, :ruby_23]
|
10
|
-
gem "guard-minitest", :platforms => [:ruby_22, :ruby_23]
|
11
|
-
gem "guard-rubocop", :platforms => [:ruby_22, :ruby_23]
|
12
|
-
gem "yard"
|
13
8
|
gem "coveralls"
|
9
|
+
gem "guard", platforms: [:ruby_22, :ruby_23]
|
10
|
+
gem "guard-minitest", platforms: [:ruby_22, :ruby_23]
|
11
|
+
gem "guard-rubocop", platforms: [:ruby_22, :ruby_23]
|
12
|
+
gem "pry-byebug", platforms: [:ruby_21, :ruby_22, :ruby_23]
|
13
|
+
gem "yard"
|
14
14
|
end
|
15
15
|
|
16
|
-
gemspec :
|
16
|
+
gemspec path: "../"
|
@@ -5,12 +5,12 @@ source "https://rubygems.org"
|
|
5
5
|
gem "activesupport", "~> 5.0.0"
|
6
6
|
|
7
7
|
group :development do
|
8
|
-
gem "pry-byebug", :platforms => [:ruby_21, :ruby_22, :ruby_23]
|
9
|
-
gem "guard", :platforms => [:ruby_22, :ruby_23]
|
10
|
-
gem "guard-minitest", :platforms => [:ruby_22, :ruby_23]
|
11
|
-
gem "guard-rubocop", :platforms => [:ruby_22, :ruby_23]
|
12
|
-
gem "yard"
|
13
8
|
gem "coveralls"
|
9
|
+
gem "guard", platforms: [:ruby_22, :ruby_23]
|
10
|
+
gem "guard-minitest", platforms: [:ruby_22, :ruby_23]
|
11
|
+
gem "guard-rubocop", platforms: [:ruby_22, :ruby_23]
|
12
|
+
gem "pry-byebug", platforms: [:ruby_21, :ruby_22, :ruby_23]
|
13
|
+
gem "yard"
|
14
14
|
end
|
15
15
|
|
16
|
-
gemspec :
|
16
|
+
gemspec path: "../"
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "activesupport", "~> 5.1.0"
|
6
|
+
|
7
|
+
group :development do
|
8
|
+
gem "coveralls"
|
9
|
+
gem "guard", platforms: [:ruby_22, :ruby_23]
|
10
|
+
gem "guard-minitest", platforms: [:ruby_22, :ruby_23]
|
11
|
+
gem "guard-rubocop", platforms: [:ruby_22, :ruby_23]
|
12
|
+
gem "pry-byebug", platforms: [:ruby_21, :ruby_22, :ruby_23]
|
13
|
+
gem "yard"
|
14
|
+
end
|
15
|
+
|
16
|
+
gemspec path: "../"
|
data/lib/montrose.rb
CHANGED
data/lib/montrose/chainable.rb
CHANGED
data/lib/montrose/clock.rb
CHANGED
data/lib/montrose/errors.rb
CHANGED
data/lib/montrose/frequency.rb
CHANGED
data/lib/montrose/options.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Montrose
|
2
3
|
class Options
|
3
4
|
include Montrose::Utils
|
@@ -71,6 +72,7 @@ module Montrose
|
|
71
72
|
def_option :every
|
72
73
|
def_option :starts
|
73
74
|
def_option :until
|
75
|
+
def_option :between
|
74
76
|
def_option :hour
|
75
77
|
def_option :day
|
76
78
|
def_option :mday
|
@@ -82,6 +84,7 @@ module Montrose
|
|
82
84
|
def_option :at
|
83
85
|
def_option :on
|
84
86
|
def_option :except
|
87
|
+
def_option :exclude_end
|
85
88
|
|
86
89
|
def initialize(opts = {})
|
87
90
|
defaults = {
|
@@ -94,7 +97,8 @@ module Montrose
|
|
94
97
|
yday: nil,
|
95
98
|
week: nil,
|
96
99
|
month: nil,
|
97
|
-
total: nil
|
100
|
+
total: nil,
|
101
|
+
exclude_end: nil
|
98
102
|
}
|
99
103
|
|
100
104
|
options = defaults.merge(opts || {})
|
@@ -182,14 +186,9 @@ module Montrose
|
|
182
186
|
end
|
183
187
|
|
184
188
|
def between=(range)
|
185
|
-
|
186
|
-
self[:
|
187
|
-
|
188
|
-
|
189
|
-
def between
|
190
|
-
return nil unless self[:starts] && self[:until]
|
191
|
-
|
192
|
-
(self[:starts]..self[:until])
|
189
|
+
@between = range
|
190
|
+
self[:starts] = range.first unless self[:starts]
|
191
|
+
self[:until] = range.last unless self[:until]
|
193
192
|
end
|
194
193
|
|
195
194
|
def at=(time)
|
data/lib/montrose/recurrence.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require "json"
|
3
|
+
require "yaml"
|
2
4
|
require "montrose/chainable"
|
3
5
|
require "montrose/errors"
|
4
6
|
require "montrose/stack"
|
@@ -310,8 +312,16 @@ module Montrose
|
|
310
312
|
#
|
311
313
|
# @return [String] json of recurrence options
|
312
314
|
#
|
313
|
-
def to_json
|
314
|
-
to_hash
|
315
|
+
def to_json(*args)
|
316
|
+
JSON.dump(to_hash, *args)
|
317
|
+
end
|
318
|
+
|
319
|
+
# Returns options used to create the recurrence in YAML format
|
320
|
+
#
|
321
|
+
# @return [String] YAML-formatted recurrence options
|
322
|
+
#
|
323
|
+
def to_yaml(*args)
|
324
|
+
YAML.dump(to_hash, *args)
|
315
325
|
end
|
316
326
|
|
317
327
|
def inspect
|
data/lib/montrose/rule.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Montrose
|
2
3
|
# Defines the Rule duck type for recurrence rules
|
3
4
|
module Rule
|
@@ -13,7 +14,7 @@ module Montrose
|
|
13
14
|
true
|
14
15
|
end
|
15
16
|
|
16
|
-
def continue?
|
17
|
+
def continue?(_time = nil)
|
17
18
|
true
|
18
19
|
end
|
19
20
|
|
@@ -34,7 +35,7 @@ module Montrose
|
|
34
35
|
end
|
35
36
|
|
36
37
|
require "montrose/rule/after"
|
37
|
-
require "montrose/rule/
|
38
|
+
require "montrose/rule/between"
|
38
39
|
require "montrose/rule/day_of_month"
|
39
40
|
require "montrose/rule/day_of_week"
|
40
41
|
require "montrose/rule/day_of_year"
|
@@ -45,4 +46,5 @@ require "montrose/rule/nth_day_of_month"
|
|
45
46
|
require "montrose/rule/nth_day_of_year"
|
46
47
|
require "montrose/rule/time_of_day"
|
47
48
|
require "montrose/rule/total"
|
49
|
+
require "montrose/rule/until"
|
48
50
|
require "montrose/rule/week_of_year"
|
data/lib/montrose/rule/after.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Montrose
|
3
|
+
module Rule
|
4
|
+
class Between
|
5
|
+
include Montrose::Rule
|
6
|
+
|
7
|
+
def self.apply_options(opts)
|
8
|
+
opts[:between].is_a?(Range) && opts[:between]
|
9
|
+
end
|
10
|
+
|
11
|
+
# Initializes rule
|
12
|
+
#
|
13
|
+
# @param [Range] between - timestamp range
|
14
|
+
#
|
15
|
+
def initialize(between)
|
16
|
+
@between = between
|
17
|
+
end
|
18
|
+
|
19
|
+
def include?(time)
|
20
|
+
@between.cover?(time)
|
21
|
+
end
|
22
|
+
|
23
|
+
def continue?(time)
|
24
|
+
@between.max > time
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/montrose/rule/except.rb
CHANGED
data/lib/montrose/rule/total.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Montrose
|
2
3
|
module Rule
|
3
4
|
class Total
|
@@ -12,16 +13,16 @@ module Montrose
|
|
12
13
|
@count = 0
|
13
14
|
end
|
14
15
|
|
15
|
-
def include?(
|
16
|
-
continue?
|
16
|
+
def include?(time)
|
17
|
+
continue?(time)
|
17
18
|
end
|
18
19
|
|
19
|
-
def advance!(
|
20
|
+
def advance!(time)
|
20
21
|
@count += 1
|
21
|
-
continue?
|
22
|
+
continue?(time)
|
22
23
|
end
|
23
24
|
|
24
|
-
def continue?
|
25
|
+
def continue?(_time)
|
25
26
|
@count <= @max
|
26
27
|
end
|
27
28
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Montrose
|
3
|
+
module Rule
|
4
|
+
class Until
|
5
|
+
include Montrose::Rule
|
6
|
+
|
7
|
+
def self.apply_options(opts)
|
8
|
+
return false unless opts[:until]
|
9
|
+
|
10
|
+
{ until: opts[:until], exclude_end: opts.fetch(:exclude_end, false) }
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(opts)
|
14
|
+
@end_time = opts.fetch(:until)
|
15
|
+
@exclude_end = opts.fetch(:exclude_end)
|
16
|
+
end
|
17
|
+
|
18
|
+
def include?(time)
|
19
|
+
if @exclude_end
|
20
|
+
time < @end_time
|
21
|
+
else
|
22
|
+
time <= @end_time
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def continue?(_time)
|
27
|
+
false
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/montrose/schedule.rb
CHANGED
data/lib/montrose/stack.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
require "montrose/rule"
|
2
3
|
|
3
4
|
module Montrose
|
@@ -10,7 +11,8 @@ module Montrose
|
|
10
11
|
[
|
11
12
|
Frequency,
|
12
13
|
Rule::After,
|
13
|
-
Rule::
|
14
|
+
Rule::Until,
|
15
|
+
Rule::Between,
|
14
16
|
Rule::Except,
|
15
17
|
Rule::Total,
|
16
18
|
Rule::TimeOfDay,
|
@@ -45,7 +47,7 @@ module Montrose
|
|
45
47
|
yield time if block_given?
|
46
48
|
true
|
47
49
|
else
|
48
|
-
no.any?
|
50
|
+
no.any? { |rule| rule.continue?(time) }
|
49
51
|
end
|
50
52
|
end
|
51
53
|
end
|
data/lib/montrose/utils.rb
CHANGED
data/lib/montrose/version.rb
CHANGED
data/montrose.gemspec
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
lib = File.expand_path("../lib", __FILE__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require "montrose/version"
|
@@ -21,13 +22,13 @@ Gem::Specification.new do |spec|
|
|
21
22
|
|
22
23
|
spec.required_ruby_version = ">= 2.1.0"
|
23
24
|
|
24
|
-
spec.add_dependency "activesupport", ">= 4.1", "< 5.
|
25
|
+
spec.add_dependency "activesupport", ">= 4.1", "< 5.2"
|
25
26
|
|
26
|
-
spec.add_development_dependency "bundler", "~> 1.
|
27
|
-
spec.add_development_dependency "appraisal", "~> 2.
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.13"
|
28
|
+
spec.add_development_dependency "appraisal", "~> 2.2.0"
|
28
29
|
spec.add_development_dependency "rake", "~> 11.0"
|
29
|
-
spec.add_development_dependency "minitest", "~> 5.
|
30
|
-
spec.add_development_dependency "m", "~> 1.
|
31
|
-
spec.add_development_dependency "rubocop", "0.
|
30
|
+
spec.add_development_dependency "minitest", "~> 5.10"
|
31
|
+
spec.add_development_dependency "m", "~> 1.5"
|
32
|
+
spec.add_development_dependency "rubocop", "0.46.0"
|
32
33
|
spec.add_development_dependency "timecop"
|
33
34
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: montrose
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ross Kaffenberger
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '4.1'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '5.
|
22
|
+
version: '5.2'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,35 +29,35 @@ dependencies:
|
|
29
29
|
version: '4.1'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '5.
|
32
|
+
version: '5.2'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: bundler
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: '1.
|
39
|
+
version: '1.13'
|
40
40
|
type: :development
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: '1.
|
46
|
+
version: '1.13'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: appraisal
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
51
|
- - "~>"
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 2.
|
53
|
+
version: 2.2.0
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
58
|
- - "~>"
|
59
59
|
- !ruby/object:Gem::Version
|
60
|
-
version: 2.
|
60
|
+
version: 2.2.0
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: rake
|
63
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,42 +78,42 @@ dependencies:
|
|
78
78
|
requirements:
|
79
79
|
- - "~>"
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: '5.
|
81
|
+
version: '5.10'
|
82
82
|
type: :development
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: '5.
|
88
|
+
version: '5.10'
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: m
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
93
|
- - "~>"
|
94
94
|
- !ruby/object:Gem::Version
|
95
|
-
version: '1.
|
95
|
+
version: '1.5'
|
96
96
|
type: :development
|
97
97
|
prerelease: false
|
98
98
|
version_requirements: !ruby/object:Gem::Requirement
|
99
99
|
requirements:
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: '1.
|
102
|
+
version: '1.5'
|
103
103
|
- !ruby/object:Gem::Dependency
|
104
104
|
name: rubocop
|
105
105
|
requirement: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
107
|
- - '='
|
108
108
|
- !ruby/object:Gem::Version
|
109
|
-
version: 0.
|
109
|
+
version: 0.46.0
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
112
|
version_requirements: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
114
|
- - '='
|
115
115
|
- !ruby/object:Gem::Version
|
116
|
-
version: 0.
|
116
|
+
version: 0.46.0
|
117
117
|
- !ruby/object:Gem::Dependency
|
118
118
|
name: timecop
|
119
119
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,6 +136,7 @@ executables: []
|
|
136
136
|
extensions: []
|
137
137
|
extra_rdoc_files: []
|
138
138
|
files:
|
139
|
+
- ".codeclimate.yml"
|
139
140
|
- ".gitignore"
|
140
141
|
- ".rubocop.yml"
|
141
142
|
- ".travis.yml"
|
@@ -148,6 +149,7 @@ files:
|
|
148
149
|
- README.md
|
149
150
|
- Rakefile
|
150
151
|
- bin/_guard-core
|
152
|
+
- bin/appraisal
|
151
153
|
- bin/console
|
152
154
|
- bin/guard
|
153
155
|
- bin/m
|
@@ -157,6 +159,7 @@ files:
|
|
157
159
|
- gemfiles/activesupport_4.1.gemfile
|
158
160
|
- gemfiles/activesupport_4.2.gemfile
|
159
161
|
- gemfiles/activesupport_5.0.gemfile
|
162
|
+
- gemfiles/activesupport_5.1.gemfile
|
160
163
|
- lib/montrose.rb
|
161
164
|
- lib/montrose/chainable.rb
|
162
165
|
- lib/montrose/clock.rb
|
@@ -174,7 +177,7 @@ files:
|
|
174
177
|
- lib/montrose/refinements/array_concat.rb
|
175
178
|
- lib/montrose/rule.rb
|
176
179
|
- lib/montrose/rule/after.rb
|
177
|
-
- lib/montrose/rule/
|
180
|
+
- lib/montrose/rule/between.rb
|
178
181
|
- lib/montrose/rule/day_of_month.rb
|
179
182
|
- lib/montrose/rule/day_of_week.rb
|
180
183
|
- lib/montrose/rule/day_of_year.rb
|
@@ -186,6 +189,7 @@ files:
|
|
186
189
|
- lib/montrose/rule/nth_day_of_year.rb
|
187
190
|
- lib/montrose/rule/time_of_day.rb
|
188
191
|
- lib/montrose/rule/total.rb
|
192
|
+
- lib/montrose/rule/until.rb
|
189
193
|
- lib/montrose/rule/week_of_year.rb
|
190
194
|
- lib/montrose/schedule.rb
|
191
195
|
- lib/montrose/stack.rb
|
@@ -212,9 +216,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
212
216
|
version: '0'
|
213
217
|
requirements: []
|
214
218
|
rubyforge_project:
|
215
|
-
rubygems_version: 2.
|
219
|
+
rubygems_version: 2.5.1
|
216
220
|
signing_key:
|
217
221
|
specification_version: 4
|
218
222
|
summary: Recurring events in Ruby
|
219
223
|
test_files: []
|
220
|
-
has_rdoc:
|
data/lib/montrose/rule/before.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
module Montrose
|
2
|
-
module Rule
|
3
|
-
class Before
|
4
|
-
include Montrose::Rule
|
5
|
-
|
6
|
-
def self.apply_options(opts)
|
7
|
-
opts[:until]
|
8
|
-
end
|
9
|
-
|
10
|
-
def initialize(end_time)
|
11
|
-
@end_time = end_time
|
12
|
-
end
|
13
|
-
|
14
|
-
def include?(time)
|
15
|
-
time < @end_time
|
16
|
-
end
|
17
|
-
|
18
|
-
def continue?
|
19
|
-
false
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|