ice_cube 0.16.0 → 0.16.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +5 -5
  2. data/config/locales/de.yml +1 -1
  3. data/config/locales/en.yml +7 -46
  4. data/config/locales/es.yml +47 -83
  5. data/config/locales/fr.yml +2 -2
  6. data/config/locales/it.yml +179 -0
  7. data/config/locales/ja.yml +52 -29
  8. data/config/locales/nl.yml +133 -0
  9. data/config/locales/pt-BR.yml +178 -0
  10. data/config/locales/sv.yml +1 -1
  11. data/lib/ice_cube/i18n.rb +11 -12
  12. data/lib/ice_cube/input_alignment.rb +89 -0
  13. data/lib/ice_cube/null_i18n.rb +12 -6
  14. data/lib/ice_cube/occurrence.rb +25 -23
  15. data/lib/ice_cube/parsers/ical_parser.rb +8 -5
  16. data/lib/ice_cube/rule.rb +5 -13
  17. data/lib/ice_cube/rules/daily_rule.rb +9 -0
  18. data/lib/ice_cube/rules/hourly_rule.rb +9 -0
  19. data/lib/ice_cube/rules/minutely_rule.rb +9 -0
  20. data/lib/ice_cube/rules/monthly_rule.rb +9 -0
  21. data/lib/ice_cube/rules/secondly_rule.rb +9 -0
  22. data/lib/ice_cube/rules/weekly_rule.rb +30 -9
  23. data/lib/ice_cube/rules/yearly_rule.rb +9 -0
  24. data/lib/ice_cube/schedule.rb +30 -29
  25. data/lib/ice_cube/single_occurrence_rule.rb +4 -0
  26. data/lib/ice_cube/time_util.rb +65 -46
  27. data/lib/ice_cube/validated_rule.rb +18 -24
  28. data/lib/ice_cube/validations/count.rb +1 -2
  29. data/lib/ice_cube/validations/daily_interval.rb +5 -1
  30. data/lib/ice_cube/validations/day.rb +6 -2
  31. data/lib/ice_cube/validations/day_of_month.rb +5 -0
  32. data/lib/ice_cube/validations/day_of_week.rb +1 -1
  33. data/lib/ice_cube/validations/hour_of_day.rb +23 -0
  34. data/lib/ice_cube/validations/hourly_interval.rb +2 -0
  35. data/lib/ice_cube/validations/minute_of_hour.rb +16 -0
  36. data/lib/ice_cube/validations/minutely_interval.rb +2 -0
  37. data/lib/ice_cube/validations/month_of_year.rb +6 -1
  38. data/lib/ice_cube/validations/monthly_interval.rb +4 -1
  39. data/lib/ice_cube/validations/schedule_lock.rb +4 -0
  40. data/lib/ice_cube/validations/second_of_minute.rb +19 -3
  41. data/lib/ice_cube/validations/secondly_interval.rb +2 -0
  42. data/lib/ice_cube/validations/until.rb +1 -2
  43. data/lib/ice_cube/validations/weekly_interval.rb +0 -2
  44. data/lib/ice_cube/version.rb +1 -1
  45. data/lib/ice_cube.rb +1 -3
  46. data/spec/spec_helper.rb +32 -9
  47. metadata +10 -7
@@ -4,15 +4,27 @@ module IceCube
4
4
 
5
5
  def second_of_minute(*seconds)
6
6
  seconds.flatten.each do |second|
7
- unless second.is_a?(Integer)
8
- raise ArgumentError, "Expecting Integer value for second, got #{second.inspect}"
9
- end
7
+ unless second.is_a?(Integer)
8
+ raise ArgumentError, "Expecting Integer value for second, got #{second.inspect}"
9
+ end
10
+
11
+ verify_alignment(second, :sec, :second_of_minute) { |error| raise error }
12
+
10
13
  validations_for(:second_of_minute) << Validation.new(second)
11
14
  end
12
15
  clobber_base_validations :sec
13
16
  self
14
17
  end
15
18
 
19
+ def realign(opening_time, start_time)
20
+ return super unless validations[:second_of_minute]
21
+
22
+ first_second = Array(validations[:second_of_minute]).min_by(&:value)
23
+ time = TimeUtil::TimeWrapper.new(start_time, false)
24
+ time.sec = first_second.value
25
+ super opening_time, time.to_time
26
+ end
27
+
16
28
  class Validation < Validations::FixedValue
17
29
 
18
30
  attr_reader :second
@@ -22,6 +34,10 @@ module IceCube
22
34
  @second = second
23
35
  end
24
36
 
37
+ def key
38
+ :second_of_minute
39
+ end
40
+
25
41
  def type
26
42
  :sec
27
43
  end
@@ -3,6 +3,8 @@ module IceCube
3
3
  module Validations::SecondlyInterval
4
4
 
5
5
  def interval(interval)
6
+ verify_alignment(interval, :sec, :interval) { |error| raise error }
7
+
6
8
  @interval = normalized_interval(interval)
7
9
  replace_validations_for(:interval, [Validation.new(@interval)])
8
10
  clobber_base_validations(:sec)
@@ -6,12 +6,11 @@ module IceCube
6
6
 
7
7
  # Value reader for limit
8
8
  def until_time
9
- @until
9
+ (arr = @validations[:until]) && (val = arr[0]) && val.time
10
10
  end
11
11
  deprecated_alias :until_date, :until_time
12
12
 
13
13
  def until(time)
14
- @until = time
15
14
  replace_validations_for(:until, time.nil? ? nil : [Validation.new(time)])
16
15
  self
17
16
  end
@@ -1,5 +1,3 @@
1
- require 'date'
2
-
3
1
  module IceCube
4
2
 
5
3
  module Validations::WeeklyInterval
@@ -1,5 +1,5 @@
1
1
  module IceCube
2
2
 
3
- VERSION = '0.16.0'
3
+ VERSION = '0.16.4'
4
4
 
5
5
  end
data/lib/ice_cube.rb CHANGED
@@ -1,8 +1,5 @@
1
1
  require 'date'
2
2
  require 'ice_cube/deprecated'
3
- require 'ice_cube/i18n'
4
-
5
- IceCube::I18n.detect_backend!
6
3
 
7
4
  module IceCube
8
5
 
@@ -10,6 +7,7 @@ module IceCube
10
7
 
11
8
  autoload :TimeUtil, 'ice_cube/time_util'
12
9
  autoload :FlexibleHash, 'ice_cube/flexible_hash'
10
+ autoload :I18n, 'ice_cube/i18n'
13
11
 
14
12
  autoload :Rule, 'ice_cube/rule'
15
13
  autoload :Schedule, 'ice_cube/schedule'
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "bundler/setup"
2
2
  require 'ice_cube'
3
+ require 'timeout'
3
4
 
4
5
  begin
5
6
  require 'simplecov'
@@ -19,6 +20,17 @@ WORLD_TIME_ZONES = [
19
20
  'Pacific/Auckland', # +1200 / +1300
20
21
  ]
21
22
 
23
+ # TODO: enable warnings here and update specs to call IceCube objects correctly
24
+ def Object.const_missing(sym)
25
+ case sym
26
+ when :Schedule, :Rule, :Occurrence, :TimeUtil, :ONE_DAY, :ONE_HOUR, :ONE_MINUTE
27
+ # warn "Use IceCube::#{sym}", caller[0]
28
+ IceCube.const_get(sym)
29
+ else
30
+ super
31
+ end
32
+ end
33
+
22
34
  RSpec.configure do |config|
23
35
  # Enable flags like --only-failures and --next-failure
24
36
  config.example_status_persistence_file_path = ".rspec_status"
@@ -29,6 +41,8 @@ RSpec.configure do |config|
29
41
 
30
42
  Dir[File.dirname(__FILE__) + '/support/**/*'].each { |f| require f }
31
43
 
44
+ config.warnings = true
45
+
32
46
  config.include WarningHelpers
33
47
 
34
48
  config.before :each do |example|
@@ -37,15 +51,18 @@ RSpec.configure do |config|
37
51
  end
38
52
  end
39
53
 
40
- config.around :each do |example|
41
- if zone = example.metadata[:system_time_zone]
42
- orig_zone = ENV['TZ']
43
- ENV['TZ'] = zone
44
- example.run
45
- ENV['TZ'] = orig_zone
46
- else
47
- example.run
48
- end
54
+ config.around :each, system_time_zone: true do |example|
55
+ orig_zone = ENV['TZ']
56
+ ENV['TZ'] = example.metadata[:system_time_zone]
57
+ example.run
58
+ ENV['TZ'] = orig_zone
59
+ end
60
+
61
+ config.around :each, locale: true do |example|
62
+ orig_locale = I18n.locale
63
+ I18n.locale = example.metadata[:locale]
64
+ example.run
65
+ I18n.locale = orig_locale
49
66
  end
50
67
 
51
68
  config.around :each, expect_warnings: true do |example|
@@ -53,4 +70,10 @@ RSpec.configure do |config|
53
70
  example.run
54
71
  end
55
72
  end
73
+
74
+ config.around :each do |example|
75
+ Timeout.timeout(example.metadata.fetch(:timeout, 1)) do
76
+ example.run
77
+ end
78
+ end
56
79
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ice_cube
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.16.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Crepezzi
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-13 00:00:00.000000000 Z
11
+ date: 2021-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -49,7 +49,10 @@ files:
49
49
  - config/locales/en.yml
50
50
  - config/locales/es.yml
51
51
  - config/locales/fr.yml
52
+ - config/locales/it.yml
52
53
  - config/locales/ja.yml
54
+ - config/locales/nl.yml
55
+ - config/locales/pt-BR.yml
53
56
  - config/locales/ru.yml
54
57
  - config/locales/sv.yml
55
58
  - lib/ice_cube.rb
@@ -61,6 +64,7 @@ files:
61
64
  - lib/ice_cube/errors/until_exceeded.rb
62
65
  - lib/ice_cube/flexible_hash.rb
63
66
  - lib/ice_cube/i18n.rb
67
+ - lib/ice_cube/input_alignment.rb
64
68
  - lib/ice_cube/null_i18n.rb
65
69
  - lib/ice_cube/occurrence.rb
66
70
  - lib/ice_cube/parsers/hash_parser.rb
@@ -104,7 +108,7 @@ homepage: http://seejohnrun.github.com/ice_cube/
104
108
  licenses:
105
109
  - MIT
106
110
  metadata: {}
107
- post_install_message:
111
+ post_install_message:
108
112
  rdoc_options: []
109
113
  require_paths:
110
114
  - lib
@@ -119,9 +123,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
123
  - !ruby/object:Gem::Version
120
124
  version: '0'
121
125
  requirements: []
122
- rubyforge_project: ice-cube
123
- rubygems_version: 2.5.2
124
- signing_key:
126
+ rubygems_version: 3.1.4
127
+ signing_key:
125
128
  specification_version: 4
126
129
  summary: Ruby Date Recurrence Library
127
130
  test_files: