Class: Haml::I18n::Extractor::ExceptionFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/haml-i18n-extractor/extraction/finder/exception_finder.rb

Constant Summary collapse

/link_to\s*\(?\s*["](.*?)["]\s*,\s*(.*)\)?/
/link_to\s*\(?\s*['](.*?)[']\s*,\s*(.*)\)?/
/link_to\s*\(?['](.*?)[']\)?.*\sdo\s*$/
/link_to\s*\(?["](.*?)["]\)?.*\sdo\s*$/
/link_to\s*\(?([^'"]*?)\)?.*/
EXCEPTION_MATCHES =

this class simply returns text except for anything that matches these regexes. returns first match.

[ LINK_TO_BLOCK_FORM_DOUBLE_Q, LINK_TO_BLOCK_FORM_SINGLE_Q,
LINK_TO_REGEX_DOUBLE_Q, LINK_TO_REGEX_SINGLE_Q , LINK_TO_NO_QUOTES ]

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ ExceptionFinder

Returns a new instance of ExceptionFinder.



6
7
8
# File 'lib/haml-i18n-extractor/extraction/finder/exception_finder.rb', line 6

def initialize(text)
  @text = text
end

Instance Method Details

#findObject



21
22
23
24
25
26
27
28
29
30
# File 'lib/haml-i18n-extractor/extraction/finder/exception_finder.rb', line 21

def find
  ret = @text
  EXCEPTION_MATCHES.each do |regex|
    if @text.match(regex)
      ret = $1
      break # return whatever it finds on first try, order of above regexes matters
    end
  end
  ret
end