Class: Grntest::VariableExpander

Inherits:
Object
  • Object
show all
Defined in:
lib/grntest/variable-expander.rb

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ VariableExpander

Returns a new instance of VariableExpander.



18
19
20
# File 'lib/grntest/variable-expander.rb', line 18

def initialize(context)
  @context = context
end

Instance Method Details

#expand(string) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/grntest/variable-expander.rb', line 22

def expand(string)
  string.gsub(/\#{(.+?)}/) do |matched|
    case $1
    when "db_path"
      @context.db_path.to_s
    when "db_directory"
      @context.db_path.parent.to_s
    when "base_directory"
      @context.base_directory.to_s
    when "plugins_directory"
      @context.plugins_directory.to_s
    when "libtool_directory"
      @context.libtool_directory
    when "plugin_extension"
      @context.plugin_extension
    else
      matched
    end
  end
end