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