From 645b099b2f468ed591c00ae14a21c7fc09f86bc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Garami=20G=C3=A1bor?= Date: Wed, 28 Mar 2012 01:38:32 +0200 Subject: [PATCH] Remaining fixes --- lib/i18n-spec.rb | 6 +++++- lib/i18n-spec/models/locale_file.rb | 13 +++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/i18n-spec.rb b/lib/i18n-spec.rb index 23d3d45..81844c8 100644 --- a/lib/i18n-spec.rb +++ b/lib/i18n-spec.rb @@ -1,3 +1,7 @@ +if defined?(Psych) and !defined?(YAML::ParseError) + YAML::ParseError = Psych::SyntaxError +end + 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 } \ No newline at end of file +Dir[File.dirname(__FILE__) + '/i18n-spec/shared_examples/*.rb'].each {|file| require file } diff --git a/lib/i18n-spec/models/locale_file.rb b/lib/i18n-spec/models/locale_file.rb index 4efaa77..faefbb9 100644 --- a/lib/i18n-spec/models/locale_file.rb +++ b/lib/i18n-spec/models/locale_file.rb @@ -23,9 +23,15 @@ def flattened_translations end def pluralizations - flatten_tree(translations).select do |key, value| + result = flatten_tree(translations).select do |key, value| value.is_a?(Hash) end + + if result.is_a?(Array) + Hash[result] + else + result + end end def invalid_pluralization_keys @@ -43,7 +49,10 @@ def is_parseable? begin yaml_load_content true - rescue Psych::SyntaxError => e + rescue YAML::ParseError => e + @errors[:unparseable] = e.to_s + false + rescue ArgumentError => e @errors[:unparseable] = e.to_s false end