Sha256: 0f949578e1dde486e576a9f78df2374676bb1183a78ddddf13a47f5ca5c00b4b

Contents?: true

Size: 1.33 KB

Versions: 50

Compression:

Stored size: 1.33 KB

Contents

# Copyright (C) 2016-2019  Kouhei Sutou <kou@clear-code.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

module Grntest
  class VariableExpander
    def initialize(context)
      @context = context
    end

    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
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
grntest-1.8.2 lib/grntest/variable-expander.rb
grntest-1.8.1 lib/grntest/variable-expander.rb
grntest-1.8.0 lib/grntest/variable-expander.rb
grntest-1.7.9 lib/grntest/variable-expander.rb
grntest-1.7.8 lib/grntest/variable-expander.rb
grntest-1.7.7 lib/grntest/variable-expander.rb
grntest-1.7.6 lib/grntest/variable-expander.rb
grntest-1.7.5 lib/grntest/variable-expander.rb
grntest-1.7.4 lib/grntest/variable-expander.rb
grntest-1.7.3 lib/grntest/variable-expander.rb
grntest-1.7.2 lib/grntest/variable-expander.rb
grntest-1.7.1 lib/grntest/variable-expander.rb
grntest-1.7.0 lib/grntest/variable-expander.rb
grntest-1.6.9 lib/grntest/variable-expander.rb
grntest-1.6.8 lib/grntest/variable-expander.rb
grntest-1.6.7 lib/grntest/variable-expander.rb
grntest-1.6.6 lib/grntest/variable-expander.rb
grntest-1.6.5 lib/grntest/variable-expander.rb
grntest-1.6.4 lib/grntest/variable-expander.rb
grntest-1.6.3 lib/grntest/variable-expander.rb