ice_cube 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/ice_cube/builders/string_builder.rb +15 -23
- data/lib/ice_cube/deprecated.rb +33 -23
- data/lib/ice_cube/enumerator.rb +1 -3
- data/lib/ice_cube/errors/count_exceeded.rb +1 -1
- data/lib/ice_cube/errors/until_exceeded.rb +1 -1
- data/lib/ice_cube/flexible_hash.rb +23 -7
- data/lib/ice_cube/formatters/string.rb +155 -0
- data/lib/ice_cube/hash_input.rb +71 -0
- data/lib/ice_cube/occurrence.rb +2 -1
- data/lib/ice_cube/parsers/hash_parser.rb +87 -0
- data/lib/ice_cube/parsers/yaml_parser.rb +21 -0
- data/lib/ice_cube/rule.rb +5 -7
- data/lib/ice_cube/rules/daily_rule.rb +1 -1
- data/lib/ice_cube/rules/hourly_rule.rb +1 -1
- data/lib/ice_cube/rules/minutely_rule.rb +1 -1
- data/lib/ice_cube/rules/monthly_rule.rb +1 -1
- data/lib/ice_cube/rules/secondly_rule.rb +1 -1
- data/lib/ice_cube/rules/yearly_rule.rb +1 -1
- data/lib/ice_cube/schedule.rb +76 -64
- data/lib/ice_cube/string_helpers.rb +10 -0
- data/lib/ice_cube/time_util.rb +24 -8
- data/lib/ice_cube/validated_rule.rb +13 -6
- data/lib/ice_cube/validations/count.rb +8 -6
- data/lib/ice_cube/validations/daily_interval.rb +17 -18
- data/lib/ice_cube/validations/day.rb +8 -4
- data/lib/ice_cube/validations/day_of_month.rb +12 -10
- data/lib/ice_cube/validations/day_of_week.rb +28 -26
- data/lib/ice_cube/validations/day_of_year.rb +15 -12
- data/lib/ice_cube/validations/hour_of_day.rb +13 -11
- data/lib/ice_cube/validations/hourly_interval.rb +18 -21
- data/lib/ice_cube/validations/lock.rb +35 -14
- data/lib/ice_cube/validations/minute_of_hour.rb +13 -11
- data/lib/ice_cube/validations/minutely_interval.rb +16 -19
- data/lib/ice_cube/validations/month_of_year.rb +8 -4
- data/lib/ice_cube/validations/monthly_interval.rb +19 -17
- data/lib/ice_cube/validations/schedule_lock.rb +12 -11
- data/lib/ice_cube/validations/second_of_minute.rb +9 -5
- data/lib/ice_cube/validations/secondly_interval.rb +13 -16
- data/lib/ice_cube/validations/until.rb +16 -12
- data/lib/ice_cube/validations/weekly_interval.rb +24 -23
- data/lib/ice_cube/validations/yearly_interval.rb +14 -11
- data/lib/ice_cube/version.rb +1 -1
- data/lib/ice_cube.rb +13 -11
- data/spec/spec_helper.rb +2 -0
- metadata +24 -34
|
@@ -20,20 +20,31 @@ module IceCube
|
|
|
20
20
|
|
|
21
21
|
attr_reader :interval, :week_start
|
|
22
22
|
|
|
23
|
+
def initialize(interval, week_start)
|
|
24
|
+
@interval = interval
|
|
25
|
+
@week_start = week_start
|
|
26
|
+
end
|
|
27
|
+
|
|
23
28
|
def type
|
|
24
29
|
:day
|
|
25
30
|
end
|
|
26
31
|
|
|
27
|
-
def
|
|
28
|
-
|
|
32
|
+
def dst_adjust?
|
|
33
|
+
true
|
|
29
34
|
end
|
|
30
35
|
|
|
31
|
-
def
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
def validate(step_time, schedule)
|
|
37
|
+
t0, t1 = schedule.start_time, step_time
|
|
38
|
+
d0 = Date.new(t0.year, t0.month, t0.day)
|
|
39
|
+
d1 = Date.new(t1.year, t1.month, t1.day)
|
|
40
|
+
days = (d1 - TimeUtil.normalize_wday(d1.wday, week_start)) -
|
|
41
|
+
(d0 - TimeUtil.normalize_wday(d0.wday, week_start))
|
|
42
|
+
offset = ((days / 7) % interval).nonzero?
|
|
43
|
+
(interval - offset) * 7 if offset
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def build_s(builder)
|
|
47
|
+
builder.base = interval == 1 ? 'Weekly' : "Every #{interval} weeks"
|
|
37
48
|
end
|
|
38
49
|
|
|
39
50
|
def build_hash(builder)
|
|
@@ -41,21 +52,11 @@ module IceCube
|
|
|
41
52
|
builder[:week_start] = TimeUtil.sym_to_wday(week_start)
|
|
42
53
|
end
|
|
43
54
|
|
|
44
|
-
def
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
def validate(time, schedule)
|
|
50
|
-
date = Date.new(time.year, time.month, time.day)
|
|
51
|
-
st = schedule.start_time
|
|
52
|
-
start_date = Date.new(st.year, st.month, st.day)
|
|
53
|
-
weeks = (
|
|
54
|
-
(date - TimeUtil.normalize_wday(date.wday, week_start)) -
|
|
55
|
-
(start_date - TimeUtil.normalize_wday(start_date.wday, week_start))
|
|
56
|
-
) / 7
|
|
57
|
-
unless weeks % interval == 0
|
|
58
|
-
(interval - (weeks % interval)) * 7
|
|
55
|
+
def build_ical(builder)
|
|
56
|
+
builder['FREQ'] << 'WEEKLY'
|
|
57
|
+
unless interval == 1
|
|
58
|
+
builder['INTERVAL'] << interval
|
|
59
|
+
builder['WKST'] << week_start.to_s.upcase[0..1]
|
|
59
60
|
end
|
|
60
61
|
end
|
|
61
62
|
|
|
@@ -12,10 +12,24 @@ module IceCube
|
|
|
12
12
|
|
|
13
13
|
attr_reader :interval
|
|
14
14
|
|
|
15
|
+
def initialize(interval)
|
|
16
|
+
@interval = interval
|
|
17
|
+
end
|
|
18
|
+
|
|
15
19
|
def type
|
|
16
20
|
:year
|
|
17
21
|
end
|
|
18
22
|
|
|
23
|
+
def dst_adjust?
|
|
24
|
+
true
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def validate(step_time, schedule)
|
|
28
|
+
years = step_time.year - schedule.start_time.year
|
|
29
|
+
offset = (years % interval).nonzero?
|
|
30
|
+
interval - offset if offset
|
|
31
|
+
end
|
|
32
|
+
|
|
19
33
|
def build_s(builder)
|
|
20
34
|
builder.base = interval == 1 ? 'Yearly' : "Every #{interval} years"
|
|
21
35
|
end
|
|
@@ -31,17 +45,6 @@ module IceCube
|
|
|
31
45
|
end
|
|
32
46
|
end
|
|
33
47
|
|
|
34
|
-
def initialize(interval)
|
|
35
|
-
@interval = interval
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def validate(time, schedule)
|
|
39
|
-
years_to_start = time.year - schedule.start_time.year
|
|
40
|
-
unless years_to_start % interval == 0
|
|
41
|
-
interval - (years_to_start % interval)
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
48
|
end
|
|
46
49
|
|
|
47
50
|
end
|
data/lib/ice_cube/version.rb
CHANGED
data/lib/ice_cube.rb
CHANGED
|
@@ -1,13 +1,6 @@
|
|
|
1
1
|
require 'date'
|
|
2
2
|
require 'ice_cube/deprecated'
|
|
3
3
|
|
|
4
|
-
# Use psych if we can
|
|
5
|
-
begin
|
|
6
|
-
require 'psych'
|
|
7
|
-
rescue LoadError
|
|
8
|
-
require 'yaml'
|
|
9
|
-
end
|
|
10
|
-
|
|
11
4
|
module IceCube
|
|
12
5
|
|
|
13
6
|
autoload :VERSION, 'ice_cube/version'
|
|
@@ -23,6 +16,9 @@ module IceCube
|
|
|
23
16
|
autoload :HashBuilder, 'ice_cube/builders/hash_builder'
|
|
24
17
|
autoload :StringBuilder, 'ice_cube/builders/string_builder'
|
|
25
18
|
|
|
19
|
+
autoload :HashParser, 'ice_cube/parsers/hash_parser'
|
|
20
|
+
autoload :YamlParser, 'ice_cube/parsers/yaml_parser'
|
|
21
|
+
|
|
26
22
|
autoload :CountExceeded, 'ice_cube/errors/count_exceeded'
|
|
27
23
|
autoload :UntilExceeded, 'ice_cube/errors/until_exceeded'
|
|
28
24
|
|
|
@@ -71,10 +67,6 @@ module IceCube
|
|
|
71
67
|
ONE_DAY = ONE_HOUR * 24
|
|
72
68
|
ONE_WEEK = ONE_DAY * 7
|
|
73
69
|
|
|
74
|
-
def self.use_psych?
|
|
75
|
-
@use_psych ||= defined?(Psych) && defined?(Psych::VERSION)
|
|
76
|
-
end
|
|
77
|
-
|
|
78
70
|
# Defines the format used by IceCube when printing out Schedule#to_s.
|
|
79
71
|
# Defaults to '%B %e, %Y'
|
|
80
72
|
def self.to_s_time_format
|
|
@@ -85,4 +77,14 @@ module IceCube
|
|
|
85
77
|
def self.to_s_time_format=(format)
|
|
86
78
|
@to_s_time_format = format
|
|
87
79
|
end
|
|
80
|
+
|
|
81
|
+
# Retain backwards compatibility for schedules exported from older versions
|
|
82
|
+
# This represents the version number, 11 = 0.11, 1.0 will be 100
|
|
83
|
+
def self.compatibility
|
|
84
|
+
@compatibility ||= 11
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def self.compatibility=(version)
|
|
88
|
+
@compatibility = version
|
|
89
|
+
end
|
|
88
90
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -9,6 +9,7 @@ require File.dirname(__FILE__) + '/../lib/ice_cube'
|
|
|
9
9
|
|
|
10
10
|
DAY = Time.utc(2010, 3, 1)
|
|
11
11
|
WEDNESDAY = Time.utc(2010, 6, 23, 5, 0, 0)
|
|
12
|
+
|
|
12
13
|
WORLD_TIME_ZONES = [
|
|
13
14
|
'America/Anchorage', # -1000 / -0900
|
|
14
15
|
'Europe/London', # +0000 / +0100
|
|
@@ -48,4 +49,5 @@ RSpec.configure do |config|
|
|
|
48
49
|
end
|
|
49
50
|
end
|
|
50
51
|
end
|
|
52
|
+
|
|
51
53
|
end
|
metadata
CHANGED
|
@@ -1,78 +1,69 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ice_cube
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
5
|
-
prerelease:
|
|
4
|
+
version: 0.12.0
|
|
6
5
|
platform: ruby
|
|
7
6
|
authors:
|
|
8
7
|
- John Crepezzi
|
|
9
8
|
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 2014-04-06 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: rake
|
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
|
17
|
-
none: false
|
|
18
16
|
requirements:
|
|
19
|
-
- -
|
|
17
|
+
- - ">="
|
|
20
18
|
- !ruby/object:Gem::Version
|
|
21
19
|
version: '0'
|
|
22
20
|
type: :development
|
|
23
21
|
prerelease: false
|
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
-
none: false
|
|
26
23
|
requirements:
|
|
27
|
-
- -
|
|
24
|
+
- - ">="
|
|
28
25
|
- !ruby/object:Gem::Version
|
|
29
26
|
version: '0'
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
|
31
28
|
name: rspec
|
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
|
33
|
-
none: false
|
|
34
30
|
requirements:
|
|
35
|
-
- -
|
|
31
|
+
- - "~>"
|
|
36
32
|
- !ruby/object:Gem::Version
|
|
37
|
-
version:
|
|
33
|
+
version: 2.12.0
|
|
38
34
|
type: :development
|
|
39
35
|
prerelease: false
|
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
-
none: false
|
|
42
37
|
requirements:
|
|
43
|
-
- -
|
|
38
|
+
- - "~>"
|
|
44
39
|
- !ruby/object:Gem::Version
|
|
45
|
-
version:
|
|
40
|
+
version: 2.12.0
|
|
46
41
|
- !ruby/object:Gem::Dependency
|
|
47
42
|
name: active_support
|
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
|
49
|
-
none: false
|
|
50
44
|
requirements:
|
|
51
|
-
- -
|
|
45
|
+
- - ">="
|
|
52
46
|
- !ruby/object:Gem::Version
|
|
53
47
|
version: 3.0.0
|
|
54
48
|
type: :development
|
|
55
49
|
prerelease: false
|
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
-
none: false
|
|
58
51
|
requirements:
|
|
59
|
-
- -
|
|
52
|
+
- - ">="
|
|
60
53
|
- !ruby/object:Gem::Version
|
|
61
54
|
version: 3.0.0
|
|
62
55
|
- !ruby/object:Gem::Dependency
|
|
63
56
|
name: tzinfo
|
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
|
65
|
-
none: false
|
|
66
58
|
requirements:
|
|
67
|
-
- -
|
|
59
|
+
- - ">="
|
|
68
60
|
- !ruby/object:Gem::Version
|
|
69
61
|
version: '0'
|
|
70
62
|
type: :development
|
|
71
63
|
prerelease: false
|
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
73
|
-
none: false
|
|
74
65
|
requirements:
|
|
75
|
-
- -
|
|
66
|
+
- - ">="
|
|
76
67
|
- !ruby/object:Gem::Version
|
|
77
68
|
version: '0'
|
|
78
69
|
description: ice_cube is a recurring date library for Ruby. It allows for quick,
|
|
@@ -82,6 +73,7 @@ executables: []
|
|
|
82
73
|
extensions: []
|
|
83
74
|
extra_rdoc_files: []
|
|
84
75
|
files:
|
|
76
|
+
- lib/ice_cube.rb
|
|
85
77
|
- lib/ice_cube/builders/hash_builder.rb
|
|
86
78
|
- lib/ice_cube/builders/ical_builder.rb
|
|
87
79
|
- lib/ice_cube/builders/string_builder.rb
|
|
@@ -90,7 +82,11 @@ files:
|
|
|
90
82
|
- lib/ice_cube/errors/count_exceeded.rb
|
|
91
83
|
- lib/ice_cube/errors/until_exceeded.rb
|
|
92
84
|
- lib/ice_cube/flexible_hash.rb
|
|
85
|
+
- lib/ice_cube/formatters/string.rb
|
|
86
|
+
- lib/ice_cube/hash_input.rb
|
|
93
87
|
- lib/ice_cube/occurrence.rb
|
|
88
|
+
- lib/ice_cube/parsers/hash_parser.rb
|
|
89
|
+
- lib/ice_cube/parsers/yaml_parser.rb
|
|
94
90
|
- lib/ice_cube/rule.rb
|
|
95
91
|
- lib/ice_cube/rules/daily_rule.rb
|
|
96
92
|
- lib/ice_cube/rules/hourly_rule.rb
|
|
@@ -101,6 +97,7 @@ files:
|
|
|
101
97
|
- lib/ice_cube/rules/yearly_rule.rb
|
|
102
98
|
- lib/ice_cube/schedule.rb
|
|
103
99
|
- lib/ice_cube/single_occurrence_rule.rb
|
|
100
|
+
- lib/ice_cube/string_helpers.rb
|
|
104
101
|
- lib/ice_cube/time_step.rb
|
|
105
102
|
- lib/ice_cube/time_util.rb
|
|
106
103
|
- lib/ice_cube/validated_rule.rb
|
|
@@ -124,38 +121,31 @@ files:
|
|
|
124
121
|
- lib/ice_cube/validations/weekly_interval.rb
|
|
125
122
|
- lib/ice_cube/validations/yearly_interval.rb
|
|
126
123
|
- lib/ice_cube/version.rb
|
|
127
|
-
- lib/ice_cube.rb
|
|
128
124
|
- spec/spec_helper.rb
|
|
129
125
|
homepage: http://seejohnrun.github.com/ice_cube/
|
|
130
126
|
licenses:
|
|
131
127
|
- MIT
|
|
128
|
+
metadata: {}
|
|
132
129
|
post_install_message:
|
|
133
130
|
rdoc_options: []
|
|
134
131
|
require_paths:
|
|
135
132
|
- lib
|
|
136
133
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
137
|
-
none: false
|
|
138
134
|
requirements:
|
|
139
|
-
- -
|
|
135
|
+
- - ">="
|
|
140
136
|
- !ruby/object:Gem::Version
|
|
141
137
|
version: '0'
|
|
142
|
-
segments:
|
|
143
|
-
- 0
|
|
144
|
-
hash: 3343770401458335569
|
|
145
138
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
|
-
none: false
|
|
147
139
|
requirements:
|
|
148
|
-
- -
|
|
140
|
+
- - ">="
|
|
149
141
|
- !ruby/object:Gem::Version
|
|
150
142
|
version: '0'
|
|
151
|
-
segments:
|
|
152
|
-
- 0
|
|
153
|
-
hash: 3343770401458335569
|
|
154
143
|
requirements: []
|
|
155
144
|
rubyforge_project: ice-cube
|
|
156
|
-
rubygems_version:
|
|
145
|
+
rubygems_version: 2.2.2
|
|
157
146
|
signing_key:
|
|
158
|
-
specification_version:
|
|
147
|
+
specification_version: 4
|
|
159
148
|
summary: Ruby Date Recurrence Library
|
|
160
149
|
test_files:
|
|
161
150
|
- spec/spec_helper.rb
|
|
151
|
+
has_rdoc: true
|