Top Level Namespace
Instance Method Summary collapse
Instance Method Details
#__erbt(path) ⇒ Object
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/internal/erbt.rb', line 1 def __erbt(path) path = File.(path) `touch #{path}` template = path + '.template' unless File.exist?(template) raise ArgumentError.new(".template does not exist!") end product = `erb #{template}` if File.read(path) != product backup = path + ".backup" puts "#{path} will be changed." puts "#{path} is backed up." `cat #{path} > #{backup}` end f = File.open(path, 'w') f.write(product) f.close end |
#erbt(path) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/internal/erbt.rb', line 20 def erbt(path) path = File.(path) file path => [path + '.template'] do __erbt(path) end desc("erbt all") task 'erbt' => [path] end |