Class: Rake::Delphi::RCTemplateTask

Inherits:
Task
  • Object
show all
Defined in:
lib/rake/delphi/resources.rb

Instance Attribute Summary

Attributes inherited from Task

#logger

Instance Method Summary collapse

Methods inherited from Task

#execute_base, #initialize_base, #needed=, #needed?, #out, #reenable_chain, #shortname, #trace?

Constructor Details

#initialize(name, app) ⇒ RCTemplateTask

Returns a new instance of RCTemplateTask.



73
74
75
76
77
78
# File 'lib/rake/delphi/resources.rb', line 73

def initialize(name, app)
    super
    @output = nil
    @template_file = File.expand_path('../../templates/project.erb', __FILE__)
    @template_obj = RCTemplate.new(self)
end

Instance Method Details

#[]=(key, value) ⇒ Object



84
85
86
# File 'lib/rake/delphi/resources.rb', line 84

def []=(key, value)
    @template_obj[key] = value
end

#execute(args = nil) ⇒ Object



88
89
90
91
92
93
94
95
# File 'lib/rake/delphi/resources.rb', line 88

def execute(args=nil)
    super
    erb = ERB.new(IO.read(@template_file))
    text = erb.result(@template_obj.get_binding)
    File.open(@output, 'w') do |f|
        f.write(text)
    end
end

#output=(value) ⇒ Object



80
81
82
# File 'lib/rake/delphi/resources.rb', line 80

def output=(value)
    @output = value.pathmap('%X.rc')
end