lib/generators/template/install_generator.rb in template-1.4.0 vs lib/generators/template/install_generator.rb in template-2.0.0
- old
+ new
@@ -1,24 +1,24 @@
+require 'rake'
require 'rails/generators'
-require 'Rake' #need rake to be able to execute shell commands
module Template
-#kudos to Mike Farmer from stackoverflow http://stackoverflow.com/users/4082/mike-farmer
class InstallGenerator < Rails::Generators::Base
- desc "Creates some basic files for a rails 3 app"
+ desc "Installs some simple files needed for a rails 3 app"
- # Add some extra options here:
# Commandline options can be defined here using Thor-like options:
- # class_option :my_opt, :type => :boolean, :default => false, :desc => "My Option"
+ class_option :my_opt, :type => :boolean, :default => false, :desc => "My Option"
# I can later access that option using:
# options[:my_opt]
def self.source_root
@source_root ||= File.join(File.dirname(__FILE__), 'templates')
end
+ # Generator Code. Remember this is just suped-up Thor so methods are executed in order
+
def copy_template_files
copy_file 'app/controllers/welcome_controller.rb','app/controllers/welcome_controller.rb'
template 'app/views/layouts/application.html.erb'
template 'app/views/welcome/index.html.erb'
template 'config/database.yml'
@@ -57,11 +57,8 @@
puts '| - Run rake db:setup |'
puts '| - Start your server: rails server |'
puts '---------------------------------------------------------------'
end
end
-
-
-
end
end