Class: Card::Set::I18nScanner

Inherits:
I18n::Tasks::Scanners::FileScanner
  • Object
show all
Includes:
I18n::Tasks::Scanners::OccurrenceFromPosition, I18n::Tasks::Scanners::RelativeKeys
Defined in:
card/lib/card/set/i18n_scanner.rb

Instance Method Summary collapse

Instance Method Details

#scan_file(path) ⇒ Array<[absolute key, Results::Occurrence]>

Returns:

  • (Array<[absolute key, Results::Occurrence]>)


10
11
12
13
14
15
16
17
18
19
# File 'card/lib/card/set/i18n_scanner.rb', line 10

def scan_file path
  text = read_file(path)

  text.scan(/[^\w._-]tr[( ]\s*["':](\w+)/).map do |_match|
    occurrence = occurrence_from_position(
      path, text, Regexp.last_match.offset(0).first
    )
    [absolute_key(".#{_match[0]}", path), occurrence]
  end
end