Sha256: f1335bc37c145ad98e81734443af31cdf6f4e3f41df23f865e6bc49100928e38

Contents?: true

Size: 717 Bytes

Versions: 7

Compression:

Stored size: 717 Bytes

Contents

require 'fileutils'

module Clearwater
  module Roda
    class Template
      attr_reader :input, :output, :options

      def initialize input_filename, output_filename, options={}
        @input = input_filename
        @output = output_filename
        @options = options
      end

      def write
        if output.respond_to? :write
          output.write content
        else
          FileUtils.mkdir_p File.dirname(output)
          File.write output, content
        end
      end

      def content
        string = if input.respond_to? :read
                   input.read
                 else
                   File.read(input)
                 end

        string % options
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
clearwater-roda-0.3.0 lib/clearwater/roda/template.rb
clearwater-roda-0.2.4 lib/clearwater/roda/template.rb
clearwater-roda-0.2.3 lib/clearwater/roda/template.rb
clearwater-roda-0.2.2 lib/clearwater/roda/template.rb
clearwater-roda-0.2.1 lib/clearwater/roda/template.rb
clearwater-roda-0.2.0 lib/clearwater/roda/template.rb
clearwater-roda-0.1.0 lib/clearwater/roda/template.rb