Skip to content

Commit efd98f1

Browse files
committed
Ruby 1.9 uses Psych for YAML
1 parent 0746fea commit efd98f1

3 files changed

Lines changed: 4 additions & 15 deletions

File tree

lib/ice_cube.rb

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,6 @@
11
require 'date'
22
require 'ice_cube/deprecated'
33

4-
# Use psych if we can
5-
begin
6-
require 'psych'
7-
rescue LoadError
8-
require 'yaml'
9-
end
10-
114
module 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

lib/ice_cube/rule.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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

lib/ice_cube/schedule.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)