Module: I18n::Tasks::Scanners::RubyKeyLiterals
- Included in:
- PatternMapper, PatternScanner
- Defined in:
- lib/i18n/tasks/scanners/ruby_key_literals.rb
Constant Summary collapse
- LITERAL_RE =
/:?".+?"|:?'.+?'|:\w+/.freeze
- VALID_KEY_CHARS =
%r{(?:[[:word:]]|[-.?!:;À-ž/])}.freeze
- VALID_KEY_RE =
/^#{VALID_KEY_CHARS}+$/.freeze
Instance Method Summary collapse
-
#literal_re ⇒ Object
Match literals: * String: ”, “#{}” * Symbol: :sym, :”, :“#{}”.
-
#strip_literal(literal) ⇒ String
remove the leading colon and unwrap quotes from the key match.
- #valid_key?(key) ⇒ Boolean
Instance Method Details
#literal_re ⇒ Object
Match literals:
-
String: ”, “#{}”
-
Symbol: :sym, :”, :“#{}”
10 11 12 |
# File 'lib/i18n/tasks/scanners/ruby_key_literals.rb', line 10 def literal_re LITERAL_RE end |
#strip_literal(literal) ⇒ String
remove the leading colon and unwrap quotes from the key match
17 18 19 20 21 |
# File 'lib/i18n/tasks/scanners/ruby_key_literals.rb', line 17 def strip_literal(literal) literal = literal[1..] if literal[0] == ':' literal = literal[1..-2] if literal[0] == "'" || literal[0] == '"' literal end |
#valid_key?(key) ⇒ Boolean
26 27 28 |
# File 'lib/i18n/tasks/scanners/ruby_key_literals.rb', line 26 def valid_key?(key) key =~ VALID_KEY_RE && !key.end_with?('.') end |