lib/i18n-spec/models/locale_file.rb in i18n-spec-0.0.6 vs lib/i18n-spec/models/locale_file.rb in i18n-spec-0.0.7

- old
+ new

@@ -1,13 +1,23 @@ module I18nSpec class LocaleFile PLURALIZATION_KEYS = %w{zero one two few many other} + attr_accessor :filepath + def initialize(filepath) @filepath = filepath end + def translations + @translations ||= Psych.load_file(@filepath) + end + + def flattened_translations + @flattened_translations ||= flatten_tree(translations.values.first) + end + def is_parseable? begin Psych.load_file(@filepath) true rescue Psych::SyntaxError => e @@ -36,13 +46,9 @@ keys = flatten_tree(default_locale.translations.values.first).keys.sort keys == default_keys end protected - - def translations - @translations ||= Psych.load_file(@filepath) - end def flatten_tree(data, prefix = '', result = {}) data.each do |key, value| current_prefix = prefix.empty? ? key.to_s : "#{prefix}.#{key}" if !value.is_a?(Hash) || pluralization_data?(value) \ No newline at end of file