class Thor::Actions::TemplateDirectory

Protected Instance Methods

execute!() click to toggle source
Calls superclass method
# File lib/fwtoolkit/cli/fw_actions/template_dir.rb, line 36
def execute!
  super

  lookup = Thor::Util.escape_globs(destination)
  lookup = file_level_lookup(lookup)

  files(lookup).select{|f| f =~ /~template_config.rb/ }.each do |file_source|
    conf = File.open(file_source, 'r:utf-8')  { |f| f.read }
    # Work around for Rubinius incomplete encoding in 1.9 mode
    if conf.respond_to?(:encoding) && conf.encoding.name != "UTF-8"
      conf.encode!('UTF-8')
    end
    base.shell.say_status :executing, "configuration file: #{base.relative_to_original_destination_root(file_source)}", :green
    begin
      eval(conf, binding, file_source)
      FileUtils.rm file_source
    rescue Exception => e
      raise Thor::Error, "Invalid `#{file_source}` file: #{e.message}", e.backtrace
    end
  end
end