Sha256: fc51ffe025425f0b28170c59efee58ee456f8e3e763b4bda8072b21e15638565

Contents?: true

Size: 518 Bytes

Versions: 6

Compression:

Stored size: 518 Bytes

Contents

module Nesta
  module Commands
    class Template
      def initialize(filename)
        @filename = filename
      end

      def template_path
        dir = File.expand_path('../../../templates', File.dirname(__FILE__))
        File.join(dir, @filename)
      end

      def copy_to(dest, context)
        FileUtils.mkdir_p(File.dirname(dest))
        template = ERB.new(File.read(template_path), trim_mode: "-")
        File.open(dest, 'w') { |file| file.puts template.result(context) }
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
nesta-0.18.0 lib/nesta/commands/template.rb
nesta-0.17.0 lib/nesta/commands/template.rb
nesta-0.16.0 lib/nesta/commands/template.rb
nesta-0.15.0 lib/nesta/commands/template.rb
nesta-0.14.0 lib/nesta/commands/template.rb
nesta-0.13.0 lib/nesta/commands/template.rb