Module: I18n::Inflector::Config

Included in:
Interpolate
Defined in:
lib/i18n-inflector/config.rb

Overview

This module contains submodules and module methods for handling global configuration of the engine.

Defined Under Namespace

Modules: Escapes, Keys, Markers, Operators, Reserved

Constant Summary collapse

OPTION_PREFIX =

Prefix that makes option a controlling option.

InflectionOptions::OPTION_PREFIX
OPTION_PREFIX_REGEXP =

Regexp matching a prefix that makes option a controlling option.

Regexp.new("^#{OPTION_PREFIX}")
PATTERN_RESTR =

A string for regular expression that catches patterns.

"(.?)#{Markers::PATTERN}" \
"([^\\#{Markers::PATTERN_BEGIN}]*)\\#{Markers::PATTERN_BEGIN}" \
"([^\\#{Markers::PATTERN_END}]+)\\#{Markers::PATTERN_END}" \
"((?:\\#{Markers::PATTERN_BEGIN}([^\\#{Markers::PATTERN_BEGIN}" \
"]+)\\#{Markers::PATTERN_END})*)".freeze
MULTI_RESTR =

A string for regular expression that extracts additional patterns attached.

"\\#{Markers::PATTERN_BEGIN}" \
"([^\\#{Markers::PATTERN_END}]+)\\" \
"#{Markers::PATTERN_END}".freeze
TOKENS_RESTR =

A regular expression that catches token groups or single tokens.

'(?:' \
"([^#{Operators::Tokens::ASSIGN}\\#{Operators::Tokens::OR}]+)" \
"#{Operators::Tokens::ASSIGN}+" \
"([^\\#{Operators::Tokens::OR}]+)\\1?)" \
"|([^#{Operators::Tokens::ASSIGN}\\#{Operators::Tokens::OR}]+)".freeze
PATTERN_REGEXP =

A regular expression that catches patterns.

Regexp.new PATTERN_RESTR
MULTI_REGEXP =

A regular expression that extracts additional patterns attached.

Regexp.new MULTI_RESTR
TOKENS_REGEXP =

A regular expression that catches token groups or single tokens.

Regexp.new TOKENS_RESTR

Class Method Summary collapse

Class Method Details

.all_consts(obj, f = String) ⇒ Object



28
29
30
31
32
33
# File 'lib/i18n-inflector/config.rb', line 28

def all_consts(obj, f = String)
  obj.constants.filter_map do |c|
    v = obj.const_get(c)
    (v.is_a?(f) && c != 'ALL') ? v : nil
  end.uniq
end

.gen_regexp(ary) ⇒ Object



37
38
39
# File 'lib/i18n-inflector/config.rb', line 37

def gen_regexp(ary)
  ::Regexp.new "[#{ary.join}]"
end

.get_i18n_reserved_keysObject



17
18
19
20
21
22
23
24
# File 'lib/i18n-inflector/config.rb', line 17

def get_i18n_reserved_keys
  return I18n::RESERVED_KEYS                  if defined?(I18n::RESERVED_KEYS)
  return I18n::Backend::Base::RESERVED_KEYS   if defined?(I18n::Backend::Base::RESERVED_KEYS)
  return I18n::Backend::Simple::RESERVED_KEYS if defined?(I18n::Backend::Simple::RESERVED_KEYS)
  return RESERVED_KEYS                        if defined?(RESERVED_KEYS)

  []
end