parse-cron-ext 0.1.0 → 0.1.1

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: 92c12e5f584a2ced4ef9d81a2c58b29ce29e9b72106ce2320253de25a08b5838
4
- data.tar.gz: 8e6a58e1ada748bf525f2dbc1b5a9b770aa25b35f66f34991d1918418c6980b7
3
+ metadata.gz: ef52291db6825df25b7f6343e2618b970da6438a0d989b87d2cfe7ed96161f14
4
+ data.tar.gz: 5c597642a5d8a29b3ebd8878dd32eb33c5d98975abfbf70aa60f84f1d7fa17c7
5
5
  SHA512:
6
- metadata.gz: 9f49102492f26865f3326575cc6c5e55009a49489807888ed7317b26e9b827d9924ccf0f5a3d6770d4195f6ad9d19d8c2e8ef0c3d39895c101f958cb55b5e80c
7
- data.tar.gz: ae7aa92ddb3aff49f488329aa44f291fcf79eb4b6b344ea20f2724311e21ab096a795e6109b59d9ebb60ec81ae0ab26c3a02490c01191c461c3d7af7b363b8c1
6
+ metadata.gz: 9b1894b4dd88faf5bb8281e6dcfa76d12facec35dca9360c285843443e29b685a3ab1fa89b53518d47c364e40368547db8c7e28bcfdd55a305a5ecc661c1cbde
7
+ data.tar.gz: 15cc20b4d27a25f63c56d76be557ff1cded603f5dec90e1f37ec7461890bec23c1577fdbbfe08bfbf23e87e9f16107c5896146423ec03c2e6be4606108a54c83
data/README.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # parse-cron-ext
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/parse/cron/ext`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ parse-cron-ext is a extension (monkey-patch) for parse-cron 0.1.4, which is the latest version.
4
+ siebertm/parse-cron: https://github.com/siebertm/parse-cron
4
5
 
5
- TODO: Delete this and the text above, and describe your gem
6
+ Warning:
7
+ All specs written in parse-cron passed, but Use at your own risk.
6
8
 
7
9
  ## Installation
8
10
  Add this line to your application's Gemfile:
@@ -20,8 +22,47 @@ Or install it yourself as:
20
22
  $ gem install parse-cron-ext
21
23
 
22
24
  ## Usage
23
-
24
- TODO: Write usage instructions here
25
+ These notations are inspired by [AWS Cron Expressions](https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html).
26
+
27
+
28
+ ### End of the month by using L notation
29
+ ```ruby
30
+ cron_parser = CronParser.new('0 9 L * *')
31
+
32
+ time = Time.local(2022, 1, 16, 12, 0)
33
+ cron_parser.next(time)
34
+ # => 2022-01-31 09:00
35
+
36
+ time = Time.local(2022, 2, 3, 12, 0)
37
+ cron_parser.next(time)
38
+ # => 2022-02-28 09:00
39
+
40
+
41
+ # end of March
42
+ cron_parser = CronParser.new('0 9 L 3 *')
43
+
44
+ time = Time.local(2022, 2, 3, 12, 0)
45
+ cron_parser.next(time)
46
+ # => 2022-03-31 09:00
47
+ ```
48
+
49
+ ### Second Sunday, Third Friday...
50
+ ```ruby
51
+ # second sunday
52
+ cron_parser = CronParser.new('0 9 * * SUN#2')
53
+
54
+ time = Time.local(2022, 1, 3, 12, 0)
55
+ cron_parser.next(time)
56
+ # => 2022-01-09 09:00
57
+
58
+
59
+ # second sunday in march
60
+ cron_parser = CronParser.new('0 9 * 3 SUN#2')
61
+
62
+ time = Time.local(2022, 1, 3, 12, 0)
63
+ cron_parser.next(time)
64
+ # => 2022-03-31 09:00
65
+ ```
25
66
 
26
67
  ## Development
27
68
 
@@ -31,13 +72,12 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
31
72
 
32
73
  ## Contributing
33
74
 
34
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/parse-cron-ext. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/parse-cron-ext/blob/master/CODE_OF_CONDUCT.md).
75
+ Bug reports and pull requests are welcome on GitHub at https://github.com/a5-stable/parse-cron-ext.
76
+ This project is intended to be a safe, welcoming space for collaboration!
35
77
 
78
+ Any Pull Requests or Issues to improve it will be gladly welcome.
79
+ I will check them and react as soon as possible.
36
80
 
37
81
  ## License
38
82
 
39
83
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
-
41
- ## Code of Conduct
42
-
43
- Everyone interacting in the Parse::Cron::Ext project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/parse-cron-ext/blob/master/CODE_OF_CONDUCT.md).
data/lib/cron_parse.rb CHANGED
@@ -34,14 +34,6 @@ class CronParser
34
34
 
35
35
  protected
36
36
 
37
- def recursive_calculate(meth,time,num)
38
- array = [time]
39
- num.-(1).times do |num|
40
- array << self.send(meth, array.last)
41
- end
42
- array
43
- end
44
-
45
37
  def nudge_date(t, dir = :next, can_nudge_month = true)
46
38
  spec = interpolate_weekdays(t.year, t.month)[1]
47
39
  spec = [spec[@dow_offset-1]] if @dow_offset
@@ -65,12 +57,6 @@ class CronParser
65
57
  t.day = dir == :next ? valid_days.first : valid_days.last
66
58
  end
67
59
 
68
- # returns a list of days which do both match time_spec[:dom] or time_spec[:dow]
69
- def interpolate_weekdays(year, month)
70
- @_interpolate_weekdays_cache ||= {}
71
- @_interpolate_weekdays_cache["#{year}-#{month}"] ||= interpolate_weekdays_without_cache(year, month)
72
- end
73
-
74
60
  def interpolate_weekdays_without_cache(year, month)
75
61
  t = Date.new(year, month, 1)
76
62
  valid_mday, _, mday_field = time_specs[:dom]
@@ -1,7 +1,7 @@
1
1
  module Parse
2
2
  module Cron
3
3
  module Ext
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
6
6
  end
7
7
  end
@@ -6,8 +6,8 @@ Gem::Specification.new do |spec|
6
6
  spec.authors = ["a5-stable"]
7
7
  spec.email = ["sh07e1916@gmail.com"]
8
8
 
9
- spec.summary = %q{}
10
- spec.description = %q{}
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{It makes it possible to specify "end of month in March" or "Third Monday" by cron.}
11
11
  spec.homepage = "https://yahoo.co.jp"
12
12
  spec.license = "MIT"
13
13
  spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parse-cron-ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - a5-stable
@@ -24,7 +24,8 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.1.4
27
- description: ''
27
+ description: It makes it possible to specify "end of month in March" or "Third Monday"
28
+ by cron.
28
29
  email:
29
30
  - sh07e1916@gmail.com
30
31
  executables: []
@@ -70,5 +71,6 @@ requirements: []
70
71
  rubygems_version: 3.0.3.1
71
72
  signing_key:
72
73
  specification_version: 4
73
- summary: ''
74
+ summary: parse-cron-ext is a extension (monkey-patch) for parse-cron 0.1.4, which
75
+ is the latest version.
74
76
  test_files: []