montrose 0.1.0 → 0.1.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 +2 -1
- data/Gemfile +1 -1
- data/README.md +142 -55
- data/lib/montrose/chainable.rb +24 -13
- data/lib/montrose/options.rb +28 -9
- data/lib/montrose/recurrence.rb +5 -0
- data/lib/montrose/rule/nth_day_matcher.rb +2 -0
- data/lib/montrose/utils.rb +22 -16
- data/lib/montrose/version.rb +2 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98eedcb18d91e3390bc4bf1e9962e2ddd4a596a3
|
4
|
+
data.tar.gz: 3a43325e390bd795c81a5ee6246a413542a59509
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6983022b0d6ba0aebc265c311362a5e24f6dba4a19d7334d198b0eb49b91161ddfc92276c1edb636d7d6e03bfb0039d41a8a72805932fa22e37917ac5a57676d
|
7
|
+
data.tar.gz: 1264cd660fc3e6fff55485a7a273961147188935a0b22b162090ca63a9293f7a82d54459b04f7a69009aa797c9c73090ac44e7c4779c00207b3473415d52219f
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -5,10 +5,7 @@
|
|
5
5
|
[![Code Climate](https://codeclimate.com/github/rossta/montrose/badges/gpa.svg)](https://codeclimate.com/github/rossta/montrose)
|
6
6
|
[![Dependency Status](https://gemnasium.com/rossta/montrose.svg)](https://gemnasium.com/rossta/montrose)
|
7
7
|
|
8
|
-
Recurring events in Ruby.
|
9
|
-
|
10
|
-
This library is currently under development. Most of the functionality does not
|
11
|
-
exist yet.
|
8
|
+
Recurring events in Ruby. This library is still a work-in-progress.
|
12
9
|
|
13
10
|
## Installation
|
14
11
|
|
@@ -31,6 +28,120 @@ Or install it yourself as:
|
|
31
28
|
```ruby
|
32
29
|
require "montrose"
|
33
30
|
|
31
|
+
# daily for 10 occurrences
|
32
|
+
Montrose.daily(total: 10)
|
33
|
+
|
34
|
+
# daily until December 23, 2015
|
35
|
+
starts = Date.new(2015, 1, 1)
|
36
|
+
ends = Date.new(2015, 12, 23)
|
37
|
+
Montrose.daily(starts: starts, until: ends)
|
38
|
+
|
39
|
+
# every other day forever
|
40
|
+
Montrose.daily(interval: 2)
|
41
|
+
|
42
|
+
# every 10 days 5 occurrences
|
43
|
+
Montrose.every(10.days, total: 5)
|
44
|
+
|
45
|
+
# everyday in January for 3 years
|
46
|
+
starts = Time.now.beginning_of_year
|
47
|
+
ends = Time.now.end_of_year + 2.years
|
48
|
+
Montrose.daily(month: :january, between: starts...ends)
|
49
|
+
|
50
|
+
# weekly for 10 occurrences
|
51
|
+
Montrose.weekly(total: 10)
|
52
|
+
|
53
|
+
# weekly until December 23, 2015
|
54
|
+
ends_on = Date.new(2015, 12, 23)
|
55
|
+
starts_on = ends_on - 15.weeks
|
56
|
+
Montrose.every(:week, until: ends_on, starts: starts_on
|
57
|
+
|
58
|
+
# every other week forever
|
59
|
+
Montrose.every(2.weeks)
|
60
|
+
|
61
|
+
# weekly on Tuesday and Thursday for five weeks
|
62
|
+
# from September 1, 2015 until October 5, 2015
|
63
|
+
Montrose.weekly(on: [:tuesday, :thursday],
|
64
|
+
between: Date.new(2015, 9, 1)..Date.new(2015, 10, 5))
|
65
|
+
|
66
|
+
# every other week on Monday, Wednesday and Friday until December 23 2015,
|
67
|
+
# but starting on Tuesday, September 1, 2015
|
68
|
+
Montrose.every(2.weeks,
|
69
|
+
on: [:monday, :wednesday, :friday],
|
70
|
+
starts: Date.new(2015, 9, 1))
|
71
|
+
|
72
|
+
# every other week on Tuesday and Thursday, for 8 occurrences
|
73
|
+
Montrose.weekly(on: [:tuesday, :thursday], total: 8, interval: 2)
|
74
|
+
|
75
|
+
# monthly on the first Friday for ten occurrences
|
76
|
+
Montrose.monthly(day: { friday: [1] }, total: 10)
|
77
|
+
|
78
|
+
# monthly on the first Friday until December 23, 2015
|
79
|
+
Montrose.every(:month, day: { friday: [1] }, until: Date.new(2016, 12, 23))
|
80
|
+
|
81
|
+
# every other month on the first and last Sunday of the month for 10 occurrences
|
82
|
+
Montrose.every(:month, day: { sunday: [1, -1] }, interval: 2, total: 10)
|
83
|
+
|
84
|
+
# monthly on the second-to-last Monday of the month for 6 months
|
85
|
+
Montrose.every(:month, day: { monday: [-2] }, total: 6)
|
86
|
+
|
87
|
+
# monthly on the third-to-the-last day of the month, forever
|
88
|
+
Montrose.every(:month, mday: [-3])
|
89
|
+
|
90
|
+
# monthly on the 2nd and 15th of the month for 10 occurrences
|
91
|
+
Montrose.every(:month, on: [2, 15], total: 10)
|
92
|
+
|
93
|
+
# monthly on the first and last day of the month for 10 occurrences
|
94
|
+
Montrose.monthly(mday: [1, -1], total: 10)
|
95
|
+
|
96
|
+
# every 18 months on the 10th thru 15th of the month for 10 occurrences
|
97
|
+
Montrose.every(18.months, total: 10, mday: 10..15)
|
98
|
+
|
99
|
+
# every Tuesday, every other month
|
100
|
+
Montrose.every(2.months, on: :tuesday)
|
101
|
+
|
102
|
+
# yearly in June and July for 10 occurrences
|
103
|
+
Montrose.yearly(month: [:june, :july], total: 10)
|
104
|
+
|
105
|
+
# every other year on January, February, and March for 10 occurrences
|
106
|
+
Montrose.every(2.years, month: [:january, :february, :march], total: 10)
|
107
|
+
|
108
|
+
# every third year on the 1st, 100th and 200th day for 10 occurrences
|
109
|
+
Montrose.yearly(yday: [1, 100, 200], total: 10)
|
110
|
+
|
111
|
+
# every 20th Monday of the year, forever
|
112
|
+
Montrose.yearly(day: { monday: [20] })
|
113
|
+
|
114
|
+
# Monday of week number 20 forever
|
115
|
+
Montrose.yearly(week: [20], on: :monday)
|
116
|
+
|
117
|
+
# every Thursday in March, forever
|
118
|
+
Montrose.monthly(month: :march, on: :thursday, at: "12 pm")
|
119
|
+
|
120
|
+
# every Thursday, but only during June, July, and August, forever" do
|
121
|
+
Montrose.monthly(month: 6..8, on: :thursday)
|
122
|
+
|
123
|
+
# every Friday 13th, forever
|
124
|
+
Montrose.monthly(on: { friday: 13 })
|
125
|
+
|
126
|
+
# first Saturday that follows the first Sunday of the month, forever
|
127
|
+
Montrose.monthly(on: { saturday: 7..13 })
|
128
|
+
|
129
|
+
# every four years, the first Tuesday after a Monday in November, forever (U.S. Presidential Election day)
|
130
|
+
Montrose.every(4.years, month: :november, on: { tuesday: 2..8 })
|
131
|
+
|
132
|
+
# every 3 hours from 9:00 AM to 5:00 PM on a specific day
|
133
|
+
date = Date.new(2016, 9, 1)
|
134
|
+
Montrose.hourly(between: date..(date+1), hour: 9..17, interval: 3)
|
135
|
+
|
136
|
+
# every 15 minutes for 6 occurrences
|
137
|
+
Montrose.every(90.minutes, total: 6)
|
138
|
+
|
139
|
+
# every hour and a half for four occurrences
|
140
|
+
Montrose.every(90.minutes, total: 4)
|
141
|
+
|
142
|
+
# every 20 minutes from 9:00 AM to 4:40 PM every day
|
143
|
+
Montrose.every(20.minutes, hour: 9..16)
|
144
|
+
|
34
145
|
# Minutely
|
35
146
|
Montrose.minutely
|
36
147
|
Montrose::Recurrence.new(every: :minute)
|
@@ -63,15 +174,11 @@ Montrose.weekly
|
|
63
174
|
Montrose.every(:week)
|
64
175
|
Montrose::Recurrence.new(every: :week)
|
65
176
|
|
66
|
-
|
67
|
-
Montrose
|
68
|
-
Montrose
|
69
|
-
Montrose
|
70
|
-
Montrose
|
71
|
-
Montrose::Recurrence.new(every: :week, on: :friday, repeat: 4)
|
72
|
-
Montrose::Recurrence.new(every: :week, on: :friday, at: "3:41 PM")
|
73
|
-
Montrose::Recurrence.new(every: :week, on: [:monday, :wednesday, :friday], at: "12:00 PM")
|
74
|
-
Montrose::Recurrence.weekly(on: :thursday)
|
177
|
+
Montrose.every(:week, on: :monday)
|
178
|
+
Montrose.every(:week, on: [:monday, :wednesday, :friday])
|
179
|
+
Montrose.every(2.weeks, on: :friday)
|
180
|
+
Montrose.every(:week, on: :friday, at: "3:41 PM")
|
181
|
+
Montrose.weekly(on: :thursday)
|
75
182
|
|
76
183
|
# Monthly by month day
|
77
184
|
Montrose.monthly(mday: 1) # first of the month
|
@@ -82,34 +189,15 @@ Montrose.monthly(mday: [2, 15]) # 2nd and 15th of the month
|
|
82
189
|
Montrose.monthly(mday: -3) # third-to-last day of the month
|
83
190
|
Montrose.monthly(mday: 10..15) # 10th through the 15th day of the month
|
84
191
|
|
85
|
-
# TODO: :on option not yet supported
|
86
|
-
Montrose::Recurrence.new(every: :month, on: 15)
|
87
|
-
Montrose::Recurrence.new(every: :month, on: 31)
|
88
|
-
Montrose::Recurrence.new(every: :month, on: 7, interval: 2)
|
89
|
-
Montrose::Recurrence.new(every: :month, on: 7, interval: :monthly)
|
90
|
-
Montrose::Recurrence.new(every: :month, on: 7, interval: :bimonthly)
|
91
|
-
Montrose::Recurrence.new(every: :month, on: 7, repeat: 6)
|
92
|
-
Montrose::Recurrence.monthly(on: 31)
|
93
|
-
|
94
192
|
# Monthly by week day
|
95
193
|
Montrose.monthly(day: :friday, interval: 2) # every Friday every other month
|
96
194
|
Montrose.every(:month, day: :friday, interval: 2)
|
97
195
|
Montrose::Recurrence.new(every: :month, day: :friday, interval: 2)
|
98
196
|
|
99
197
|
Montrose.monthly(day: { friday: [1] }) # 1st Friday of the month
|
100
|
-
Montrose.monthly(day: { Sunday: [1,
|
101
|
-
|
102
|
-
Montrose.monthly(mday: 7..13, day: :saturday) # first Saturday that follow the
|
103
|
-
first Sunday of the month
|
198
|
+
Montrose.monthly(day: { Sunday: [1, -1] }) # first and last Sunday of the month
|
104
199
|
|
105
|
-
|
106
|
-
Montrose::Recurrence.new(every: :month, on: :first, weekday: :sunday)
|
107
|
-
Montrose::Recurrence.new(every: :month, on: :third, weekday: :monday)
|
108
|
-
Montrose::Recurrence.new(every: :month, on: :last, weekday: :friday)
|
109
|
-
Montrose::Recurrence.new(every: :month, on: :last, weekday: :friday, interval: 2)
|
110
|
-
Montrose::Recurrence.new(every: :month, on: :last, weekday: :friday, interval: :quarterly)
|
111
|
-
Montrose::Recurrence.new(every: :month, on: :last, weekday: :friday, interval: :semesterly)
|
112
|
-
Montrose::Recurrence.new(every: :month, on: :last, weekday: :friday, repeat: 3)
|
200
|
+
Montrose.monthly(mday: 7..13, day: :saturday) # first Saturday that follow the first Sunday of the month
|
113
201
|
|
114
202
|
# Yearly
|
115
203
|
Montrose.yearly
|
@@ -117,28 +205,24 @@ Montrose.every(:year)
|
|
117
205
|
Montrose::Recurrence.new(every: :year)
|
118
206
|
|
119
207
|
Montrose.yearly(month: [:june, :july]) # yearly in June and July
|
120
|
-
Montrose.yearly(month: 6..8, day: :thursday) # yearly in June, July, August on
|
121
|
-
Thursday
|
208
|
+
Montrose.yearly(month: 6..8, day: :thursday) # yearly in June, July, August on Thursday
|
122
209
|
Montrose.yearly(yday: [1, 100]) # yearly on the 1st and 100th day of year
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
Montrose
|
129
|
-
Montrose
|
130
|
-
|
131
|
-
|
132
|
-
Montrose
|
133
|
-
|
134
|
-
# TODO: Remove a date in the series on the given except date(s)
|
135
|
-
# :except defaults to being unset
|
136
|
-
Montrose::Recurrence.new(every: :day, except: "2017-01-31")
|
137
|
-
Montrose::Recurrence.new(every: :day, except: [Date.today, "2017-01-31"])
|
210
|
+
|
211
|
+
Montrose::Recurrence.yearly(on: { january: 31 })
|
212
|
+
Montrose::Recurrence.new(every: :year, on: { 10 => 31 }, interval: 3)
|
213
|
+
|
214
|
+
# TODO: Remove a date in the series with :except date(s)
|
215
|
+
Montrose.daily(:day, except: "2017-01-31")
|
216
|
+
Montrose.daily(except: [Date.today, "2017-01-31"])
|
217
|
+
|
218
|
+
# Chaining
|
219
|
+
Montrose.weekly.starting(3.weeks.from_now).on(:friday)
|
220
|
+
Montrose.every(:day).at("4:05pm")
|
138
221
|
|
139
222
|
# Enumerating events
|
140
|
-
r = Montrose
|
223
|
+
r = Montrose.every(:month, mday: 31, until: "January 1, 2017")
|
141
224
|
r.each { |time| puts time.to_s }
|
225
|
+
r.take(10).to_a
|
142
226
|
|
143
227
|
# Merging rules and enumerating
|
144
228
|
r.merge(starts: "2017-01-01").each { |time| puts time.to_s }
|
@@ -155,11 +239,10 @@ r.events.lazy.select { |time| time > 1.month.from_now }.take(3).each { |date| pu
|
|
155
239
|
|
156
240
|
## Goals
|
157
241
|
|
158
|
-
`Montrose` intends to:
|
242
|
+
`Montrose` aims to provide a simple interface for specifying and enumerating recurring events as Time objects. To that end, the project intends to:
|
159
243
|
|
160
244
|
* embrace Ruby idioms
|
161
245
|
* support Ruby 2.1+
|
162
|
-
* provide a simple-to-use interface
|
163
246
|
* be reasonably performant
|
164
247
|
* serialize to yaml, hash, and [ical](http://www.kanzaki.com/docs/ical/rrule.html#basic) formats
|
165
248
|
* be suitable for integration with persistence libraries
|
@@ -168,7 +251,11 @@ What `Montrose` isn't:
|
|
168
251
|
|
169
252
|
* support all calendaring use cases under the sun
|
170
253
|
|
171
|
-
##
|
254
|
+
## Inspiration
|
255
|
+
|
256
|
+
Montrose is named after the beautifully diverse and artistic [neighborhood in Houston, Texas](https://en.wikipedia.org/wiki/Montrose,_Houston).
|
257
|
+
|
258
|
+
### Related Projects
|
172
259
|
|
173
260
|
Check out following related projects, all of which have provided inspiration for `Montrose`.
|
174
261
|
|
data/lib/montrose/chainable.rb
CHANGED
@@ -75,19 +75,9 @@ module Montrose
|
|
75
75
|
# Create a monthly recurrence.
|
76
76
|
#
|
77
77
|
# @example
|
78
|
-
#
|
79
|
-
#
|
80
|
-
#
|
81
|
-
# Montrose.monthly(on: :third, weekday: :sunday)
|
82
|
-
# Montrose.monthly(on: :fourth, weekday: :sunday)
|
83
|
-
# Montrose.monthly(on: :fifth, weekday: :sunday)
|
84
|
-
# Montrose.monthly(on: :last, weekday: :sunday)
|
85
|
-
# Montrose.monthly(on: 15, interval: 2)
|
86
|
-
# Montrose.monthly(on: 15, interval: :monthly)
|
87
|
-
# Montrose.monthly(on: 15, interval: :bimonthly)
|
88
|
-
# Montrose.monthly(on: 15, interval: :quarterly)
|
89
|
-
# Montrose.monthly(on: 15, interval: :semesterly)
|
90
|
-
# Montrose.monthly(on: 15, total: 5)
|
78
|
+
# Montrose.monthly(mday: [2, 15]) # 2nd and 15th of the month
|
79
|
+
# Montrose.monthly(mday: -3) # third-to-last day of the month
|
80
|
+
# Montrose.monthly(mday: 10..15) # 10th through the 15th day of the month
|
91
81
|
#
|
92
82
|
# The <tt>:on</tt> option can be one of the following:
|
93
83
|
#
|
@@ -135,6 +125,22 @@ module Montrose
|
|
135
125
|
merge(between: date_range)
|
136
126
|
end
|
137
127
|
|
128
|
+
# Create a recurrence through :on option
|
129
|
+
#
|
130
|
+
# @param [Hash,Symbol] on { friday: 13 }
|
131
|
+
#
|
132
|
+
def on(day)
|
133
|
+
merge(on: day)
|
134
|
+
end
|
135
|
+
|
136
|
+
# Create a recurrence at given time
|
137
|
+
#
|
138
|
+
# @param [String,Time] at
|
139
|
+
#
|
140
|
+
def at(time)
|
141
|
+
merge(at: time)
|
142
|
+
end
|
143
|
+
|
138
144
|
# Create a recurrence for given days of month
|
139
145
|
#
|
140
146
|
# @param [Fixnum] days (1, 2, -1, ...)
|
@@ -142,6 +148,7 @@ module Montrose
|
|
142
148
|
def day_of_month(*days)
|
143
149
|
merge(mday: days)
|
144
150
|
end
|
151
|
+
alias mday day_of_month
|
145
152
|
|
146
153
|
# Create a recurrence for given days of week
|
147
154
|
#
|
@@ -150,6 +157,7 @@ module Montrose
|
|
150
157
|
def day_of_week(*weekdays)
|
151
158
|
merge(day: weekdays)
|
152
159
|
end
|
160
|
+
alias day day_of_week
|
153
161
|
|
154
162
|
# Create a recurrence for given days of year
|
155
163
|
#
|
@@ -158,6 +166,7 @@ module Montrose
|
|
158
166
|
def day_of_year(*days)
|
159
167
|
merge(yday: days)
|
160
168
|
end
|
169
|
+
alias yday day_of_year
|
161
170
|
|
162
171
|
# Create a recurrence for given hours of day
|
163
172
|
#
|
@@ -166,6 +175,7 @@ module Montrose
|
|
166
175
|
def hour_of_day(*hours)
|
167
176
|
merge(hour: hours)
|
168
177
|
end
|
178
|
+
alias hour hour_of_day
|
169
179
|
|
170
180
|
# Create a recurrence for given months of year
|
171
181
|
#
|
@@ -174,6 +184,7 @@ module Montrose
|
|
174
184
|
def month_of_year(*months)
|
175
185
|
merge(month: months)
|
176
186
|
end
|
187
|
+
alias month month_of_year
|
177
188
|
|
178
189
|
# Create a recurrence that ends after given number
|
179
190
|
# of occurrences
|
data/lib/montrose/options.rb
CHANGED
@@ -99,6 +99,7 @@ module Montrose
|
|
99
99
|
end
|
100
100
|
Hash[*hash_pairs].reject { |_k, v| v.nil? }
|
101
101
|
end
|
102
|
+
alias to_h to_hash
|
102
103
|
|
103
104
|
def []=(option, val)
|
104
105
|
send(:"#{option}=", val)
|
@@ -150,7 +151,7 @@ module Montrose
|
|
150
151
|
end
|
151
152
|
|
152
153
|
def day=(days)
|
153
|
-
@day = nested_map_arg(days) { |d| Montrose::Utils.day_number(d) }
|
154
|
+
@day = nested_map_arg(days) { |d| Montrose::Utils.day_number!(d) }
|
154
155
|
end
|
155
156
|
|
156
157
|
def mday=(mdays)
|
@@ -166,7 +167,7 @@ module Montrose
|
|
166
167
|
end
|
167
168
|
|
168
169
|
def month=(months)
|
169
|
-
@month = map_arg(months) { |d| Montrose::Utils.month_number(d) }
|
170
|
+
@month = map_arg(months) { |d| Montrose::Utils.month_number!(d) }
|
170
171
|
end
|
171
172
|
|
172
173
|
def between=(range)
|
@@ -189,12 +190,17 @@ module Montrose
|
|
189
190
|
end
|
190
191
|
|
191
192
|
def on=(arg)
|
192
|
-
|
193
|
-
self[:day] =
|
194
|
-
self[:
|
193
|
+
result = decompose_on_arg(arg)
|
194
|
+
self[:day] = result[:day] if result[:day]
|
195
|
+
self[:month] = result[:month] if result[:month]
|
196
|
+
self[:mday] = result[:mday] if result[:mday]
|
195
197
|
@on = arg
|
196
198
|
end
|
197
199
|
|
200
|
+
def inspect
|
201
|
+
"#<#{self.class} #{to_h.inspect}>"
|
202
|
+
end
|
203
|
+
|
198
204
|
private
|
199
205
|
|
200
206
|
def nested_map_arg(arg, &block)
|
@@ -215,7 +221,7 @@ module Montrose
|
|
215
221
|
end
|
216
222
|
|
217
223
|
def map_days(arg)
|
218
|
-
map_arg(arg) { |d| Montrose::Utils.day_number(d) }
|
224
|
+
map_arg(arg) { |d| Montrose::Utils.day_number!(d) }
|
219
225
|
end
|
220
226
|
|
221
227
|
def map_mdays(arg)
|
@@ -242,15 +248,28 @@ module Montrose
|
|
242
248
|
assert_range_includes(1..MAX_WEEKS_IN_YEAR, week, :absolute)
|
243
249
|
end
|
244
250
|
|
245
|
-
def
|
251
|
+
def decompose_on_arg(arg)
|
246
252
|
case arg
|
247
253
|
when Hash
|
248
|
-
|
254
|
+
arg.each_with_object({}) do |(k, v), result|
|
255
|
+
key, val = month_or_day(k)
|
256
|
+
result[key] = val
|
257
|
+
result[:mday] ||= []
|
258
|
+
result[:mday] += map_mdays(v)
|
259
|
+
end
|
249
260
|
else
|
250
|
-
map_days(arg)
|
261
|
+
{ day: map_days(arg) }
|
251
262
|
end
|
252
263
|
end
|
253
264
|
|
265
|
+
def month_or_day(key)
|
266
|
+
month = Montrose::Utils.month_number(key)
|
267
|
+
return [:month, month] if month
|
268
|
+
day = Montrose::Utils.day_number(key)
|
269
|
+
return [:day, day] if day
|
270
|
+
fail ConfigurationError, "Did not recognize #{key} as a month or day"
|
271
|
+
end
|
272
|
+
|
254
273
|
def assert_range_includes(range, item, absolute = false)
|
255
274
|
test = absolute ? item.abs : item
|
256
275
|
fail ConfigurationError, "Out of range" unless range.include?(test)
|
data/lib/montrose/recurrence.rb
CHANGED
data/lib/montrose/utils.rb
CHANGED
@@ -6,27 +6,33 @@ module Montrose
|
|
6
6
|
DAYS = Date::DAYNAMES
|
7
7
|
|
8
8
|
def month_number(name)
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
case name
|
10
|
+
when Symbol, String
|
11
|
+
MONTHS.index(name.to_s.titleize)
|
12
|
+
when 1..12
|
13
|
+
name
|
14
|
+
end
|
15
|
+
end
|
15
16
|
|
16
|
-
|
17
|
+
def month_number!(name)
|
18
|
+
month_number(name) or fail ConfigurationError,
|
19
|
+
"Did not recognize month #{name}, must be one of #{MONTHS.inspect}"
|
17
20
|
end
|
18
21
|
|
19
22
|
def day_number(name)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
case name
|
24
|
+
when 0..6
|
25
|
+
name
|
26
|
+
when Symbol, String
|
27
|
+
DAYS.index(name.to_s.titleize)
|
28
|
+
when Array
|
29
|
+
day_number name.first
|
30
|
+
end
|
31
|
+
end
|
28
32
|
|
29
|
-
|
33
|
+
def day_number!(name)
|
34
|
+
day_number(name) or fail ConfigurationError,
|
35
|
+
"Did not recognize day #{name}, must be one of #{DAYS.inspect}"
|
30
36
|
end
|
31
37
|
end
|
32
38
|
end
|
data/lib/montrose/version.rb
CHANGED
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.1.
|
4
|
+
version: 0.1.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-01-
|
11
|
+
date: 2016-01-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -184,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
184
184
|
version: '0'
|
185
185
|
requirements: []
|
186
186
|
rubyforge_project:
|
187
|
-
rubygems_version: 2.
|
187
|
+
rubygems_version: 2.5.1
|
188
188
|
signing_key:
|
189
189
|
specification_version: 4
|
190
190
|
summary: Recurring events in Ruby
|