Class: I18n::Tasks::Scanners::PatternScanner
- Inherits:
-
FileScanner
- Object
- Scanner
- FileScanner
- I18n::Tasks::Scanners::PatternScanner
- Includes:
- OccurrenceFromPosition, RelativeKeys, RubyKeyLiterals
- Defined in:
- lib/i18n/tasks/scanners/pattern_scanner.rb
Overview
Scan for I18n.t usages using a simple regular expression.
Direct Known Subclasses
Constant Summary collapse
- TRANSLATE_CALL_RE =
/(?<=^|[^\p{L}'\-.]|[^\p{L}'-]I18n\.|I18n\.)t(?:!|ranslate!?)?/.freeze
- IGNORE_LINES =
{ 'coffee' => /^\s*#(?!\si18n-tasks-use)/, 'erb' => /^\s*<%\s*#(?!\si18n-tasks-use)/, 'es6' => %r{^\s*//(?!\si18n-tasks-use)}, 'haml' => /^\s*-\s*#(?!\si18n-tasks-use)/, 'js' => %r{^\s*//(?!\si18n-tasks-use)}, 'opal' => /^\s*#(?!\si18n-tasks-use)/, 'slim' => %r{^\s*(?:-#|/)(?!\si18n-tasks-use)} }.freeze
Constants included from RubyKeyLiterals
RubyKeyLiterals::LITERAL_RE, RubyKeyLiterals::VALID_KEY_CHARS, RubyKeyLiterals::VALID_KEY_RE
Instance Attribute Summary
Attributes inherited from FileScanner
Instance Method Summary collapse
-
#initialize(**args) ⇒ PatternScanner
constructor
A new instance of PatternScanner.
Methods included from RubyKeyLiterals
Methods included from OccurrenceFromPosition
Methods included from RelativeKeys
Methods inherited from FileScanner
Methods inherited from Scanner
Constructor Details
#initialize(**args) ⇒ PatternScanner
Returns a new instance of PatternScanner.
26 27 28 29 30 31 32 33 |
# File 'lib/i18n/tasks/scanners/pattern_scanner.rb', line 26 def initialize(**args) super @translate_call_re = config[:translate_call].present? ? Regexp.new(config[:translate_call]) : TRANSLATE_CALL_RE @pattern = config[:pattern].present? ? Regexp.new(config[:pattern]) : default_pattern @ignore_lines_res = (config[:ignore_lines] || IGNORE_LINES).each_with_object({}) do |(ext, re), h| h[ext.to_s] = Regexp.new(re) end end |