class Object

Public Instance Methods

__erbt(path) click to toggle source
# File lib/internal/erbt.rb, line 1
def __erbt(path)
  path = File.expand_path(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) click to toggle source
# File lib/internal/erbt.rb, line 20
def erbt(path)
  path = File.expand_path(path)
  file path => [path + '.template'] do
    __erbt(path)
  end
  desc("erbt all")
  task 'erbt' => [path]
end