chrono 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/chrono/fields/base.rb +16 -2
- data/lib/chrono/fields/day.rb +4 -0
- data/lib/chrono/next_time.rb +3 -1
- data/lib/chrono/schedule.rb +4 -0
- data/lib/chrono/version.rb +1 -1
- data/spec/chrono/iterator_spec.rb +2 -0
- data/spec/chrono/schedule_spec.rb +4 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 946e2892180dd9ae752e3883cd0d85de26697b48303dc46d6ef9083958faccaa
|
4
|
+
data.tar.gz: b7a7dae085130625666abe7ebcdf40e50fa5ebe040b1cea101410458fbd165ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45245d747c9904409700776623301c7f2ab6b4c26f93a078f7b4d84221fa6549d441a51a939ead6f0ded5b979617b8c48f21027a594769f75faecd2d17190458
|
7
|
+
data.tar.gz: b148ea5a87ff74823c69d642f9b8e5af0630b2a0720ac92abf51a49b6856347b45fa79381d33acfe1404d8c5ba39024c230394731285923ebf898f06ed367ca5
|
data/CHANGELOG.md
CHANGED
data/lib/chrono/fields/base.rb
CHANGED
@@ -21,7 +21,7 @@ module Chrono
|
|
21
21
|
fields.map(&:to_a).flatten.uniq.sort
|
22
22
|
else
|
23
23
|
validate!
|
24
|
-
lower.step(upper, step).to_a.sort
|
24
|
+
wildcard? ? [] : lower.step(upper, step).to_a.sort
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -31,11 +31,21 @@ module Chrono
|
|
31
31
|
source.gsub("*", "#{range.first}-#{range.last}")
|
32
32
|
end
|
33
33
|
|
34
|
+
def wildcards
|
35
|
+
[]
|
36
|
+
end
|
37
|
+
|
38
|
+
def wildcard?
|
39
|
+
wildcards.include?(source)
|
40
|
+
end
|
41
|
+
|
34
42
|
def validate!
|
35
43
|
unless match_data
|
36
44
|
raise InvalidField.new('Unparsable field', source)
|
37
45
|
end
|
38
46
|
|
47
|
+
return true if wildcard?
|
48
|
+
|
39
49
|
if lower < range.begin || range.end < upper
|
40
50
|
raise InvalidField.new('The field is out-of-range', source)
|
41
51
|
end
|
@@ -68,7 +78,11 @@ module Chrono
|
|
68
78
|
end
|
69
79
|
|
70
80
|
def pattern
|
71
|
-
%r<\A(\d+)(?:-(\d+))?(?:/(\d+))?\z>
|
81
|
+
ptn = %r<\A(\d+)(?:-(\d+))?(?:/(\d+))?\z>
|
82
|
+
if wildcards.any?
|
83
|
+
ptn = Regexp.union(ptn, *wildcards.map { |w| /\A#{w}\z/ })
|
84
|
+
end
|
85
|
+
ptn
|
72
86
|
end
|
73
87
|
|
74
88
|
def match_data
|
data/lib/chrono/fields/day.rb
CHANGED
data/lib/chrono/next_time.rb
CHANGED
@@ -48,7 +48,9 @@ module Chrono
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def scheduled_in_this_day?
|
51
|
-
if schedule.
|
51
|
+
if schedule.last_day_of_month?
|
52
|
+
time.day == time.end_of_month.day
|
53
|
+
elsif schedule.days?
|
52
54
|
if schedule.wdays?
|
53
55
|
schedule.days.include?(time.day) || schedule.wdays.include?(time.wday)
|
54
56
|
else
|
data/lib/chrono/schedule.rb
CHANGED
data/lib/chrono/version.rb
CHANGED
@@ -25,6 +25,8 @@ describe Chrono::Iterator do
|
|
25
25
|
"2000-01-01 00:00:00", "2000-01-03 00:00:00", "0 0 1,15 * 1",
|
26
26
|
"2000-01-01 00:00:00", "2000-01-05 00:00:00", "0 0 5,15,25 * 5",
|
27
27
|
"2000-02-29 00:00:01", "2004-02-29 00:00:00", "0 0 29 2 *",
|
28
|
+
"2000-01-01 00:00:00", "2000-01-31 00:00:00", "0 0 L * *",
|
29
|
+
"2000-01-31 00:00:00", "2000-02-29 00:00:00", "0 0 L * *",
|
28
30
|
].each_slice(3) do |from, to, source|
|
29
31
|
it "ticks #{from} to #{to} by #{source}" do
|
30
32
|
now = Time.parse(from)
|
@@ -124,6 +124,10 @@ describe Chrono::Schedule do
|
|
124
124
|
let (:source){ '0 0 32 * *' }
|
125
125
|
it { expect{subject}.to raise_error(Chrono::Fields::Base::InvalidField) }
|
126
126
|
end
|
127
|
+
context 'last day of the month' do
|
128
|
+
let (:source){ '0 0 L * *' }
|
129
|
+
it { is_expected.to eq [] }
|
130
|
+
end
|
127
131
|
end
|
128
132
|
|
129
133
|
describe '#months' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chrono
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 3.4.0
|
69
|
-
description:
|
69
|
+
description:
|
70
70
|
email:
|
71
71
|
- r7kamura@gmail.com
|
72
72
|
executables: []
|
@@ -101,7 +101,7 @@ homepage: https://github.com/r7kamura/chrono
|
|
101
101
|
licenses:
|
102
102
|
- MIT
|
103
103
|
metadata: {}
|
104
|
-
post_install_message:
|
104
|
+
post_install_message:
|
105
105
|
rdoc_options: []
|
106
106
|
require_paths:
|
107
107
|
- lib
|
@@ -116,8 +116,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
116
116
|
- !ruby/object:Gem::Version
|
117
117
|
version: '0'
|
118
118
|
requirements: []
|
119
|
-
rubygems_version: 3.
|
120
|
-
signing_key:
|
119
|
+
rubygems_version: 3.3.26
|
120
|
+
signing_key:
|
121
121
|
specification_version: 4
|
122
122
|
summary: Provides a chain of logics about chronology.
|
123
123
|
test_files:
|