#Namebase allows you to use class_name (first arg passed in) class <%= class_name.camelize %>Generator < Rails::Generator::NamedBase #attr_accessor to make the templates easy def initialize(*runtime_args) super(*runtime_args) #runtime_args[0] is an array of the args passed in,can be accessed with @args #runtime_args[1] is the option hash,can be accessed as the options[:key] raise "Your Error Message Here" if #{Atleast check the params} end def manifest record do |m| #if options[:svn] is set this will run the svn add command #I was creating controllers. this call checks name spaces of rails objects (Not user created objects) #m.class_collisions class_path, "#{controller_name.camelize}Controller", "#{controller_name.camelize}ControllerTest", "#{controller_name.camelize}Helper" #This just copies files from point a to point b. #The file_options hash accepts :chmod and :shebang and :collision options. #m.file "lib/rest_resource.rb", "lib/rest_resource.rb",{} #m.directory File.join('lib','generators', class_name) #this allows you to use ERB to create cool stuff #m.template 'USAGE', File.join('lib', 'generators',class_name,"USAGE") # Display a README. #m.readme "INSTALL" #I have yet to use these #m.migration_template(relative_source, relative_destination, template_options = {:migration_file_name=>"not sure"}) #alters route.rb file #m.route_resources(*resources) #m.complex_template(relative_source, relative_destination, template_options = {[:assigns]['template_for_inclusion'] }) #check if its already there #m.identical?(source, destination, &block) end end end