lib/i18n-spec/models/locale_file.rb in i18n-spec-0.0.10 vs lib/i18n-spec/models/locale_file.rb in i18n-spec-0.1.0
- old
+ new
@@ -1,13 +1,15 @@
module I18nSpec
class LocaleFile
PLURALIZATION_KEYS = %w{zero one two few many other}
attr_accessor :filepath
+ attr_reader :errors
def initialize(filepath)
@filepath = filepath
+ @errors = {}
end
def content
@content ||= IO.read(@filepath)
end
@@ -31,17 +33,19 @@
pluralizations.each do |parent, pluralization|
pluralization.keys.select do |key, value|
invalid << [parent, key].join('.') unless PLURALIZATION_KEYS.include?(key)
end
end
+ @errors[:invalid_pluralization_keys] = invalid unless invalid.empty?
invalid
end
def is_parseable?
begin
- Psych.load_file(@filepath)
+ Psych.load(content)
true
rescue Psych::SyntaxError => e
+ @errors[:unparseable] = e.to_s
false
end
end
def has_one_top_level_namespace?