module Angus::FileHandler

Public Instance Methods

copy_erb_file(file, name, base_path = nil) click to toggle source
# File lib/angus/generator/thor/file_handler.rb, line 13
def copy_erb_file(file, name, base_path = nil)
  base_path = name if base_path.nil?

  tmp_file = Tempfile.new(File.basename(file))

  source = File.expand_path(base.find_in_source_paths(file.to_s))
  content  = ERB.new(File.binread(source), nil,  '%<>-').result(binding)

  File.open(tmp_file.path, 'w') { |f| f << content }
  tmp_file.close

  base.copy_file(tmp_file.path, File.join(base_path, filename_resolver(file, name)))
end
filename_resolver(file, app_name) click to toggle source
# File lib/angus/generator/thor/file_handler.rb, line 27
def filename_resolver(file, app_name)
  if mapping[file].nil?
    file.gsub('.erb', '')
  else
    mapping[file].call(self, app_name)
  end
end
is_erb?(file) click to toggle source
# File lib/angus/generator/thor/file_handler.rb, line 9
def is_erb?(file)
  file.end_with?('.erb')
end
mapping() click to toggle source

Override if you want a custom file mapping.

# File lib/angus/generator/thor/file_handler.rb, line 5
def mapping
  {}
end