Module: ExpandVariables
- Defined in:
- lib/expand_variables.rb
Constant Summary collapse
- VARIABLES_REGEXP =
/\$([a-zA-Z_][a-zA-Z0-9_]*)|\${\g<1>}|%\g<1>%/
Class Method Summary collapse
- .expand(value, variables, expand_file_refs: true) ⇒ Object
- .expand_existing(value, variables, expand_file_refs: true) ⇒ Object
- .possible_var_reference?(value) ⇒ Boolean
Class Method Details
.expand(value, variables, expand_file_refs: true) ⇒ Object
7 8 9 10 11 |
# File 'lib/expand_variables.rb', line 7 def (value, variables, expand_file_refs: true) replace_with(value, variables) do |collection, last_match| match_or_blank_value(collection, last_match, expand_file_refs: ) end end |
.expand_existing(value, variables, expand_file_refs: true) ⇒ Object
13 14 15 16 17 |
# File 'lib/expand_variables.rb', line 13 def (value, variables, expand_file_refs: true) replace_with(value, variables) do |collection, last_match| match_or_original_value(collection, last_match, expand_file_refs: ) end end |
.possible_var_reference?(value) ⇒ Boolean
19 20 21 22 23 |
# File 'lib/expand_variables.rb', line 19 def possible_var_reference?(value) return unless value %w[$ %].any? { |symbol| value.include?(symbol) } end |