class Grntest::VariableExpander

Public Class Methods

new(context) click to toggle source
# File lib/grntest/variable-expander.rb, line 18
def initialize(context)
  @context = context
end

Public Instance Methods

expand(string) click to toggle source
# 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