def install options
require 'fileutils'
config_file_dir = "#{options[:project_path]}/config"
unless File.exists? config_file_dir
notify "Creating config directory"
FileUtils.mkdir_p config_file_dir
end
if File.exists? "#{options[:project_path]}/.gitignore"
File.open("#{options[:project_path]}/.gitignore", 'a+') do |f|
f.write("\n# Gemnasium gem configuration file\nconfig/gemnasium.yml") unless f.read.include? 'config/gemnasium.yml'
notify "Configuration file added to your project's .gitignore."
end
end
notify 'Please fill configuration file with accurate values.', :blue if copy_template('gemnasium.yml', "#{config_file_dir}/gemnasium.yml")
if options[:install_git_hook]
notify ''
if File.exists? "#{options[:project_path]}/.git/hooks"
copy_template('post-commit', "#{options[:project_path]}/.git/hooks/post-commit")
else
notify "#{options[:project_path]} is not a git repository. Try to run `git init`.", :red
end
end
if options[:install_rake_task]
notify ''
if !File.exists? "#{options[:project_path]}/Rakefile"
notify "Rakefile not found.", :red
else
rake_file_dir = "#{options[:project_path]}/lib/tasks"
unless File.exists? rake_file_dir
notify "Creating lib/tasks directory"
FileUtils.mkdir_p rake_file_dir
end
if copy_template('gemnasium.rake', "#{rake_file_dir}/gemnasium.rake")
notify 'Usage:', :blue
notify "\trake gemnasium:push \t\t- to push your dependency files", :blue
notify "\trake gemnasium:create \t\t- to create your project on Gemnasium", :blue
notify "\trake gemnasium:migrate \t\t- to migrate your configuration file", :blue
notify "\trake gemnasium:resolve \t\t- to resolve the project name to an existing project", :blue
end
end
end
end