Class: I18nSpec::LocaleFile

Inherits:
Object
  • Object
show all
Defined in:
lib/i18n-spec/models/locale_file.rb

Constant Summary collapse

PLURALIZATION_KEYS =
%w{zero one two few many other}

Instance Method Summary collapse

Constructor Details

#initialize(filepath) ⇒ LocaleFile

Returns a new instance of LocaleFile.



5
6
7
# File 'lib/i18n-spec/models/locale_file.rb', line 5

def initialize(filepath)
  @filepath = filepath
end

Instance Method Details

#has_valid_pluralization_keys?Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
# File 'lib/i18n-spec/models/locale_file.rb', line 18

def has_valid_pluralization_keys?
  pluralizations.each do |key, pluralization|
    return false unless pluralization.keys.all? {|k| PLURALIZATION_KEYS.include?(k)}
  end
  true
end

#is_parseable?Boolean

Returns:

  • (Boolean)


9
10
11
12
13
14
15
16
# File 'lib/i18n-spec/models/locale_file.rb', line 9

def is_parseable?
  begin
    Psych.load_file(@filepath)
    true
  rescue Psych::SyntaxError => e
    false
  end
end