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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ba8b6abc6f50ac6f6176a927a2bda8692ec38cab
4
- data.tar.gz: 53047e7380933ac99edf6c966ddb3119eeedc6f7
2
+ SHA256:
3
+ metadata.gz: 7eed5dcd06a159e7d2938a08db2d6d05e1a10bce972de72e52f0e1adec664d73
4
+ data.tar.gz: d1a424b58262560220e25b2f4ff59adf65c5d1a456796140cadbffc942e085bc
5
5
  SHA512:
6
- metadata.gz: 25b9305fc0e172ceb0561a7438fddc084b24d0af60e66e3f574bc61e59f7b6ba8bb62e31749fa836eb5a58baf6e1e600682c359fb9d1a89fa4107c8371e9b529
7
- data.tar.gz: 2ff401bc058ca1e054a4c628a693846158653587502f0b48cc23b77d2d4f35c666dcfdf05e8a60535b73dd154872d9acf5518ccc554bdad10e12c7871b22e3ea
6
+ metadata.gz: 5f26045481de720482e81381b3b031493ac274d43343c08a741612e4a337181f0582632431a6b8d7b0e962474648831dd44226df237d0e08d8fad4e78a21ae55
7
+ data.tar.gz: fe616deec660d0968a622f825c181a9bd4bc747ed05342a49c49007455dded6b3c843493c50ee97ae6d5fc9cc57951e8b5d3f9a2f28616490ad9ae9527358dd6
data/.rubocop.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  AllCops:
2
+ TargetRubyVersion: 2.3
2
3
  DisplayCopNames: true
3
4
 
4
5
  Style/HashSyntax:
@@ -24,3 +25,7 @@ Metrics/MethodLength:
24
25
 
25
26
  Metrics/ClassLength:
26
27
  Max: 200
28
+
29
+ Metrics/BlockLength:
30
+ Exclude:
31
+ - 'spec/**/*'
data/.travis.yml CHANGED
@@ -1,7 +1,9 @@
1
1
  language: ruby
2
2
  rvm:
3
3
  - ruby-2.2.2
4
- - jruby-9.0.1.0
4
+ - ruby-2.6
5
+ - jruby-9.1.17.0
6
+ - jruby-9.2.9.0
5
7
  before_install: gem install bundler -v 1.10.6
6
8
  addons:
7
9
  code_climate:
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  gemspec
data/Guardfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # A sample Guardfile
2
4
  # More info at https://github.com/guard/guard#readme
3
5
 
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 => [:spec, :rubocop]
10
+ task :default => %i[spec rubocop]
@@ -1,5 +1,6 @@
1
- # -*- encoding: utf-8 -*-
2
- $LOAD_PATH.push File.expand_path('../lib', __FILE__)
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 'rake', '~> 10'
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'ice_cube'
2
4
 
3
5
  # core extensions
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module IceCube # :nodoc: all
2
4
  class Schedule
3
5
  extend ::IceCubeCron::Extension
@@ -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
- :minute,
21
- :hour,
22
- :day_of_month,
23
- :month,
24
- :day_of_week,
25
- :year
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.select! do |_key, value|
181
- !value.nil?
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
  # This adds the `.from_cron` extension to the `::IceCube::Schedule` class
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module IceCubeCron # :nodoc: all
2
4
  module ParserAttribute # :nodoc:
3
5
  def self.included(base)
@@ -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?
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module IceCubeCron # :nodoc: all
2
4
  ##
3
5
  # :category: Utilities
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module IceCubeCron # :nodoc: all
2
- VERSION = '1.1.1'.freeze
4
+ VERSION = '1.2.0'
3
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module IceCube
2
4
  class ValidatedRule < Rule # :nodoc:
3
5
  include Validations::Year
@@ -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?(Fixnum)
13
- raise ArgumentError, "expecting Fixnum value for year, got #{year.inspect}"
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
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe ::IceCubeCron::ExpressionParser do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe ::IceCubeCron::Extension do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe ::IceCubeCron::RuleBuilder do
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'spec_helper'
2
4
 
3
5
  describe ::IceCubeCron::Util do
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # This file was generated by the `rspec --init` command. Conventionally, all
2
4
  # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
5
  # The generated `.rspec` file contains `--require spec_helper` which will cause
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.1.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: 2016-07-20 00:00:00.000000000 Z
11
+ date: 2020-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: ice_cube
14
+ name: activesupport
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "<="
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.13.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.13.0
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: activesupport
28
+ name: ice_cube
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "<="
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
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: '0'
40
+ version: 0.13.0
41
41
  - !ruby/object:Gem::Dependency
42
- name: rake
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: '10'
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: '10'
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: rspec
70
+ name: rake
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '3.3'
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: '3.3'
82
+ version: '10'
83
83
  - !ruby/object:Gem::Dependency
84
- name: rubocop
84
+ name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
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: '0'
96
+ version: '3.3'
97
97
  - !ruby/object:Gem::Dependency
98
- name: codeclimate-test-reporter
98
+ name: rubocop
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0.4'
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.4'
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
- rubyforge_project:
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.