class Rake::Distribute::Item::ErbFile
Public Class Methods
new(&block)
click to toggle source
Calls superclass method
# File lib/rake/distribute/item/erbfile.rb, line 16 def initialize(&block) @context = {} super # if the user do not define build task @build_proc ||= Proc.new do |from, to| # unnecessary dup to make the workflow clear copy_entry from, to end end
Public Instance Methods
define_build_task(src)
click to toggle source
# File lib/rake/distribute/item/erbfile.rb, line 39 def define_build_task(src) directory @build_dir render_dest = File.join(@build_dir, "#{Item.sn.to_s}-#{@src.pathmap('%n')}") file render_dest => [@src, @build_dir] do render(@src, render_dest) end desc 'distribute: clean' task :clean do safe_unlink render_dest end super_define_build_task(render_dest) end
Also aliased as: super_define_build_task
render(from, to)
click to toggle source
# File lib/rake/distribute/item/erbfile.rb, line 30 def render(from, to) File.open(to, 'w') do |f| erb = ERB.new(File.read(from)) f.write(erb.result(ContextStruct.new(@context).get_binding)) f.flush end end
with_context(context)
click to toggle source
# File lib/rake/distribute/item/erbfile.rb, line 26 def with_context(context) @context = context end