ice_cube_cron 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +5 -0
- data/.travis.yml +3 -1
- data/Gemfile +2 -0
- data/Guardfile +2 -0
- data/Rakefile +3 -1
- data/ice_cube_cron.gemspec +6 -5
- data/lib/ice_cube_cron.rb +2 -0
- data/lib/ice_cube_cron/base.rb +2 -0
- data/lib/ice_cube_cron/expression_parser.rb +12 -9
- data/lib/ice_cube_cron/extension.rb +2 -0
- data/lib/ice_cube_cron/parser_attribute.rb +2 -0
- data/lib/ice_cube_cron/rule_builder.rb +4 -0
- data/lib/ice_cube_cron/util.rb +2 -0
- data/lib/ice_cube_cron/version.rb +3 -1
- data/lib/ice_cube_ext/validated_rule.rb +2 -0
- data/lib/ice_cube_ext/validations/year.rb +5 -3
- data/spec/lib/ice_cube_cron/expression_parser_spec.rb +2 -0
- data/spec/lib/ice_cube_cron/extension_spec.rb +2 -0
- data/spec/lib/ice_cube_cron/rule_builder_spec.rb +2 -0
- data/spec/lib/ice_cube_cron/util_spec.rb +2 -0
- data/spec/spec_helper.rb +2 -0
- metadata +25 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7eed5dcd06a159e7d2938a08db2d6d05e1a10bce972de72e52f0e1adec664d73
|
4
|
+
data.tar.gz: d1a424b58262560220e25b2f4ff59adf65c5d1a456796140cadbffc942e085bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f26045481de720482e81381b3b031493ac274d43343c08a741612e4a337181f0582632431a6b8d7b0e962474648831dd44226df237d0e08d8fad4e78a21ae55
|
7
|
+
data.tar.gz: fe616deec660d0968a622f825c181a9bd4bc747ed05342a49c49007455dded6b3c843493c50ee97ae6d5fc9cc57951e8b5d3f9a2f28616490ad9ae9527358dd6
|
data/.rubocop.yml
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Guardfile
CHANGED
data/Rakefile
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'bundler/gem_tasks'
|
2
4
|
require 'rspec/core/rake_task'
|
3
5
|
require 'rubocop/rake_task'
|
@@ -5,4 +7,4 @@ require 'rubocop/rake_task'
|
|
5
7
|
RuboCop::RakeTask.new
|
6
8
|
RSpec::Core::RakeTask.new(:spec)
|
7
9
|
|
8
|
-
task :default => [
|
10
|
+
task :default => %i[spec rubocop]
|
data/ice_cube_cron.gemspec
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
$LOAD_PATH.push File.expand_path('lib', __dir__)
|
3
4
|
require 'ice_cube_cron/version'
|
4
5
|
|
5
6
|
Gem::Specification.new do |s|
|
@@ -18,15 +19,15 @@ Gem::Specification.new do |s|
|
|
18
19
|
##
|
19
20
|
# Dependencies
|
20
21
|
#
|
21
|
-
s.add_dependency 'ice_cube', '<= 0.13.0'
|
22
22
|
s.add_dependency 'activesupport'
|
23
|
+
s.add_dependency 'ice_cube', '<= 0.13.0'
|
23
24
|
|
24
25
|
##
|
25
26
|
# Development Dependencies
|
26
27
|
#
|
27
|
-
s.add_development_dependency '
|
28
|
+
s.add_development_dependency 'codeclimate-test-reporter', '~> 0.4'
|
28
29
|
s.add_development_dependency 'pry', '~> 0'
|
30
|
+
s.add_development_dependency 'rake', '~> 10'
|
29
31
|
s.add_development_dependency 'rspec', '~> 3.3'
|
30
32
|
s.add_development_dependency 'rubocop', '~> 0'
|
31
|
-
s.add_development_dependency 'codeclimate-test-reporter', '~> 0.4'
|
32
33
|
end
|
data/lib/ice_cube_cron.rb
CHANGED
data/lib/ice_cube_cron/base.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module IceCubeCron # :nodoc:
|
2
4
|
##
|
3
5
|
# Parses the incoming expression and splits it into meaningful parts.
|
@@ -16,13 +18,13 @@ module IceCubeCron # :nodoc:
|
|
16
18
|
:until => nil
|
17
19
|
}.freeze
|
18
20
|
|
19
|
-
EXPRESSION_PART_KEYS = [
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
EXPRESSION_PART_KEYS = %i[
|
22
|
+
minute
|
23
|
+
hour
|
24
|
+
day_of_month
|
25
|
+
month
|
26
|
+
day_of_week
|
27
|
+
year
|
26
28
|
].freeze
|
27
29
|
|
28
30
|
##
|
@@ -138,6 +140,7 @@ module IceCubeCron # :nodoc:
|
|
138
140
|
#
|
139
141
|
def self.sanitize_week_day_param(param)
|
140
142
|
return nil if param.blank?
|
143
|
+
|
141
144
|
param.to_s.split(',').map do |element|
|
142
145
|
if element =~ /[0-9]+#[0-9]+/
|
143
146
|
parts = element.split('#')
|
@@ -177,8 +180,8 @@ module IceCubeCron # :nodoc:
|
|
177
180
|
parts, interval = split_parts_and_interval(expression_str)
|
178
181
|
|
179
182
|
expression_parts = ::Hash[EXPRESSION_PART_KEYS.zip(parts)]
|
180
|
-
expression_parts.
|
181
|
-
|
183
|
+
expression_parts.reject! do |_key, value|
|
184
|
+
value.nil?
|
182
185
|
end
|
183
186
|
expression_parts[:interval] = interval unless interval.nil?
|
184
187
|
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module IceCubeCron # :nodoc:
|
2
4
|
##
|
3
5
|
# Generates Rules based on parsed expression
|
@@ -20,6 +22,7 @@ module IceCubeCron # :nodoc:
|
|
20
22
|
# :nodoc:
|
21
23
|
def nth_day?(param)
|
22
24
|
return false if param.nil? || param.empty?
|
25
|
+
|
23
26
|
param[0].is_a?(::Hash)
|
24
27
|
end
|
25
28
|
|
@@ -31,6 +34,7 @@ module IceCubeCron # :nodoc:
|
|
31
34
|
def build_root_recurrence_rule(expression) # :nodoc:
|
32
35
|
return ::IceCube::Rule.minutely(expression.interval) if expression.minute.blank?
|
33
36
|
return ::IceCube::Rule.hourly(expression.interval) if expression.hour.blank?
|
37
|
+
|
34
38
|
unless nth_day?(expression.day_of_week)
|
35
39
|
return ::IceCube::Rule.weekly(expression.interval) if expression.day_of_month.blank? && !expression.day_of_week.blank?
|
36
40
|
return ::IceCube::Rule.daily(expression.interval) if expression.day_of_month.blank?
|
data/lib/ice_cube_cron/util.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module IceCube
|
2
4
|
module Validations
|
3
5
|
##
|
@@ -9,11 +11,11 @@ module IceCube
|
|
9
11
|
#
|
10
12
|
def year(*years)
|
11
13
|
years.flatten.each do |year|
|
12
|
-
unless year.is_a?(
|
13
|
-
|
14
|
-
end
|
14
|
+
raise ArgumentError, "expecting Fixnum value for year, got #{year.inspect}" unless year.is_a?(Integer)
|
15
|
+
|
15
16
|
validations_for(:year) << Validation.new(year)
|
16
17
|
end
|
18
|
+
|
17
19
|
::IceCube::Validations::FixedValue::INTERVALS[:year] = 100
|
18
20
|
self
|
19
21
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,57 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ice_cube_cron
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Nichols
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0
|
19
|
+
version: '0'
|
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: 0
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: ice_cube
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "<="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.13.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "<="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 0.13.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: codeclimate-test-reporter
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '0.4'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '0.4'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: pry
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -67,47 +67,47 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '10'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '10'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: rspec
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '3.3'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '3.3'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: rubocop
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '0
|
103
|
+
version: '0'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '0
|
110
|
+
version: '0'
|
111
111
|
description: Adds methods to ice_cube that creation of schedules using standard cron
|
112
112
|
expressions.
|
113
113
|
email:
|
@@ -162,8 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
162
162
|
- !ruby/object:Gem::Version
|
163
163
|
version: '0'
|
164
164
|
requirements: []
|
165
|
-
|
166
|
-
rubygems_version: 2.4.8
|
165
|
+
rubygems_version: 3.1.2
|
167
166
|
signing_key:
|
168
167
|
specification_version: 4
|
169
168
|
summary: Adds ability to create ice_cube schedules from cron expressions.
|