chrono 0.4.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/test.yml +22 -0
- data/CHANGELOG.md +63 -11
- data/README.md +4 -1
- data/chrono.gemspec +1 -3
- data/lib/chrono/fields/base.rb +16 -2
- data/lib/chrono/fields/day.rb +4 -0
- data/lib/chrono/next_time.rb +4 -10
- 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
- data/spec/spec_helper.rb +0 -8
- metadata +10 -39
- data/.travis.yml +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
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
|
@@ -0,0 +1,22 @@
|
|
1
|
+
name: test
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
push:
|
6
|
+
branches:
|
7
|
+
- master
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
build:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
strategy:
|
13
|
+
matrix:
|
14
|
+
ruby:
|
15
|
+
- 2.7.2
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v2
|
18
|
+
- uses: ruby/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: ${{ matrix.ruby }}
|
21
|
+
bundler-cache: true
|
22
|
+
- run: bundle exec rake
|
data/CHANGELOG.md
CHANGED
@@ -1,31 +1,83 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
## Unreleased
|
4
|
+
|
5
|
+
## 0.6.0
|
6
|
+
|
7
|
+
### Added
|
8
|
+
|
9
|
+
- Add last-day-of-month syntax (thx @itkrt2y).
|
10
|
+
|
11
|
+
## 0.5.0
|
12
|
+
|
13
|
+
### Added
|
14
|
+
|
15
|
+
- Add support for activesupport 7 (thx @unasuke).
|
16
|
+
|
17
|
+
### Changed
|
18
|
+
|
19
|
+
- Drop support of activesupport below 5.2.
|
20
|
+
|
1
21
|
## 0.4.0
|
2
22
|
|
3
|
-
|
23
|
+
### Changed
|
24
|
+
|
25
|
+
- Raise ArgumentError on inifinite loop detected (thx @nurse).
|
4
26
|
|
5
27
|
## 0.3.0
|
6
|
-
|
28
|
+
|
29
|
+
### Fixed
|
30
|
+
|
31
|
+
- Fix bug on day and wday specs.
|
7
32
|
|
8
33
|
## 0.2.0
|
9
|
-
|
10
|
-
|
34
|
+
|
35
|
+
### Added
|
36
|
+
|
37
|
+
- Support some alias field names.
|
38
|
+
|
39
|
+
### Changed
|
40
|
+
|
41
|
+
- Add more strict validations.
|
11
42
|
|
12
43
|
## 0.1.0
|
13
|
-
|
44
|
+
|
45
|
+
### Changed
|
46
|
+
|
47
|
+
- Raise errors on invalid fields (thx @eagletmt).
|
14
48
|
|
15
49
|
## 0.0.6
|
16
|
-
|
50
|
+
|
51
|
+
### Changed
|
52
|
+
|
53
|
+
- Support ActiveSupport 3 and 4.
|
17
54
|
|
18
55
|
## 0.0.5
|
19
|
-
|
56
|
+
|
57
|
+
### Changed
|
58
|
+
|
59
|
+
- Fix missing version dependency on ActiveSupport 4.
|
20
60
|
|
21
61
|
## 0.0.4
|
22
|
-
|
62
|
+
|
63
|
+
### Changed
|
64
|
+
|
65
|
+
- Add extra 1sec sleep to adjust to exact minute.
|
23
66
|
|
24
67
|
## 0.0.3
|
25
|
-
|
68
|
+
|
69
|
+
### Changed
|
70
|
+
|
71
|
+
- Schedule more accurate second.
|
26
72
|
|
27
73
|
## 0.0.2
|
28
|
-
|
74
|
+
|
75
|
+
### Added
|
76
|
+
|
77
|
+
- Chrono::Trigger was added.
|
29
78
|
|
30
79
|
## 0.0.1
|
31
|
-
|
80
|
+
|
81
|
+
### Added
|
82
|
+
|
83
|
+
- Chrono::Iterator was added.
|
data/README.md
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
# Chrono
|
1
|
+
# Chrono
|
2
|
+
|
3
|
+
[![test](https://github.com/r7kamura/chrono/actions/workflows/test.yml/badge.svg)](https://github.com/r7kamura/chrono/actions/workflows/test.yml)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/chrono.svg)](https://rubygems.org/gems/chrono)
|
2
5
|
|
3
6
|
Provides a chain of logics about chronology.
|
4
7
|
|
data/chrono.gemspec
CHANGED
@@ -16,10 +16,8 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
|
-
spec.add_dependency "activesupport"
|
19
|
+
spec.add_dependency "activesupport", '>= 5.2'
|
20
20
|
spec.add_development_dependency "bundler"
|
21
|
-
spec.add_development_dependency "codeclimate-test-reporter"
|
22
21
|
spec.add_development_dependency "rake"
|
23
22
|
spec.add_development_dependency "rspec", "~> 3.4.0"
|
24
|
-
spec.add_development_dependency "simplecov"
|
25
23
|
end
|
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
@@ -1,13 +1,5 @@
|
|
1
|
+
require "active_support"
|
1
2
|
require "active_support/core_ext/numeric/time"
|
2
|
-
require "active_support/version"
|
3
|
-
|
4
|
-
if ActiveSupport::VERSION::MAJOR >= 4
|
5
|
-
require "active_support/core_ext/date"
|
6
|
-
require "active_support/core_ext/time"
|
7
|
-
else
|
8
|
-
require "active_support/core_ext/date/calculations"
|
9
|
-
require "active_support/core_ext/time/calculations"
|
10
|
-
end
|
11
3
|
|
12
4
|
module Chrono
|
13
5
|
class NextTime
|
@@ -56,7 +48,9 @@ module Chrono
|
|
56
48
|
end
|
57
49
|
|
58
50
|
def scheduled_in_this_day?
|
59
|
-
if schedule.
|
51
|
+
if schedule.last_day_of_month?
|
52
|
+
time.day == time.end_of_month.day
|
53
|
+
elsif schedule.days?
|
60
54
|
if schedule.wdays?
|
61
55
|
schedule.days.include?(time.day) || schedule.wdays.include?(time.wday)
|
62
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
|
data/spec/spec_helper.rb
CHANGED
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
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '5.2'
|
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: '
|
26
|
+
version: '5.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: codeclimate-test-reporter
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: rake
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -80,29 +66,15 @@ dependencies:
|
|
80
66
|
- - "~>"
|
81
67
|
- !ruby/object:Gem::Version
|
82
68
|
version: 3.4.0
|
83
|
-
|
84
|
-
name: simplecov
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
description:
|
69
|
+
description:
|
98
70
|
email:
|
99
71
|
- r7kamura@gmail.com
|
100
72
|
executables: []
|
101
73
|
extensions: []
|
102
74
|
extra_rdoc_files: []
|
103
75
|
files:
|
76
|
+
- ".github/workflows/test.yml"
|
104
77
|
- ".gitignore"
|
105
|
-
- ".travis.yml"
|
106
78
|
- CHANGELOG.md
|
107
79
|
- Gemfile
|
108
80
|
- LICENSE.txt
|
@@ -129,7 +101,7 @@ homepage: https://github.com/r7kamura/chrono
|
|
129
101
|
licenses:
|
130
102
|
- MIT
|
131
103
|
metadata: {}
|
132
|
-
post_install_message:
|
104
|
+
post_install_message:
|
133
105
|
rdoc_options: []
|
134
106
|
require_paths:
|
135
107
|
- lib
|
@@ -144,9 +116,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
116
|
- !ruby/object:Gem::Version
|
145
117
|
version: '0'
|
146
118
|
requirements: []
|
147
|
-
|
148
|
-
|
149
|
-
signing_key:
|
119
|
+
rubygems_version: 3.3.26
|
120
|
+
signing_key:
|
150
121
|
specification_version: 4
|
151
122
|
summary: Provides a chain of logics about chronology.
|
152
123
|
test_files:
|
data/.travis.yml
DELETED