Skip to content

Commit

Permalink
Use Psych to load yaml when it is defined
Browse files Browse the repository at this point in the history
  • Loading branch information
tigrish committed Mar 27, 2012
1 parent ffe455a commit a617b01
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 0 additions & 1 deletion lib/i18n-spec.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
require 'psych'
Dir[File.dirname(__FILE__) + '/i18n-spec/models/*.rb'].each {|file| require file }
Dir[File.dirname(__FILE__) + '/i18n-spec/matchers/*.rb'].each {|file| require file }
Dir[File.dirname(__FILE__) + '/i18n-spec/shared_examples/*.rb'].each {|file| require file }
12 changes: 10 additions & 2 deletions lib/i18n-spec/models/locale_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def content
end

def translations
@translations ||= Psych.load(content)
@translations ||= yaml_load_content
end

def flattened_translations
Expand All @@ -41,7 +41,7 @@ def invalid_pluralization_keys

def is_parseable?
begin
Psych.load(content)
yaml_load_content
true
rescue Psych::SyntaxError => e
@errors[:unparseable] = e.to_s
Expand Down Expand Up @@ -76,5 +76,13 @@ def pluralization_data?(data)
keys.any? {|k| PLURALIZATION_KEYS.include?(k) }
end

def yaml_load_content
if defined? Psych
Psych.load(content)
else
YAML.load(content)
end
end

end
end

0 comments on commit a617b01

Please sign in to comment.