ice_cube_cron 1.0.1 → 1.1.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
  SHA1:
3
- metadata.gz: b8587cad1d7f913b7bb81a58e4e3eac37db6d1dc
4
- data.tar.gz: 02fc4ecba72f46539c6d2ef155b8b9f64e6d0e88
3
+ metadata.gz: a337f8cf564877d079a3b1a3a53b4e8d5cbc8d42
4
+ data.tar.gz: 5888cfd5aff2af878068c572535cef08491b6c56
5
5
  SHA512:
6
- metadata.gz: 9d0e3698b6657bb35da47fba62350d2ad33db1ace17ec6ba617f9b6eab58a7f7cb28f4f6d83e3f46bf1086600fba1711b5b9f02fc40b49a83cc7abab551aa24e
7
- data.tar.gz: 34c79837a63121f7b7f892305cf749c13323e9d515b5328d1daff80ac9d982a9f94a2d21b907c8fb2354e739e0d5718cadb029491e91e763b6c3abf9af57cdf6
6
+ metadata.gz: 0dfe6377d1577e6c94adc43c10971f68f9e07612affb3e8ec50cdfcb6d1965b0f1c921fd1c1e0836c285d7cc156ac9fe68a1da8ff0d00e700bb7e82b39f7d4ff
7
+ data.tar.gz: 41d6141e77d63c32cc1d9e7857ca1d265795a148b35333dee933bf864ad6389157423faf6a02fa214511d09b78febd6adc90956617ae25eb798138cb72d4beba
data/.rubocop.yml CHANGED
@@ -7,6 +7,9 @@ Style/HashSyntax:
7
7
  Style/AccessModifierIndentation:
8
8
  EnforcedStyle: outdent
9
9
 
10
+ Style/Alias:
11
+ EnforcedStyle: prefer_alias_method
12
+
10
13
  Style/Documentation:
11
14
  Enabled: true
12
15
 
data/README.md CHANGED
@@ -57,7 +57,7 @@ schedule.occurrences_between(::Date.new(2015, 3, 5), ::Date.new(2015, 6, 5))
57
57
  |1st of every month||||1||
58
58
  |1st and 15th of every month||||1,15||
59
59
  |every monday|||||1|
60
- |1st monday of every month|||||1#1|
60
+ |1st tuesday of every month|||||2#1|
61
61
  |ever other friday|2||||5|
62
62
  |every 6 months on the 5th|6|||5||
63
63
  |last friday of every month|||||5L|
@@ -27,6 +27,6 @@ Gem::Specification.new do |s|
27
27
  s.add_development_dependency 'rake', '~> 10'
28
28
  s.add_development_dependency 'pry', '~> 0'
29
29
  s.add_development_dependency 'rspec', '~> 3.3'
30
- s.add_development_dependency 'rubocop', '~> 0.34'
30
+ s.add_development_dependency 'rubocop', '~> 0'
31
31
  s.add_development_dependency 'codeclimate-test-reporter', '~> 0.4'
32
32
  end
@@ -14,7 +14,7 @@ module IceCubeCron # :nodoc:
14
14
  :hour => nil,
15
15
  :minute => nil,
16
16
  :until => nil
17
- }
17
+ }.freeze
18
18
 
19
19
  EXPRESSION_PART_KEYS = [
20
20
  :minute,
@@ -23,7 +23,7 @@ module IceCubeCron # :nodoc:
23
23
  :month,
24
24
  :day_of_week,
25
25
  :year
26
- ]
26
+ ].freeze
27
27
 
28
28
  ##
29
29
  # Create a parsed expression
@@ -83,7 +83,9 @@ module IceCubeCron # :nodoc:
83
83
  ExpressionParser.sanitize_integer_array_param(val)
84
84
  end
85
85
 
86
- parser_attribute_accessor :until
86
+ parser_attribute_accessor :until do |val|
87
+ ::IceCubeCron::Util.sanitize_date_param(val)
88
+ end
87
89
 
88
90
  ##
89
91
  # Sanitize given value to a valid day parameter
@@ -178,7 +180,7 @@ module IceCubeCron # :nodoc:
178
180
  expression_parts.select! do |_key, value|
179
181
  !value.nil?
180
182
  end
181
- expression_parts.merge!(:interval => interval) unless interval.nil?
183
+ expression_parts[:interval] = interval unless interval.nil?
182
184
 
183
185
  expression_parts
184
186
  end
@@ -10,7 +10,7 @@ module IceCubeCron # :nodoc: all
10
10
 
11
11
  module ClassMethods # :nodoc:
12
12
  def parser_attribute_accessor(attr_name, &cleanser)
13
- getter = "#{attr_name}".to_sym
13
+ getter = attr_name.to_s.to_sym
14
14
  setter = "#{attr_name}=".to_sym
15
15
 
16
16
  define_method(getter) do
@@ -18,7 +18,7 @@ module IceCubeCron # :nodoc: all
18
18
  end
19
19
 
20
20
  define_method(setter) do |val|
21
- val = cleanser.call(val) if cleanser
21
+ val = yield val if cleanser
22
22
  expression_hash[getter] = val
23
23
  end
24
24
 
@@ -4,6 +4,7 @@ module IceCubeCron # :nodoc: all
4
4
  #
5
5
  module Util
6
6
  def self.sanitize_date_param(date)
7
+ date = Date.parse(date) if date.is_a?(::String)
7
8
  date = date.to_time(:utc) if date.is_a?(::Date) && !date.is_a?(::DateTime)
8
9
  date = date.to_time.utc if date.is_a?(::DateTime)
9
10
  date = Time.at(date).utc if date.is_a?(::Integer)
@@ -1,3 +1,3 @@
1
1
  module IceCubeCron # :nodoc: all
2
- VERSION = '1.0.1'
2
+ VERSION = '1.1.0'.freeze
3
3
  end
@@ -317,6 +317,28 @@ describe ::IceCubeCron::ExpressionParser do
317
317
  expect(expression.day_of_week).to eq([{ 1 => [-1] }])
318
318
  end
319
319
  end
320
+
321
+ describe 'until' do
322
+ it '[]' do
323
+ expect(expression.until).to eq(nil)
324
+ end
325
+
326
+ it '[]=' do
327
+ expression.until = 1_453_334_400
328
+ expect(expression.until).to eq(::Time.at(1_453_334_400).utc)
329
+ end
330
+
331
+ it 'sanitizes' do
332
+ expression.until = 1_453_334_400
333
+ expect(expression.until).to eq(::Time.at(1_453_334_400).utc)
334
+
335
+ expression.until = nil
336
+ expect(expression.until).to eq(nil)
337
+
338
+ expression.until = ::Date.new(2016, 1, 21)
339
+ expect(expression.until).to eq(::Time.at(1_453_334_400).utc)
340
+ end
341
+ end
320
342
  end
321
343
 
322
344
  describe 'invalid parameters' do
@@ -13,5 +13,9 @@ describe ::IceCubeCron::Util do
13
13
  it 'should handle datetime' do
14
14
  expect(described_class.sanitize_date_param(DateTime.new(2015, 5, 1, 0, 0, 0))).to eq(DateTime.new(2015, 5, 1, 0, 0, 0))
15
15
  end
16
+
17
+ it 'should handle string' do
18
+ expect(described_class.sanitize_date_param('2015-5-1')).to eq(DateTime.new(2015, 5, 1, 0, 0, 0))
19
+ end
16
20
  end
17
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ice_cube_cron
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.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: 2015-12-07 00:00:00.000000000 Z
11
+ date: 2016-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ice_cube
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0.34'
89
+ version: '0'
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.34'
96
+ version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: codeclimate-test-reporter
99
99
  requirement: !ruby/object:Gem::Requirement