Class: PhraseApp::Android::FormatCheck
- Inherits:
-
PhraseAppClient
- Object
- PhraseAppClient
- PhraseApp::Android::FormatCheck
- Defined in:
- lib/phraseapp_android/format_check.rb
Instance Attribute Summary collapse
-
#keys ⇒ Object
Returns the value of attribute keys.
Attributes inherited from PhraseAppClient
#client, #locale_files, #locales, #project_id, #sub_path
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ FormatCheck
constructor
A new instance of FormatCheck.
- #perform ⇒ Object
- #perform_for_locale(locale) ⇒ Object
Methods inherited from PhraseAppClient
#locale_file_name, #read_locale_file, #read_xml_file
Constructor Details
#initialize(options = {}) ⇒ FormatCheck
Returns a new instance of FormatCheck.
7 8 9 10 11 |
# File 'lib/phraseapp_android/format_check.rb', line 7 def initialize( = {}) super() self.keys = xml_strings_to_hash 'strings', nil end |
Instance Attribute Details
#keys ⇒ Object
Returns the value of attribute keys.
5 6 7 |
# File 'lib/phraseapp_android/format_check.rb', line 5 def keys @keys end |
Instance Method Details
#perform ⇒ Object
13 14 15 |
# File 'lib/phraseapp_android/format_check.rb', line 13 def perform locales.map { |l| perform_for_locale(l) }.reduce(:+) end |
#perform_for_locale(locale) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/phraseapp_android/format_check.rb', line 17 def perform_for_locale(locale) data = xml_strings_to_hash 'strings', locale count = 0 keys.each do |name, value| formatters = value.scan /(%[\d$a-z]+)/i count += 1 if formatters && !check_formatters(locale, data, name, formatters) end count end |