class MotionGradle::Template
Attributes
destination[RW]
Public Class Methods
new(name)
click to toggle source
# File lib/motion_gradle/template.rb, line 5 def initialize(name) template_path = File.expand_path("../templates/#{name}.erb", __FILE__) @template = ERB.new(File.new(template_path).read) end
Public Instance Methods
write(locals = {})
click to toggle source
# File lib/motion_gradle/template.rb, line 10 def write(locals = {}) File.open(self.destination, 'w') do |io| struct = OpenStruct.new(locals) io.puts(@template.result(struct.instance_eval { binding })) end end