dgp-schedule_attributes 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -2
- data/Gemfile.lock +1 -1
- data/README.markdown +1 -1
- data/gemfiles/rails_3.2.gemfile.lock +1 -1
- data/gemfiles/rails_4.0.gemfile.lock +1 -1
- data/gemfiles/rails_4.1.gemfile.lock +1 -1
- data/gemfiles/rails_4.2.gemfile.lock +1 -1
- data/gemfiles/rails_edge.gemfile.lock +1 -1
- data/lib/schedule_attributes/core.rb +3 -1
- data/lib/schedule_attributes/input.rb +18 -2
- data/lib/schedule_attributes/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d6ec6d8bd266ca9919c062f8535487b10b074536
|
4
|
+
data.tar.gz: e6c92474b6b7325d8cdc58b2e03b4678ef2ef536
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 575674d2526e00e742510302264952c0f7316e552467e540815c52b7ba62d20f72c0e7bb792ded3ee3ea83396d325371c6e192becd356a5ccd52c21320cad362
|
7
|
+
data.tar.gz: 799a694b7ddea894a99e2a5c2fbee265e397b54a535f0826283640ac8b256df8b6d6f948bbb46b699d4e0e1a31ce6ee7a0ae2d5fa7d0fddf4759569456072e70
|
data/CHANGELOG.md
CHANGED
@@ -3,12 +3,16 @@ All notable changes to this project will be documented in this file.
|
|
3
3
|
|
4
4
|
## HEAD
|
5
5
|
|
6
|
-
## 0.5.
|
6
|
+
## 0.5.1
|
7
|
+
|
8
|
+
- Fix several failing combinations of start/end_time and start/end_date after allowing Model#schedule_attributes to accept string- and symbol-keyed hashes ~ @dgilperez
|
9
|
+
|
10
|
+
## 0.5.0 *(BROKEN)*
|
7
11
|
|
8
12
|
- Added Code of Conduct from Contributor Covenant ~ @dgilperez
|
9
13
|
- Tests are now rspec-3 like ~ @dgilperez
|
10
14
|
- Activate IceCube.compatibility = 12 in specs ~ @dgilperez
|
11
|
-
- *POSSIBLE BREAKING CHANGE* Detect :start_date and :end_date attributes and merge them into :start_time and :end_time respective ones before passing them to IceCube::Schedule objects.
|
15
|
+
- *POSSIBLE BREAKING CHANGE* Detect :start_date and :end_date attributes and merge them into :start_time and :end_time respective ones before passing them to IceCube::Schedule objects. This modifies old serialized schedules persisted, if instantiated, reassigned and saved ~ @dgilperez
|
12
16
|
|
13
17
|
## 0.4.0
|
14
18
|
|
data/Gemfile.lock
CHANGED
data/README.markdown
CHANGED
@@ -28,10 +28,12 @@ module ScheduleAttributes
|
|
28
28
|
extend ActiveSupport::Concern
|
29
29
|
|
30
30
|
def schedule_attributes=(options)
|
31
|
+
raise ArgumentError "expecting a Hash" unless options.is_a? Hash
|
32
|
+
options = options.with_indifferent_access
|
31
33
|
merge_date_and_time_into_time_attribute!(options)
|
32
34
|
|
33
35
|
input = ScheduleAttributes::Input.new(options)
|
34
|
-
new_schedule = IceCube::Schedule.new(input.
|
36
|
+
new_schedule = IceCube::Schedule.new(input.start_date || TimeHelpers.today)
|
35
37
|
|
36
38
|
if input.repeat?
|
37
39
|
parser = ScheduleAttributes::RuleParser[input.interval_unit || 'day'].new(input)
|
@@ -131,13 +131,25 @@ module ScheduleAttributes
|
|
131
131
|
end
|
132
132
|
|
133
133
|
def start_date
|
134
|
-
|
134
|
+
if @params[:start_date]
|
135
|
+
parse_date_time(@params[:start_date], @params[:start_time])
|
136
|
+
elsif @params[:start_time] && !time_only?(@params[:start_time])
|
137
|
+
parse_date_time(@params[:start_time])
|
138
|
+
elsif start_time
|
139
|
+
start_time
|
140
|
+
else
|
141
|
+
parse_date_time(@params[:start_time])
|
142
|
+
end
|
135
143
|
end
|
136
144
|
|
137
145
|
def end_date
|
138
146
|
if @params[:end_date]
|
139
147
|
parse_date_time(@params[:end_date], @params[:end_time] || @params[:start_time])
|
140
|
-
elsif @params[:end_time]
|
148
|
+
elsif @params[:end_time] && !time_only?(@params[:end_time])
|
149
|
+
parse_date_time(@params[:end_time])
|
150
|
+
elsif end_time
|
151
|
+
end_time
|
152
|
+
else
|
141
153
|
parse_date_time(@params[:end_time])
|
142
154
|
end
|
143
155
|
end
|
@@ -160,5 +172,9 @@ module ScheduleAttributes
|
|
160
172
|
return if date_time_parts.empty?
|
161
173
|
TimeHelpers.parse_in_zone(date_time_parts.join(' '))
|
162
174
|
end
|
175
|
+
|
176
|
+
def time_only?(string)
|
177
|
+
!!(string.strip =~ /\d{1,2}\:\d{2}/)
|
178
|
+
end
|
163
179
|
end
|
164
180
|
end
|