ice_cube 0.16.3 → 0.17.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/config/locales/de.yml +1 -1
- data/config/locales/fr.yml +2 -2
- data/config/locales/id.yml +134 -0
- data/config/locales/it.yml +179 -0
- data/config/locales/nl.yml +133 -0
- data/config/locales/sv.yml +1 -1
- data/lib/ice_cube/builders/hash_builder.rb +1 -5
- data/lib/ice_cube/builders/ical_builder.rb +13 -15
- data/lib/ice_cube/builders/string_builder.rb +10 -16
- data/lib/ice_cube/deprecated.rb +3 -4
- data/lib/ice_cube/errors/count_exceeded.rb +0 -2
- data/lib/ice_cube/errors/until_exceeded.rb +0 -2
- data/lib/ice_cube/flexible_hash.rb +3 -7
- data/lib/ice_cube/i18n.rb +11 -23
- data/lib/ice_cube/input_alignment.rb +9 -11
- data/lib/ice_cube/null_i18n.rb +6 -6
- data/lib/ice_cube/occurrence.rb +10 -11
- data/lib/ice_cube/parsers/hash_parser.rb +3 -6
- data/lib/ice_cube/parsers/ical_parser.rb +39 -38
- data/lib/ice_cube/parsers/yaml_parser.rb +2 -4
- data/lib/ice_cube/rule.rb +7 -18
- data/lib/ice_cube/rules/daily_rule.rb +0 -4
- data/lib/ice_cube/rules/hourly_rule.rb +0 -4
- data/lib/ice_cube/rules/minutely_rule.rb +0 -4
- data/lib/ice_cube/rules/monthly_rule.rb +0 -4
- data/lib/ice_cube/rules/secondly_rule.rb +0 -4
- data/lib/ice_cube/rules/weekly_rule.rb +1 -5
- data/lib/ice_cube/rules/yearly_rule.rb +0 -4
- data/lib/ice_cube/schedule.rb +32 -40
- data/lib/ice_cube/single_occurrence_rule.rb +1 -5
- data/lib/ice_cube/time_util.rb +49 -57
- data/lib/ice_cube/validated_rule.rb +4 -10
- data/lib/ice_cube/validations/count.rb +2 -8
- data/lib/ice_cube/validations/daily_interval.rb +5 -11
- data/lib/ice_cube/validations/day.rb +7 -13
- data/lib/ice_cube/validations/day_of_month.rb +4 -10
- data/lib/ice_cube/validations/day_of_week.rb +10 -13
- data/lib/ice_cube/validations/day_of_year.rb +6 -12
- data/lib/ice_cube/validations/fixed_value.rb +9 -15
- data/lib/ice_cube/validations/hour_of_day.rb +6 -12
- data/lib/ice_cube/validations/hourly_interval.rb +3 -9
- data/lib/ice_cube/validations/lock.rb +8 -14
- data/lib/ice_cube/validations/minute_of_hour.rb +4 -10
- data/lib/ice_cube/validations/minutely_interval.rb +4 -10
- data/lib/ice_cube/validations/month_of_year.rb +2 -8
- data/lib/ice_cube/validations/monthly_interval.rb +4 -10
- data/lib/ice_cube/validations/schedule_lock.rb +0 -6
- data/lib/ice_cube/validations/second_of_minute.rb +4 -10
- data/lib/ice_cube/validations/secondly_interval.rb +2 -8
- data/lib/ice_cube/validations/until.rb +2 -8
- data/lib/ice_cube/validations/weekly_interval.rb +5 -11
- data/lib/ice_cube/validations/yearly_interval.rb +3 -9
- data/lib/ice_cube/version.rb +1 -3
- data/lib/ice_cube.rb +51 -51
- metadata +28 -12
- data/spec/spec_helper.rb +0 -79
@@ -1,7 +1,5 @@
|
|
1
1
|
module IceCube
|
2
|
-
|
3
2
|
module Validations::WeeklyInterval
|
4
|
-
|
5
3
|
def interval(interval, week_start = :sunday)
|
6
4
|
@interval = normalized_interval(interval)
|
7
5
|
@week_start = TimeUtil.wday_to_sym(week_start)
|
@@ -11,7 +9,6 @@ module IceCube
|
|
11
9
|
end
|
12
10
|
|
13
11
|
class Validation
|
14
|
-
|
15
12
|
attr_reader :interval, :week_start
|
16
13
|
|
17
14
|
def initialize(interval, week_start)
|
@@ -33,13 +30,13 @@ module IceCube
|
|
33
30
|
d0 = Date.new(t0.year, t0.month, t0.day)
|
34
31
|
d1 = Date.new(t1.year, t1.month, t1.day)
|
35
32
|
days = (d1 - TimeUtil.normalize_wday(d1.wday, week_start)) -
|
36
|
-
|
33
|
+
(d0 - TimeUtil.normalize_wday(d0.wday, week_start))
|
37
34
|
offset = ((days.to_i / 7) % interval).nonzero?
|
38
35
|
(interval - offset) * 7 if offset
|
39
36
|
end
|
40
37
|
|
41
38
|
def build_s(builder)
|
42
|
-
builder.base = IceCube::I18n.t(
|
39
|
+
builder.base = IceCube::I18n.t("ice_cube.each_week", count: interval)
|
43
40
|
end
|
44
41
|
|
45
42
|
def build_hash(builder)
|
@@ -48,15 +45,12 @@ module IceCube
|
|
48
45
|
end
|
49
46
|
|
50
47
|
def build_ical(builder)
|
51
|
-
builder[
|
48
|
+
builder["FREQ"] << "WEEKLY"
|
52
49
|
unless interval == 1
|
53
|
-
builder[
|
54
|
-
builder[
|
50
|
+
builder["INTERVAL"] << interval
|
51
|
+
builder["WKST"] << week_start.to_s.upcase[0..1]
|
55
52
|
end
|
56
53
|
end
|
57
|
-
|
58
54
|
end
|
59
|
-
|
60
55
|
end
|
61
|
-
|
62
56
|
end
|
@@ -1,7 +1,5 @@
|
|
1
1
|
module IceCube
|
2
|
-
|
3
2
|
module Validations::YearlyInterval
|
4
|
-
|
5
3
|
def interval(interval)
|
6
4
|
@interval = normalized_interval(interval)
|
7
5
|
replace_validations_for(:interval, [Validation.new(@interval)])
|
@@ -10,7 +8,6 @@ module IceCube
|
|
10
8
|
end
|
11
9
|
|
12
10
|
class Validation
|
13
|
-
|
14
11
|
attr_reader :interval
|
15
12
|
|
16
13
|
def initialize(interval)
|
@@ -32,7 +29,7 @@ module IceCube
|
|
32
29
|
end
|
33
30
|
|
34
31
|
def build_s(builder)
|
35
|
-
builder.base = IceCube::I18n.t(
|
32
|
+
builder.base = IceCube::I18n.t("ice_cube.each_year", count: interval)
|
36
33
|
end
|
37
34
|
|
38
35
|
def build_hash(builder)
|
@@ -40,14 +37,11 @@ module IceCube
|
|
40
37
|
end
|
41
38
|
|
42
39
|
def build_ical(builder)
|
43
|
-
builder[
|
40
|
+
builder["FREQ"] << "YEARLY"
|
44
41
|
unless interval == 1
|
45
|
-
builder[
|
42
|
+
builder["INTERVAL"] << interval
|
46
43
|
end
|
47
44
|
end
|
48
|
-
|
49
45
|
end
|
50
|
-
|
51
46
|
end
|
52
|
-
|
53
47
|
end
|
data/lib/ice_cube/version.rb
CHANGED
data/lib/ice_cube.rb
CHANGED
@@ -1,71 +1,71 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "date"
|
2
|
+
require "ice_cube/deprecated"
|
3
3
|
|
4
4
|
module IceCube
|
5
|
+
autoload :VERSION, "ice_cube/version"
|
5
6
|
|
6
|
-
autoload :
|
7
|
+
autoload :TimeUtil, "ice_cube/time_util"
|
8
|
+
autoload :FlexibleHash, "ice_cube/flexible_hash"
|
7
9
|
|
8
|
-
|
9
|
-
autoload :FlexibleHash, 'ice_cube/flexible_hash'
|
10
|
-
autoload :I18n, 'ice_cube/i18n'
|
10
|
+
require "ice_cube/i18n"
|
11
11
|
|
12
|
-
autoload :Rule,
|
13
|
-
autoload :Schedule,
|
14
|
-
autoload :Occurrence,
|
12
|
+
autoload :Rule, "ice_cube/rule"
|
13
|
+
autoload :Schedule, "ice_cube/schedule"
|
14
|
+
autoload :Occurrence, "ice_cube/occurrence"
|
15
15
|
|
16
|
-
autoload :IcalBuilder,
|
17
|
-
autoload :HashBuilder,
|
18
|
-
autoload :StringBuilder,
|
16
|
+
autoload :IcalBuilder, "ice_cube/builders/ical_builder"
|
17
|
+
autoload :HashBuilder, "ice_cube/builders/hash_builder"
|
18
|
+
autoload :StringBuilder, "ice_cube/builders/string_builder"
|
19
19
|
|
20
|
-
autoload :HashParser,
|
21
|
-
autoload :YamlParser,
|
22
|
-
autoload :IcalParser,
|
20
|
+
autoload :HashParser, "ice_cube/parsers/hash_parser"
|
21
|
+
autoload :YamlParser, "ice_cube/parsers/yaml_parser"
|
22
|
+
autoload :IcalParser, "ice_cube/parsers/ical_parser"
|
23
23
|
|
24
|
-
autoload :CountExceeded,
|
25
|
-
autoload :UntilExceeded,
|
24
|
+
autoload :CountExceeded, "ice_cube/errors/count_exceeded"
|
25
|
+
autoload :UntilExceeded, "ice_cube/errors/until_exceeded"
|
26
26
|
|
27
|
-
autoload :ValidatedRule,
|
28
|
-
autoload :SingleOccurrenceRule,
|
27
|
+
autoload :ValidatedRule, "ice_cube/validated_rule"
|
28
|
+
autoload :SingleOccurrenceRule, "ice_cube/single_occurrence_rule"
|
29
29
|
|
30
|
-
autoload :SecondlyRule,
|
31
|
-
autoload :MinutelyRule,
|
32
|
-
autoload :HourlyRule,
|
33
|
-
autoload :DailyRule,
|
34
|
-
autoload :WeeklyRule,
|
35
|
-
autoload :MonthlyRule,
|
36
|
-
autoload :YearlyRule,
|
30
|
+
autoload :SecondlyRule, "ice_cube/rules/secondly_rule"
|
31
|
+
autoload :MinutelyRule, "ice_cube/rules/minutely_rule"
|
32
|
+
autoload :HourlyRule, "ice_cube/rules/hourly_rule"
|
33
|
+
autoload :DailyRule, "ice_cube/rules/daily_rule"
|
34
|
+
autoload :WeeklyRule, "ice_cube/rules/weekly_rule"
|
35
|
+
autoload :MonthlyRule, "ice_cube/rules/monthly_rule"
|
36
|
+
autoload :YearlyRule, "ice_cube/rules/yearly_rule"
|
37
37
|
|
38
38
|
module Validations
|
39
|
-
autoload :FixedValue,
|
40
|
-
autoload :ScheduleLock,
|
41
|
-
|
42
|
-
autoload :Count,
|
43
|
-
autoload :Until,
|
44
|
-
|
45
|
-
autoload :SecondlyInterval,
|
46
|
-
autoload :MinutelyInterval,
|
47
|
-
autoload :DailyInterval,
|
48
|
-
autoload :WeeklyInterval,
|
49
|
-
autoload :MonthlyInterval,
|
50
|
-
autoload :YearlyInterval,
|
51
|
-
autoload :HourlyInterval,
|
52
|
-
|
53
|
-
autoload :HourOfDay,
|
54
|
-
autoload :MonthOfYear,
|
55
|
-
autoload :MinuteOfHour,
|
56
|
-
autoload :SecondOfMinute,
|
57
|
-
autoload :DayOfMonth,
|
58
|
-
autoload :DayOfWeek,
|
59
|
-
autoload :Day,
|
60
|
-
autoload :DayOfYear,
|
39
|
+
autoload :FixedValue, "ice_cube/validations/fixed_value"
|
40
|
+
autoload :ScheduleLock, "ice_cube/validations/schedule_lock"
|
41
|
+
|
42
|
+
autoload :Count, "ice_cube/validations/count"
|
43
|
+
autoload :Until, "ice_cube/validations/until"
|
44
|
+
|
45
|
+
autoload :SecondlyInterval, "ice_cube/validations/secondly_interval"
|
46
|
+
autoload :MinutelyInterval, "ice_cube/validations/minutely_interval"
|
47
|
+
autoload :DailyInterval, "ice_cube/validations/daily_interval"
|
48
|
+
autoload :WeeklyInterval, "ice_cube/validations/weekly_interval"
|
49
|
+
autoload :MonthlyInterval, "ice_cube/validations/monthly_interval"
|
50
|
+
autoload :YearlyInterval, "ice_cube/validations/yearly_interval"
|
51
|
+
autoload :HourlyInterval, "ice_cube/validations/hourly_interval"
|
52
|
+
|
53
|
+
autoload :HourOfDay, "ice_cube/validations/hour_of_day"
|
54
|
+
autoload :MonthOfYear, "ice_cube/validations/month_of_year"
|
55
|
+
autoload :MinuteOfHour, "ice_cube/validations/minute_of_hour"
|
56
|
+
autoload :SecondOfMinute, "ice_cube/validations/second_of_minute"
|
57
|
+
autoload :DayOfMonth, "ice_cube/validations/day_of_month"
|
58
|
+
autoload :DayOfWeek, "ice_cube/validations/day_of_week"
|
59
|
+
autoload :Day, "ice_cube/validations/day"
|
60
|
+
autoload :DayOfYear, "ice_cube/validations/day_of_year"
|
61
61
|
end
|
62
62
|
|
63
63
|
# Define some useful constants
|
64
64
|
ONE_SECOND = 1
|
65
65
|
ONE_MINUTE = ONE_SECOND * 60
|
66
|
-
ONE_HOUR =
|
67
|
-
ONE_DAY =
|
68
|
-
ONE_WEEK =
|
66
|
+
ONE_HOUR = ONE_MINUTE * 60
|
67
|
+
ONE_DAY = ONE_HOUR * 24
|
68
|
+
ONE_WEEK = ONE_DAY * 7
|
69
69
|
|
70
70
|
# Defines the format used by IceCube when printing out Schedule#to_s.
|
71
71
|
# Defaults to '%B %e, %Y'
|
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.
|
4
|
+
version: 0.17.0
|
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:
|
11
|
+
date: 2024-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - ">"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: standard
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
description: ice_cube is a recurring date library for Ruby. It allows for quick,
|
42
56
|
programatic expansion of recurring date rules.
|
43
57
|
email: john@crepezzi.com
|
@@ -49,7 +63,10 @@ files:
|
|
49
63
|
- config/locales/en.yml
|
50
64
|
- config/locales/es.yml
|
51
65
|
- config/locales/fr.yml
|
66
|
+
- config/locales/id.yml
|
67
|
+
- config/locales/it.yml
|
52
68
|
- config/locales/ja.yml
|
69
|
+
- config/locales/nl.yml
|
53
70
|
- config/locales/pt-BR.yml
|
54
71
|
- config/locales/ru.yml
|
55
72
|
- config/locales/sv.yml
|
@@ -101,12 +118,13 @@ files:
|
|
101
118
|
- lib/ice_cube/validations/weekly_interval.rb
|
102
119
|
- lib/ice_cube/validations/yearly_interval.rb
|
103
120
|
- lib/ice_cube/version.rb
|
104
|
-
-
|
105
|
-
homepage: http://seejohnrun.github.com/ice_cube/
|
121
|
+
homepage: https://ice-cube-ruby.github.io/ice_cube/
|
106
122
|
licenses:
|
107
123
|
- MIT
|
108
|
-
metadata:
|
109
|
-
|
124
|
+
metadata:
|
125
|
+
changelog_uri: https://github.com/ice-cube-ruby/ice_cube/blob/master/CHANGELOG.md
|
126
|
+
wiki_uri: https://github.com/ice-cube-ruby/ice_cube/wiki
|
127
|
+
post_install_message:
|
110
128
|
rdoc_options: []
|
111
129
|
require_paths:
|
112
130
|
- lib
|
@@ -121,10 +139,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
139
|
- !ruby/object:Gem::Version
|
122
140
|
version: '0'
|
123
141
|
requirements: []
|
124
|
-
|
125
|
-
|
126
|
-
signing_key:
|
142
|
+
rubygems_version: 3.5.11
|
143
|
+
signing_key:
|
127
144
|
specification_version: 4
|
128
145
|
summary: Ruby Date Recurrence Library
|
129
|
-
test_files:
|
130
|
-
- spec/spec_helper.rb
|
146
|
+
test_files: []
|
data/spec/spec_helper.rb
DELETED
@@ -1,79 +0,0 @@
|
|
1
|
-
require "bundler/setup"
|
2
|
-
require 'ice_cube'
|
3
|
-
require 'timeout'
|
4
|
-
|
5
|
-
begin
|
6
|
-
require 'simplecov'
|
7
|
-
SimpleCov.start
|
8
|
-
rescue LoadError
|
9
|
-
# okay
|
10
|
-
end
|
11
|
-
|
12
|
-
IceCube.compatibility = 12
|
13
|
-
|
14
|
-
DAY = Time.utc(2010, 3, 1)
|
15
|
-
WEDNESDAY = Time.utc(2010, 6, 23, 5, 0, 0)
|
16
|
-
|
17
|
-
WORLD_TIME_ZONES = [
|
18
|
-
'America/Anchorage', # -1000 / -0900
|
19
|
-
'Europe/London', # +0000 / +0100
|
20
|
-
'Pacific/Auckland', # +1200 / +1300
|
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
|
-
|
34
|
-
RSpec.configure do |config|
|
35
|
-
# Enable flags like --only-failures and --next-failure
|
36
|
-
config.example_status_persistence_file_path = ".rspec_status"
|
37
|
-
|
38
|
-
config.expect_with :rspec do |c|
|
39
|
-
c.syntax = :expect
|
40
|
-
end
|
41
|
-
|
42
|
-
Dir[File.dirname(__FILE__) + '/support/**/*'].each { |f| require f }
|
43
|
-
|
44
|
-
config.warnings = true
|
45
|
-
|
46
|
-
config.include WarningHelpers
|
47
|
-
|
48
|
-
config.before :each do |example|
|
49
|
-
if example.metadata[:requires_active_support]
|
50
|
-
raise 'ActiveSupport required but not present' unless defined?(ActiveSupport)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
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
|
66
|
-
end
|
67
|
-
|
68
|
-
config.around :each, expect_warnings: true do |example|
|
69
|
-
capture_warnings do
|
70
|
-
example.run
|
71
|
-
end
|
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
|
79
|
-
end
|