Sha256: 047f4f8de18407a7b19398ccc4cfab5e5522805695417aa96f8471b797f1c33d
Contents?: true
Size: 1.05 KB
Versions: 3
Compression:
Stored size: 1.05 KB
Contents
# Copyright (C) 2016 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 "base_directory" @context.base_directory.to_s else matched end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
grntest-1.2.5 | lib/grntest/variable-expander.rb |
grntest-1.2.4 | lib/grntest/variable-expander.rb |
grntest-1.2.3 | lib/grntest/variable-expander.rb |