chrono 0.5.0 → 0.7.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 046fa468703ffbd8c7c77b1767853c5db8e518c6affbc0b2a84d466cb15492b5
4
- data.tar.gz: 2128582a3bf2822dc3eab8cdf27e159fb4bd193ed896b4cea36309e4fec5516e
3
+ metadata.gz: 15ef63958b818176b45588c52900c11fb064100bdd9cac790aaa8c55f81c4569
4
+ data.tar.gz: 3f4e7950727edf4591469b6fccd8fba0cbfaf64f980498f346578829e8116247
5
5
  SHA512:
6
- metadata.gz: 46dbbf74bd81f5f5177109660e85edb88fb65fcf561947ea924f0fe158e5c117fb9b91a9c9b8a8202d425f3e0e6fdb43ef506912ce4207ba0bb0e4cb5648ae23
7
- data.tar.gz: 5891051f8983853fbafb88e171bfdb315653e43be2165cbb837e52a705e1a6a3696f441eee41b0b9842cbe7b8f40fbf430625016fa77e1c172c4d2a8eb68b6cb
6
+ metadata.gz: fcb310278e84892563694af01e7d0086fadcee1894dd3cce1a4aca65c5dac91551c97cf021b589ce2a298da00804bb4e68cc25b9a5be86d62d245c20ccd29452
7
+ data.tar.gz: 55715ac2d13bc10b263f907596acc7c6c4a836e7ae6575bbf7cca031eb2926ccb0a86d04d21311284c87818add89f5f129201c67543c0bbaab89d14ec8913d7b
@@ -0,0 +1,23 @@
1
+ changelog:
2
+ categories:
3
+ - title: Added
4
+ labels:
5
+ - add
6
+ - title: Changed
7
+ labels:
8
+ - change
9
+ - title: Deprecated
10
+ labels:
11
+ - deprecate
12
+ - title: Fixed
13
+ labels:
14
+ - fix
15
+ - title: Removed
16
+ labels:
17
+ - remove
18
+ - title: Security
19
+ labels:
20
+ - security
21
+ - title: Others
22
+ labels:
23
+ - "*"
@@ -0,0 +1,37 @@
1
+ # This file is machine-generated by `gh actions-lock`.
2
+ # Do not edit by hand; run `gh actions-lock` to update.
3
+ # Docs: https://gh.io/actions-lockfile
4
+ version: 'v0.0.3'
5
+ workflows:
6
+ '.github/workflows/bump-request.yml':
7
+ - 'actions/checkout@v7.0.1'
8
+ - 'r7kamura/bump-request@v0.7.1'
9
+ - 'ruby/setup-ruby@v1.336.0'
10
+ '.github/workflows/release.yml': []
11
+ '.github/workflows/test.yml':
12
+ - 'actions/checkout@v7.0.1'
13
+ - 'ruby/setup-ruby@v1.336.0'
14
+ dependencies:
15
+ 'actions/checkout@v7.0.1':
16
+ ref: 'v7.0.1'
17
+ commit: 'sha1-3d3c42e5aac5ba805825da76410c181273ba90b1'
18
+ owner_id: 44036562
19
+ repo_id: 197814629
20
+ 'actions/setup-node@v7.1.0':
21
+ ref: 'v7.1.0'
22
+ commit: 'sha1-949feb2413d6458794dcd2491c4babbbce0c15c1'
23
+ owner_id: 44036562
24
+ repo_id: 189476904
25
+ 'r7kamura/bump-request@v0.7.1':
26
+ ref: 'v0.7.1'
27
+ commit: 'sha1-b27937188d404bc0c2fd442403e6de1d20f9b349'
28
+ owner_id: 111689
29
+ repo_id: 533135195
30
+ uses:
31
+ - 'actions/checkout@v7.0.1'
32
+ - 'actions/setup-node@v7.1.0'
33
+ 'ruby/setup-ruby@v1.336.0':
34
+ ref: 'v1.336.0'
35
+ commit: 'sha1-de492cf36cbab201753d720ce4f4e336cd688c94'
36
+ owner_id: 210414
37
+ repo_id: 231208785
@@ -0,0 +1,26 @@
1
+ name: bump-request
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ version:
7
+ description: Version to change to.
8
+ required: true
9
+ type: string
10
+
11
+ jobs:
12
+ run:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v7.0.1
16
+ - name: Set up Ruby
17
+ uses: ruby/setup-ruby@v1.336.0
18
+ with:
19
+ ruby-version: 3.3
20
+ bundler-cache: true
21
+ - uses: r7kamura/bump-request@v0.7.1
22
+ with:
23
+ command: |
24
+ sed -i -r 's/([0-9]+\.[0-9]+\.[0-9]+)/${{ inputs.version }}/' lib/*/version.rb
25
+ bundle install
26
+ version: ${{ inputs.version }}
@@ -0,0 +1,11 @@
1
+ name: release
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ release:
10
+ uses: r7kamura/workflows/.github/workflows/gem-release.yml@main
11
+ if: github.repository_owner == 'r7kamura'
@@ -4,7 +4,7 @@ on:
4
4
  pull_request:
5
5
  push:
6
6
  branches:
7
- - master
7
+ - main
8
8
 
9
9
  jobs:
10
10
  build:
@@ -12,10 +12,12 @@ jobs:
12
12
  strategy:
13
13
  matrix:
14
14
  ruby:
15
- - 2.7.2
15
+ - '3.3'
16
+ - '3.4'
17
+ - '4.0'
16
18
  steps:
17
- - uses: actions/checkout@v2
18
- - uses: ruby/setup-ruby@v1
19
+ - uses: actions/checkout@v7.0.1
20
+ - uses: ruby/setup-ruby@v1.336.0
19
21
  with:
20
22
  ruby-version: ${{ matrix.ruby }}
21
23
  bundler-cache: true
data/README.md CHANGED
@@ -1,8 +1,5 @@
1
1
  # Chrono
2
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)
5
-
6
3
  Provides a chain of logics about chronology.
7
4
 
8
5
  ## Trigger
@@ -29,7 +26,7 @@ iterator.next #=> 2000-01-01 02:30:00
29
26
 
30
27
  ## Syntax
31
28
  The following syntax is supported.
32
- See the [examples](https://github.com/r7kamura/chrono/blob/master/spec/chrono/iterator_spec.rb)
29
+ See the [examples](https://github.com/r7kamura/chrono/blob/main/spec/chrono/iterator_spec.rb)
33
30
  for more details.
34
31
 
35
32
  * (*) Asterisk
data/chrono.gemspec CHANGED
@@ -15,6 +15,7 @@ Gem::Specification.new do |spec|
15
15
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
16
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
17
  spec.require_paths = ["lib"]
18
+ spec.required_ruby_version = ">= 3.3"
18
19
 
19
20
  spec.add_dependency "activesupport", '>= 5.2'
20
21
  spec.add_development_dependency "bundler"
@@ -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
@@ -6,6 +6,10 @@ module Chrono
6
6
  def range
7
7
  1..31
8
8
  end
9
+
10
+ def wildcards
11
+ ['L']
12
+ end
9
13
  end
10
14
  end
11
15
  end
@@ -48,7 +48,9 @@ module Chrono
48
48
  end
49
49
 
50
50
  def scheduled_in_this_day?
51
- if schedule.days?
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
@@ -46,6 +46,10 @@ module Chrono
46
46
  fields[4] != '*'
47
47
  end
48
48
 
49
+ def last_day_of_month?
50
+ fields[2] == 'L'
51
+ end
52
+
49
53
  private
50
54
 
51
55
  def fields
@@ -1,3 +1,3 @@
1
1
  module Chrono
2
- VERSION = "0.5.0"
2
+ VERSION = "0.7.0"
3
3
  end
@@ -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,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chrono
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2021-12-24 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activesupport
@@ -66,16 +65,18 @@ dependencies:
66
65
  - - "~>"
67
66
  - !ruby/object:Gem::Version
68
67
  version: 3.4.0
69
- description:
70
68
  email:
71
69
  - r7kamura@gmail.com
72
70
  executables: []
73
71
  extensions: []
74
72
  extra_rdoc_files: []
75
73
  files:
74
+ - ".github/release.yml"
75
+ - ".github/workflows/actions.lock"
76
+ - ".github/workflows/bump-request.yml"
77
+ - ".github/workflows/release.yml"
76
78
  - ".github/workflows/test.yml"
77
79
  - ".gitignore"
78
- - CHANGELOG.md
79
80
  - Gemfile
80
81
  - LICENSE.txt
81
82
  - README.md
@@ -101,7 +102,6 @@ homepage: https://github.com/r7kamura/chrono
101
102
  licenses:
102
103
  - MIT
103
104
  metadata: {}
104
- post_install_message:
105
105
  rdoc_options: []
106
106
  require_paths:
107
107
  - lib
@@ -109,15 +109,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
109
109
  requirements:
110
110
  - - ">="
111
111
  - !ruby/object:Gem::Version
112
- version: '0'
112
+ version: '3.3'
113
113
  required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  requirements:
115
115
  - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  requirements: []
119
- rubygems_version: 3.1.4
120
- signing_key:
119
+ rubygems_version: 4.0.20
121
120
  specification_version: 4
122
121
  summary: Provides a chain of logics about chronology.
123
122
  test_files:
data/CHANGELOG.md DELETED
@@ -1,77 +0,0 @@
1
- # Changelog
2
-
3
- ## Unreleased
4
-
5
- ## 0.5.0
6
-
7
- ### Added
8
-
9
- - Add support for activesupport 7 (thx @unasuke).
10
-
11
- ### Changed
12
-
13
- - Drop support of activesupport below 5.2.
14
-
15
- ## 0.4.0
16
-
17
- ### Changed
18
-
19
- - Raise ArgumentError on inifinite loop detected (thx @nurse).
20
-
21
- ## 0.3.0
22
-
23
- ### Fixed
24
-
25
- - Fix bug on day and wday specs.
26
-
27
- ## 0.2.0
28
-
29
- ### Added
30
-
31
- - Support some alias field names.
32
-
33
- ### Changed
34
-
35
- - Add more strict validations.
36
-
37
- ## 0.1.0
38
-
39
- ### Changed
40
-
41
- - Raise errors on invalid fields (thx @eagletmt).
42
-
43
- ## 0.0.6
44
-
45
- ### Changed
46
-
47
- - Support ActiveSupport 3 and 4.
48
-
49
- ## 0.0.5
50
-
51
- ### Changed
52
-
53
- - Fix missing version dependency on ActiveSupport 4.
54
-
55
- ## 0.0.4
56
-
57
- ### Changed
58
-
59
- - Add extra 1sec sleep to adjust to exact minute.
60
-
61
- ## 0.0.3
62
-
63
- ### Changed
64
-
65
- - Schedule more accurate second.
66
-
67
- ## 0.0.2
68
-
69
- ### Added
70
-
71
- - Chrono::Trigger was added.
72
-
73
- ## 0.0.1
74
-
75
- ### Added
76
-
77
- - Chrono::Iterator was added.