Class: Haml::I18n::Extractor::ExceptionFinder
- Inherits:
-
Object
- Object
- Haml::I18n::Extractor::ExceptionFinder
- Defined in:
- lib/haml-i18n-extractor/extraction/finder/exception_finder.rb
Constant Summary collapse
- LINK_TO_REGEX_DOUBLE_Q =
/link_to\s*\(?\s*["](.*?)["]\s*,\s*(.*)\)?/
- LINK_TO_REGEX_SINGLE_Q =
/link_to\s*\(?\s*['](.*?)[']\s*,\s*(.*)\)?/
- LINK_TO_BLOCK_FORM_SINGLE_Q =
/link_to\s*\(?['](.*?)[']\)?.*\sdo\s*$/
- LINK_TO_BLOCK_FORM_DOUBLE_Q =
/link_to\s*\(?["](.*?)["]\)?.*\sdo\s*$/
- LINK_TO_NO_QUOTES =
/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
- #find ⇒ Object
-
#initialize(text) ⇒ ExceptionFinder
constructor
A new instance of ExceptionFinder.
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
#find ⇒ Object
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 |