parse-cron-ext 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5cf58eb4b89df362df575b83dee5198a5251e3fcabb272c905ebf6a323931e03
4
- data.tar.gz: 2a2a933ef6d9fbaa5511ba7ff1df7d33e509d6dbc4eae998af10a4a646f490eb
3
+ metadata.gz: db764d04c5274b466fb075cb04185d709091c69434078c8b052166eaafbc854c
4
+ data.tar.gz: 6fdb5eee236c9a750bdbb4137dec00bd8a07978925f93e2d6be39674c5d67dda
5
5
  SHA512:
6
- metadata.gz: 404ead898589406dc2a65deed0d2a44587a926d3da1bf5a5c1b8cc7489ec8164ab2c6d5331a4522ebc6398139d41a7ce964d36c06ae239009bacadfd5d81a373
7
- data.tar.gz: 0fd4100327bb9db144da4cd301afa487f8dbd5796da2295cf1d5fe3fa0107cf3fa37a35870e1aaa41972b23f5e97b152ea9b64b3471335f3015c43083e5c3797
6
+ metadata.gz: 0246ef91c0379146ad95c5055cd509cbe61e0ccc0f75b05ecec991b05cde9ccad8e8196f2240a561a406300b4f2e3e4b7e4d33b418e8be42cfd67b0eae6bb923
7
+ data.tar.gz: 07a5dcc145a0f37be7590d7da5ac80bdd0938dbe0a4119fb217108c53e9fee04744ed0a914d8dcdf42a4737f081783037c510cb8b48478d0b7e70cf0b12ef5f8
data/.travis.yml CHANGED
@@ -1,6 +1,12 @@
1
1
  ---
2
2
  language: ruby
3
- cache: bundler
3
+ sudo: false
4
4
  rvm:
5
- - 2.6.8
6
- before_install: gem install bundler -v 2.1.4
5
+ - 2.5.9
6
+ - 2.6.7
7
+ - 2.7.3
8
+ - 3.0.1
9
+ before_install:
10
+ - gem update bundler
11
+ - gem update --system
12
+
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- parse-cron-ext (0.1.0)
4
+ parse-cron-ext (0.2.0)
5
5
  parse-cron (>= 0.1.4)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
1
  # parse-cron-ext
2
+ [![Gem Version](https://badge.fury.io/rb/parse-cron-ext.svg)](https://badge.fury.io/rb/parse-cron-ext)
3
+ [![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)
2
4
 
3
5
  parse-cron-ext is a extension (monkey-patch) for parse-cron 0.1.4, which is the latest version.
4
6
  siebertm/parse-cron: https://github.com/siebertm/parse-cron
@@ -23,8 +25,9 @@ Or install it yourself as:
23
25
 
24
26
  ## Usage
25
27
  These notations are inspired by [AWS Cron Expressions](https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html).
26
-
27
-
28
+
29
+
30
+ You can express...
28
31
  ### End of the month by using L notation
29
32
  ```ruby
30
33
  cron_parser = CronParser.new('0 9 L * *')
@@ -61,8 +64,20 @@ Or install it yourself as:
61
64
 
62
65
  time = Time.local(2022, 1, 3, 12, 0)
63
66
  cron_parser.next(time)
64
- # => 2022-03-31 09:00
67
+ # => 2022-03-13 09:00
68
+ ```
69
+
70
+
71
+ ### Weekday by using W notation
72
+ ```ruby
73
+ # next weekday
74
+ cron_parser = CronParser.new('0 0 * * W')
75
+
76
+ time = Time.local(2022, 2, 11, 12, 0)
77
+ cron_parser.next(time)
78
+ # => 2022-02-14 00:00
65
79
  ```
80
+ https://www.timeanddate.com/calendar/
66
81
 
67
82
  ## Development
68
83
 
data/lib/cron_parse.rb CHANGED
@@ -3,7 +3,7 @@ require 'date'
3
3
  require 'parse-cron'
4
4
 
5
5
  class CronParser
6
- SUBELEMENT_REGEX = %r{^(\d+|l)((-(\d+)(/(\d+))?)?|#(\d+))$}
6
+ SUBELEMENT_REGEX = %r{^(\d+|l|w)((-(\d+)(/(\d+))?)?|#(\d+))$}
7
7
 
8
8
  def parse_element(elem, allowed_range, time_specs_key=nil)
9
9
  values = elem.split(',').map do |subel|
@@ -18,6 +18,8 @@ class CronParser
18
18
  stepped_range($1.to_i..$4.to_i, 1)
19
19
  elsif $1 == "l" && time_specs_key == :dom
20
20
  [$1]
21
+ elsif $1 == "w" && time_specs_key == :dow
22
+ [1, 2, 3, 4, 5]
21
23
  else # just a numeric
22
24
  @dow_offset = $7.to_i if $7
23
25
  [$1.to_i]
@@ -91,7 +93,7 @@ class CronParser
91
93
  :hour => parse_element(tokens[1], 0..23), #hour
92
94
  :dom => parse_element(tokens[2], 1..31, :dom), #DOM
93
95
  :month => parse_element(tokens[3], 1..12), #mon
94
- :dow => parse_element(tokens[4], 0..6) #DOW
96
+ :dow => parse_element(tokens[4], 0..6, :dow) #DOW
95
97
  }
96
98
  end
97
99
  end
@@ -1,7 +1,7 @@
1
1
  module Parse
2
2
  module Cron
3
3
  module Ext
4
- VERSION = "0.1.2"
4
+ VERSION = "0.2.0"
5
5
  end
6
6
  end
7
7
  end
@@ -7,8 +7,8 @@ Gem::Specification.new do |spec|
7
7
  spec.email = ["sh07e1916@gmail.com"]
8
8
 
9
9
  spec.summary = %q{parse-cron-ext is a extension (monkey-patch) for parse-cron 0.1.4, which is the latest version.}
10
- spec.description = %q{enable to specify "end of the month in March" or "Third Monday" in cron by extending of parse-cron.}
11
- spec.homepage = "https://yahoo.co.jp"
10
+ spec.description = %q{enable to specify "end of the month", "end of the month in March", "Third Monday", and so on... in cron by extending of parse-cron.}
11
+ spec.homepage = "https://github.com/a5-stable/parse-cron-ext"
12
12
  spec.license = "MIT"
13
13
  spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
14
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parse-cron-ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - a5-stable
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-02-05 00:00:00.000000000 Z
11
+ date: 2022-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: parse-cron
@@ -24,8 +24,8 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.1.4
27
- description: enable to specify "end of the month in March" or "Third Monday" in cron
28
- by extending of parse-cron.
27
+ description: enable to specify "end of the month", "end of the month in March", "Third
28
+ Monday", and so on... in cron by extending of parse-cron.
29
29
  email:
30
30
  - sh07e1916@gmail.com
31
31
  executables: []
@@ -46,7 +46,7 @@ files:
46
46
  - lib/cron_parse.rb
47
47
  - lib/parse-cron-ext/version.rb
48
48
  - parse-cron-ext.gemspec
49
- homepage: https://yahoo.co.jp
49
+ homepage: https://github.com/a5-stable/parse-cron-ext
50
50
  licenses:
51
51
  - MIT
52
52
  metadata: