File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11require 'date'
22require 'ice_cube/deprecated'
33
4- # Use psych if we can
5- begin
6- require 'psych'
7- rescue LoadError
8- require 'yaml'
9- end
10-
114module IceCube
125
136 autoload :VERSION , 'ice_cube/version'
@@ -71,10 +64,6 @@ module Validations
7164 ONE_DAY = ONE_HOUR * 24
7265 ONE_WEEK = ONE_DAY * 7
7366
74- def self . use_psych?
75- @use_psych ||= defined? ( Psych ) && defined? ( Psych ::VERSION )
76- end
77-
7867 # Defines the format used by IceCube when printing out Schedule#to_s.
7968 # Defaults to '%B %e, %Y'
8069 def self . to_s_time_format
Original file line number Diff line number Diff line change @@ -30,12 +30,12 @@ def to_ical
3030
3131 # Yaml implementation
3232 def to_yaml ( *args )
33- IceCube :: use_psych? ? Psych :: dump ( to_hash ) : YAML ::dump ( to_hash , *args )
33+ YAML ::dump ( to_hash , *args )
3434 end
3535
3636 # From yaml
3737 def self . from_yaml ( yaml )
38- from_hash IceCube :: use_psych? ? Psych :: load ( yaml ) : YAML ::load ( yaml )
38+ from_hash YAML ::load ( yaml )
3939 end
4040
4141 # Expected to be overridden by subclasses
Original file line number Diff line number Diff line change @@ -313,12 +313,12 @@ def to_ical(force_utc = false)
313313
314314 # Convert the schedule to yaml
315315 def to_yaml ( *args )
316- IceCube :: use_psych? ? Psych :: dump ( to_hash , * args ) : YAML ::dump ( to_hash , *args )
316+ YAML ::dump ( to_hash , *args )
317317 end
318318
319319 # Load the schedule from yaml
320320 def self . from_yaml ( yaml , options = { } )
321- hash = IceCube :: use_psych? ? Psych :: load ( yaml ) : YAML ::load ( yaml )
321+ hash = YAML ::load ( yaml )
322322 if match = yaml . match ( /start_date: .+((?:-|\+ )\d {2}:\d {2})$/ )
323323 TimeUtil . restore_deserialized_offset ( hash [ :start_date ] , match [ 1 ] )
324324 end
You can’t perform that action at this time.
0 commit comments