whedon 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.simplecov +12 -0
- data/.travis.yml +4 -0
- data/LICENSE +21 -0
- data/README.md +14 -0
- data/lib/whedon/schedule.rb +3 -30
- data/lib/whedon/version.rb +1 -1
- data/spec/spec_helper.rb +14 -1
- data/spec/whedon/schedule_spec.rb +21 -14
- data/whedon.gemspec +4 -1
- metadata +52 -32
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6f65fe47d114ba93d1c8a0f2fd0941055aa62e27
|
4
|
+
data.tar.gz: 7ffa65c61ac6367d50dbc2418f0059c70d05f4f7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bcf1aace39f9e20ef3a1c8ee99e0b9ed875f3abd1e4d340432fa70eeb30b0d6d3a31220772487ce121d36cf24748056d8d8a4b01febad27919b9f68b41ce7739
|
7
|
+
data.tar.gz: 20e0b0e7369ed786356a4bdffd83dad968e620bac366c027bdea62851c48cf53c6f799b79f459fb6a7ec1725d7e9a348348ae2f5faf73c357821065484fcfde8
|
data/.simplecov
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
unless ENV['COVERAGE'] == 'false'
|
2
|
+
require 'simplecov-rcov'
|
3
|
+
|
4
|
+
class SimpleCov::Formatter::MergedFormatter
|
5
|
+
def format(result)
|
6
|
+
SimpleCov::Formatter::HTMLFormatter.new.format(result)
|
7
|
+
SimpleCov::Formatter::RcovFormatter.new.format(result)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
SimpleCov.formatter = SimpleCov::Formatter::MergedFormatter
|
12
|
+
end
|
data/.travis.yml
CHANGED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Copyright 2006-2013 John Mettraux
|
2
|
+
Portions copyright 2013 Blake Thomas
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
a copy of this software and associated documentation files (the
|
6
|
+
"Software"), to deal in the Software without restriction, including
|
7
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
@@ -24,7 +24,21 @@ sch.next("2020/07/01")
|
|
24
24
|
# Given date/time matches cron string
|
25
25
|
sch.matches?("2020/07/01 14:00:00")
|
26
26
|
|
27
|
+
# Time.now matches cron string
|
28
|
+
sch.now?
|
29
|
+
|
27
30
|
# Give cron string represented as an array
|
28
31
|
# [seconds minutes hours days months weekdays monthdays timezone]
|
29
32
|
sch.to_a
|
30
33
|
```
|
34
|
+
|
35
|
+
## And ... the Name?
|
36
|
+
|
37
|
+
Why 'whedon' ? First, [when](http://rubygems.org/gems/when) was taken. I was
|
38
|
+
considering variations on 'when do', & it occurred to me that 'whedon' (a la
|
39
|
+
[Joss Whedon](http://en.wikipedia.org/wiki/Joss_Whedon)) was an obvious anagram
|
40
|
+
of 'when do'. The pun regarding Whedon::Schedule being that Joss Whedon's
|
41
|
+
television series tend to get pulled from the network schedule.
|
42
|
+
|
43
|
+
## License
|
44
|
+
[MIT](http://opensource.org/licenses/MIT). See [LICENSE](LICENSE).
|
data/lib/whedon/schedule.rb
CHANGED
@@ -1,27 +1,3 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2006-2013, John Mettraux, jmettraux@gmail.com
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
-
# of this software and associated documentation files (the "Software"), to deal
|
6
|
-
# in the Software without restriction, including without limitation the rights
|
7
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
# copies of the Software, and to permit persons to whom the Software is
|
9
|
-
# furnished to do so, subject to the following conditions:
|
10
|
-
#
|
11
|
-
# The above copyright notice and this permission notice shall be included in
|
12
|
-
# all copies or substantial portions of the Software.
|
13
|
-
#
|
14
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
17
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
18
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
19
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
20
|
-
# THE SOFTWARE.
|
21
|
-
#
|
22
|
-
# Made in Japan.
|
23
|
-
#++
|
24
|
-
|
25
1
|
require 'tzinfo'
|
26
2
|
|
27
3
|
|
@@ -81,13 +57,13 @@ module Whedon
|
|
81
57
|
|
82
58
|
raise ParseError.new(
|
83
59
|
"invalid cronline: '#{line}'"
|
84
|
-
) if es && es.find { |e| ! e.is_a?(
|
60
|
+
) if es && es.find { |e| ! e.is_a?(Integer) }
|
85
61
|
end
|
86
62
|
end
|
87
63
|
|
88
64
|
# Returns true if the given time matches this cron line.
|
89
65
|
#
|
90
|
-
def matches?(time)
|
66
|
+
def matches?(time=Time.now)
|
91
67
|
|
92
68
|
time = as_time(time)
|
93
69
|
|
@@ -97,10 +73,7 @@ module Whedon
|
|
97
73
|
return false unless date_match?(time)
|
98
74
|
true
|
99
75
|
end
|
100
|
-
|
101
|
-
def now?(time=Time.now)
|
102
|
-
matches?(time)
|
103
|
-
end
|
76
|
+
alias_method :now?, :matches?
|
104
77
|
|
105
78
|
# Returns the next time that this cron line is supposed to 'fire'
|
106
79
|
#
|
data/lib/whedon/version.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
|
3
|
+
SimpleCov.start do
|
4
|
+
add_filter "vendor"
|
5
|
+
add_filter "spec"
|
6
|
+
end
|
7
|
+
|
8
|
+
RSpec.configure do |config|
|
9
|
+
config.expect_with :rspec do |c|
|
10
|
+
c.syntax = [:should, :expect]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
1
14
|
require File.expand_path("../../lib/whedon", __FILE__)
|
2
15
|
|
3
16
|
class Ex < Whedon::Schedule
|
@@ -21,5 +34,5 @@ def cl(line)
|
|
21
34
|
end
|
22
35
|
|
23
36
|
def compare(line, array)
|
24
|
-
cl(line).to_array.
|
37
|
+
expect(cl(line).to_array).to eq(array)
|
25
38
|
end
|
@@ -49,12 +49,12 @@ describe Whedon::Schedule do
|
|
49
49
|
|
50
50
|
it 'rejects invalid weekday expressions' do
|
51
51
|
|
52
|
-
lambda { cl '0 17 * * MON_FRI' }.should raise_error
|
52
|
+
lambda { cl '0 17 * * MON_FRI' }.should raise_error(Whedon::ParseError)
|
53
53
|
# underline instead of dash
|
54
54
|
|
55
|
-
lambda { cl '* * * * 9' }.should raise_error
|
56
|
-
lambda { cl '* * * * 0-12' }.should raise_error
|
57
|
-
lambda { cl '* * * * BLABLA' }.should raise_error
|
55
|
+
lambda { cl '* * * * 9' }.should raise_error(Whedon::ParseError)
|
56
|
+
lambda { cl '* * * * 0-12' }.should raise_error(Whedon::ParseError)
|
57
|
+
lambda { cl '* * * * BLABLA' }.should raise_error(Whedon::ParseError)
|
58
58
|
end
|
59
59
|
|
60
60
|
it 'rejects invalid cronlines' do
|
@@ -67,8 +67,8 @@ describe Whedon::Schedule do
|
|
67
67
|
compare '* * * * * EST', [ [0], nil, nil, nil, nil, nil, nil, 'EST' ]
|
68
68
|
compare '* * * * * * EST', [ nil, nil, nil, nil, nil, nil, nil, 'EST' ]
|
69
69
|
|
70
|
-
lambda { cl '* * * * * NotATimeZone' }.should raise_error
|
71
|
-
lambda { cl '* * * * * * NotATimeZone' }.should raise_error
|
70
|
+
lambda { cl '* * * * * NotATimeZone' }.should raise_error(Whedon::ParseError)
|
71
|
+
lambda { cl '* * * * * * NotATimeZone' }.should raise_error(Whedon::ParseError)
|
72
72
|
end
|
73
73
|
|
74
74
|
it 'interprets cron strings with / (slashes) correctly' do
|
@@ -296,6 +296,13 @@ describe Whedon::Schedule do
|
|
296
296
|
|
297
297
|
describe '#matches?' do
|
298
298
|
|
299
|
+
it 'accepts epoch time' do
|
300
|
+
cl('* * * * *').matches?(Time.at(0)).should be true
|
301
|
+
end
|
302
|
+
|
303
|
+
it 'accepts a time string' do
|
304
|
+
cl('* * * * *').matches?('1969-12-31 18:00:00 -0600').should be true
|
305
|
+
end
|
299
306
|
|
300
307
|
[ ['* * * * *', utc(1970, 1, 1, 0, 1), true],
|
301
308
|
['* * * * sun', utc(1970, 1, 4), true],
|
@@ -343,22 +350,22 @@ describe Whedon::Schedule do
|
|
343
350
|
|
344
351
|
it 'matches correctly when there is a sun#2 involved' do
|
345
352
|
|
346
|
-
cl('* * 13 * fri#2').matches?(utc(1970, 2, 13)).should
|
347
|
-
cl('* * 13 * fri#2').matches?(utc(1970, 2, 20)).should
|
353
|
+
cl('* * 13 * fri#2').matches?(utc(1970, 2, 13)).should be true
|
354
|
+
cl('* * 13 * fri#2').matches?(utc(1970, 2, 20)).should be false
|
348
355
|
end
|
349
356
|
|
350
357
|
it 'matches correctly when there is a L involved' do
|
351
358
|
|
352
|
-
cl('* * L * *').matches?(utc(1970, 1, 31)).should
|
353
|
-
cl('* * L * *').matches?(utc(1970, 1, 30)).should
|
359
|
+
cl('* * L * *').matches?(utc(1970, 1, 31)).should be true
|
360
|
+
cl('* * L * *').matches?(utc(1970, 1, 30)).should be false
|
354
361
|
end
|
355
362
|
|
356
363
|
it 'matches correctly when there is a sun#2,sun#3 involved' do
|
357
364
|
|
358
|
-
cl('* * * * sun#2,sun#3').matches?( local(1970, 1, 4) ).should
|
359
|
-
cl('* * * * sun#2,sun#3').matches?( local(1970, 1, 11) ).should
|
360
|
-
cl('* * * * sun#2,sun#3').matches?( local(1970, 1, 18) ).should
|
361
|
-
cl('* * * * sun#2,sun#3').matches?( local(1970, 1, 25) ).should
|
365
|
+
cl('* * * * sun#2,sun#3').matches?( local(1970, 1, 4) ).should be false
|
366
|
+
cl('* * * * sun#2,sun#3').matches?( local(1970, 1, 11) ).should be true
|
367
|
+
cl('* * * * sun#2,sun#3').matches?( local(1970, 1, 18) ).should be true
|
368
|
+
cl('* * * * sun#2,sun#3').matches?( local(1970, 1, 25) ).should be false
|
362
369
|
end
|
363
370
|
end
|
364
371
|
|
data/whedon.gemspec
CHANGED
@@ -11,6 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.homepage = "https://github.com/bwthomas/whedon"
|
12
12
|
s.summary = %q{Parses cron lines}
|
13
13
|
s.description = %q{Parses cron lines into a Schedule instance that can be queried.}
|
14
|
+
s.license = 'MIT'
|
14
15
|
|
15
16
|
s.rubyforge_project = "whedon"
|
16
17
|
|
@@ -21,7 +22,9 @@ Gem::Specification.new do |s|
|
|
21
22
|
|
22
23
|
s.add_dependency 'tzinfo'
|
23
24
|
|
24
|
-
s.add_development_dependency 'rspec', '~>
|
25
|
+
s.add_development_dependency 'rspec', '~>3.5.0'
|
26
|
+
s.add_development_dependency 'simplecov'
|
27
|
+
s.add_development_dependency 'simplecov-rcov'
|
25
28
|
s.add_development_dependency 'rake'
|
26
29
|
s.add_development_dependency 'pry'
|
27
30
|
end
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whedon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.3
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- John Mettraux
|
@@ -10,70 +9,90 @@ authors:
|
|
10
9
|
autorequire:
|
11
10
|
bindir: bin
|
12
11
|
cert_chain: []
|
13
|
-
date:
|
12
|
+
date: 2018-02-20 00:00:00.000000000 Z
|
14
13
|
dependencies:
|
15
14
|
- !ruby/object:Gem::Dependency
|
16
15
|
name: tzinfo
|
17
16
|
requirement: !ruby/object:Gem::Requirement
|
18
|
-
none: false
|
19
17
|
requirements:
|
20
|
-
- -
|
18
|
+
- - ">="
|
21
19
|
- !ruby/object:Gem::Version
|
22
20
|
version: '0'
|
23
21
|
type: :runtime
|
24
22
|
prerelease: false
|
25
23
|
version_requirements: !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
24
|
requirements:
|
28
|
-
- -
|
25
|
+
- - ">="
|
29
26
|
- !ruby/object:Gem::Version
|
30
27
|
version: '0'
|
31
28
|
- !ruby/object:Gem::Dependency
|
32
29
|
name: rspec
|
33
30
|
requirement: !ruby/object:Gem::Requirement
|
34
|
-
none: false
|
35
31
|
requirements:
|
36
|
-
- - ~>
|
32
|
+
- - "~>"
|
37
33
|
- !ruby/object:Gem::Version
|
38
|
-
version:
|
34
|
+
version: 3.5.0
|
39
35
|
type: :development
|
40
36
|
prerelease: false
|
41
37
|
version_requirements: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
38
|
requirements:
|
44
|
-
- - ~>
|
39
|
+
- - "~>"
|
45
40
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
41
|
+
version: 3.5.0
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: simplecov
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: simplecov-rcov
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
47
70
|
- !ruby/object:Gem::Dependency
|
48
71
|
name: rake
|
49
72
|
requirement: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
73
|
requirements:
|
52
|
-
- -
|
74
|
+
- - ">="
|
53
75
|
- !ruby/object:Gem::Version
|
54
76
|
version: '0'
|
55
77
|
type: :development
|
56
78
|
prerelease: false
|
57
79
|
version_requirements: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
80
|
requirements:
|
60
|
-
- -
|
81
|
+
- - ">="
|
61
82
|
- !ruby/object:Gem::Version
|
62
83
|
version: '0'
|
63
84
|
- !ruby/object:Gem::Dependency
|
64
85
|
name: pry
|
65
86
|
requirement: !ruby/object:Gem::Requirement
|
66
|
-
none: false
|
67
87
|
requirements:
|
68
|
-
- -
|
88
|
+
- - ">="
|
69
89
|
- !ruby/object:Gem::Version
|
70
90
|
version: '0'
|
71
91
|
type: :development
|
72
92
|
prerelease: false
|
73
93
|
version_requirements: !ruby/object:Gem::Requirement
|
74
|
-
none: false
|
75
94
|
requirements:
|
76
|
-
- -
|
95
|
+
- - ">="
|
77
96
|
- !ruby/object:Gem::Version
|
78
97
|
version: '0'
|
79
98
|
description: Parses cron lines into a Schedule instance that can be queried.
|
@@ -84,10 +103,12 @@ executables: []
|
|
84
103
|
extensions: []
|
85
104
|
extra_rdoc_files: []
|
86
105
|
files:
|
87
|
-
- .gitignore
|
88
|
-
- .rspec
|
89
|
-
- .
|
106
|
+
- ".gitignore"
|
107
|
+
- ".rspec"
|
108
|
+
- ".simplecov"
|
109
|
+
- ".travis.yml"
|
90
110
|
- Gemfile
|
111
|
+
- LICENSE
|
91
112
|
- README.md
|
92
113
|
- Rakefile
|
93
114
|
- lib/whedon.rb
|
@@ -97,30 +118,29 @@ files:
|
|
97
118
|
- spec/whedon/schedule_spec.rb
|
98
119
|
- whedon.gemspec
|
99
120
|
homepage: https://github.com/bwthomas/whedon
|
100
|
-
licenses:
|
121
|
+
licenses:
|
122
|
+
- MIT
|
123
|
+
metadata: {}
|
101
124
|
post_install_message:
|
102
125
|
rdoc_options: []
|
103
126
|
require_paths:
|
104
127
|
- lib
|
105
128
|
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
-
none: false
|
107
129
|
requirements:
|
108
|
-
- -
|
130
|
+
- - ">="
|
109
131
|
- !ruby/object:Gem::Version
|
110
132
|
version: '0'
|
111
133
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
|
-
none: false
|
113
134
|
requirements:
|
114
|
-
- -
|
135
|
+
- - ">="
|
115
136
|
- !ruby/object:Gem::Version
|
116
137
|
version: '0'
|
117
138
|
requirements: []
|
118
139
|
rubyforge_project: whedon
|
119
|
-
rubygems_version:
|
140
|
+
rubygems_version: 2.6.11
|
120
141
|
signing_key:
|
121
|
-
specification_version:
|
142
|
+
specification_version: 4
|
122
143
|
summary: Parses cron lines
|
123
144
|
test_files:
|
124
145
|
- spec/spec_helper.rb
|
125
146
|
- spec/whedon/schedule_spec.rb
|
126
|
-
has_rdoc:
|