Sha256: aeb77792df98273ea8ab4b83af0408b71ac2d83908a32565b076403e24148872
Contents?: true
Size: 1.11 KB
Versions: 1
Compression:
Stored size: 1.11 KB
Contents
require 'rake/clean' require 'rake/tasklib' module Rake::Funnel::Tasks class QuickTemplate < Rake::TaskLib include Rake::Funnel::Support attr_accessor :name, :search_pattern, :context def initialize(name = :template) @name = name @search_pattern = %w(**/*.erb) @context = binding yield self if block_given? define end private def define results = templates.all_or_default.map { |t| result_filename(t) } CLEAN.include(*results) desc "Generate #{templates.all_or_default.join(', ')}" task name do templates.all_or_default.each do |template| target = result_filename(template) Rake.rake_output_message "Creating file #{target}" content = Rake::Funnel::Support::TemplateEngine.render(File.read(template), template, context) File.write(target, content) end end self end def templates Finder.new(search_pattern, self, 'No templates found.') end def result_filename(template) template.ext end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rake-funnel-0.1.0.pre | lib/rake/funnel/tasks/quick_template.rb |