def copy_file(source_path, *args, **options, &block)
      source_path = source_path.to_s
      dest_path = (args.first || source_path).to_s.sub(/\.erb$/, '')

      ctx = if (vars = options[:context])
              vars.instance_eval('binding')
            else
              instance_eval('binding')
            end

      create_file(dest_path, options) do
        version = ERB.version.scan(/\d+\.\d+\.\d+/)[0]
        template = if version.to_f >= 2.2
                    ERB.new(::File.binread(source_path), trim_mode: "-", eoutvar: "@output_buffer")
                   else
                    ERB.new(::File.binread(source_path), nil, "-", "@output_buffer")
                   end
        content = template.result(ctx)
        content = block[content] if block
        content
      end
      return unless options[:preserve]
      copy_metadata(source_path, dest_path, options)
    end
def copy_file(source_path, *args, **options, &block)
      source_path = source_path.to_s
      dest_path = (args.first || source_path).to_s.sub(/\.erb$/, '')

      ctx = if (vars = options[:context])
              vars.instance_eval('binding')
            else
              instance_eval('binding')
            end

      create_file(dest_path, options) do
        version = ERB.version.scan(/\d+\.\d+\.\d+/)[0]
        template = if version.to_f >= 2.2
                    ERB.new(::File.binread(source_path), trim_mode: "-", eoutvar: "@output_buffer")
                   else
                    ERB.new(::File.binread(source_path), nil, "-", "@output_buffer")
                   end
        content = template.result(ctx)
        content = block[content] if block
        content
      end
      return unless options[:preserve]
      copy_metadata(source_path, dest_path, options)
    end
Copy file from the relative source to the relative
 destination running it through ERB.

 @example
   copy_file 'templates/test.rb', 'app/test.rb'

 @example
   vars = OpenStruct.new
   vars[:name] = 'foo'
   copy_file 'templates/%name%.rb', 'app/%name%.rb', context: vars

 @param [String, Pathname] source_path
 @param [Hash] options
 @option options [Symbol] :context
   the binding to use for the template
 @option options [Symbol] :preserve
   If true, the owner, group, permissions and modified time
   are preserved on the copied file, defaults to false.
 @option options [Symbol] :noop
   If true do not execute the action.
 @option options [Symbol] :verbose
   If true log the action status to stdout

 @api public