def initialize_template(guard_name)
guard_class = ::Guard.get_guard_class(guard_name, true)
if guard_class
guard_class.init(guard_name)
guardfile_name = 'Guardfile'
guard_file = File.read(guardfile_name) if File.exists?(guardfile_name)
duplicate_definitions?(guard_name, guard_file)
elsif File.exist?(File.join(HOME_TEMPLATES, guard_name))
content = File.read('Guardfile')
template = File.read(File.join(HOME_TEMPLATES, guard_name))
File.open('Guardfile', 'wb') do |f|
f.puts(content)
f.puts('')
f.puts(template)
end
::Guard::UI.info "#{ guard_name } template added to Guardfile, feel free to edit it"
else
const_name = guard_name.downcase.gsub('-', '')
UI.error "Could not load 'guard/#{ guard_name.downcase }' or '~/.guard/templates/#{ guard_name.downcase }' or find class Guard::#{ const_name.capitalize }"
end
end