Class: MODL::Parser::RefProcessor
- Inherits:
-
Object
- Object
- MODL::Parser::RefProcessor
- Defined in:
- lib/modl/parser/ref_processor.rb
Overview
Convert MODL reference to the replacement value
Constant Summary collapse
- NESTED_SEPARATOR =
'.'
- MATCHER =
Regexp.new('((%\w+)(\.\w*<`?\w*`?,`\w*`>)+|(%` ?[\w-]+`[\w.<>,]*%?)|(%\*?[\w]+(\.%?\w*<?[\w,]*>?)*%?))')
- MAX_RECURSE_DEPTH =
10
Class Method Summary collapse
-
.deref(str, global) ⇒ Object
Check str for references and process them.
-
.split_by_ref_tokens(str, global) ⇒ Object
Process the next %ref token.
- .trivial_reject(str) ⇒ Object
Class Method Details
.deref(str, global) ⇒ Object
Check str for references and process them. Return the processed string and a new_value if there is one.
45 46 47 48 49 |
# File 'lib/modl/parser/ref_processor.rb', line 45 def self.deref(str, global) obj = str obj, new_value = split_by_ref_tokens str, global unless trivial_reject(str) [obj, new_value] end |
.split_by_ref_tokens(str, global) ⇒ Object
Process the next %ref token
52 53 54 55 56 57 58 59 60 61 |
# File 'lib/modl/parser/ref_processor.rb', line 52 def self.split_by_ref_tokens(str, global) new_value = nil text = str original = str new_value, str = process_tokens(global, original, str, text) if new_value.nil? [str, new_value] end |
.trivial_reject(str) ⇒ Object
38 39 40 41 |
# File 'lib/modl/parser/ref_processor.rb', line 38 def self.trivial_reject(str) # do a fast check to see if we need to deref - save processing the regex if we don't have to. !(str.is_a?(String) && !str.start_with?('%*') && (str.nil? || str.include?('%') || str.include?('`'))) end |