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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 031b0bf395bee38af7d2516bb2358b4385128527
4
- data.tar.gz: e9881c68f4dd05c30701e75ec7f4dbad5a6eb863
3
+ metadata.gz: d6ec6d8bd266ca9919c062f8535487b10b074536
4
+ data.tar.gz: e6c92474b6b7325d8cdc58b2e03b4678ef2ef536
5
5
  SHA512:
6
- metadata.gz: e77a84adc8c0cb9825eef971704fb37fe8397d83501e21c72574e437ef3955ede56eb97fcd85daf97f605e2a07c33ef44b90e762a6163f93d10565644ccb4b00
7
- data.tar.gz: c4109d2763a4a0a4a77d568538f7590d268aa5e258e1e17f59bef312666c48b67e2a8bf1daf70e35501e104c6f294dbd7106d21cea31ff67900b57200bc5e66f
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.0
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dgp-schedule_attributes (0.5.0)
4
+ dgp-schedule_attributes (0.5.1)
5
5
  activesupport (>= 3.2)
6
6
  ice_cube (~> 0.13)
7
7
  tzinfo
data/README.markdown CHANGED
@@ -13,7 +13,7 @@ Install using
13
13
 
14
14
  Or add to your *Gemfile*:
15
15
 
16
- gem 'dgp-schedule_attributes', '~> 0.4'
16
+ gem 'dgp-schedule_attributes', '~> 0.4', require: 'schedule_attributes'
17
17
 
18
18
  To use, include the `ScheduleAttributes` module in your model class.
19
19
 
@@ -35,7 +35,7 @@ GIT
35
35
  PATH
36
36
  remote: ../
37
37
  specs:
38
- dgp-schedule_attributes (0.4.0)
38
+ dgp-schedule_attributes (0.5.0)
39
39
  activesupport (>= 3.2)
40
40
  ice_cube (~> 0.13)
41
41
  tzinfo
@@ -21,7 +21,7 @@ GIT
21
21
  PATH
22
22
  remote: ../
23
23
  specs:
24
- dgp-schedule_attributes (0.4.0)
24
+ dgp-schedule_attributes (0.5.0)
25
25
  activesupport (>= 3.2)
26
26
  ice_cube (~> 0.13)
27
27
  tzinfo
@@ -20,7 +20,7 @@ GIT
20
20
  PATH
21
21
  remote: ../
22
22
  specs:
23
- dgp-schedule_attributes (0.4.0)
23
+ dgp-schedule_attributes (0.5.0)
24
24
  activesupport (>= 3.2)
25
25
  ice_cube (~> 0.13)
26
26
  tzinfo
@@ -20,7 +20,7 @@ GIT
20
20
  PATH
21
21
  remote: ../
22
22
  specs:
23
- dgp-schedule_attributes (0.4.0)
23
+ dgp-schedule_attributes (0.5.0)
24
24
  activesupport (>= 3.2)
25
25
  ice_cube (~> 0.13)
26
26
  tzinfo
@@ -27,7 +27,7 @@ GIT
27
27
  PATH
28
28
  remote: ../
29
29
  specs:
30
- dgp-schedule_attributes (0.4.0)
30
+ dgp-schedule_attributes (0.5.0)
31
31
  activesupport (>= 3.2)
32
32
  ice_cube (~> 0.13)
33
33
  tzinfo
@@ -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.start_time || TimeHelpers.today)
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
- parse_date_time(@params[:start_date]) if @params[:start_date]
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
@@ -1,3 +1,3 @@
1
1
  module ScheduleAttributes
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dgp-schedule_attributes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Gil