Class: Hobo::FrontControllerGenerator
- Inherits:
-
Rails::Generators::NamedBase
- Object
- Rails::Generators::NamedBase
- Hobo::FrontControllerGenerator
- Includes:
- classy_module do # check_class_collision :suffix => 'Controller' class_option :helpers, :type => :boolean, :desc => "Generates helper files", :default => !Railsclassy_module do # check_class_collision :suffix => 'Controller' class_option :helpers, :type => :boolean, :desc => "Generates helper files", :default => !Rails.applicationclassy_module do # check_class_collision :suffix => 'Controller' class_option :helpers, :type => :boolean, :desc => "Generates helper files", :default => !Rails.application.configclassy_module do # check_class_collision :suffix => 'Controller' class_option :helpers, :type => :boolean, :desc => "Generates helper files", :default => !Rails.application.config.hoboclassy_module do # check_class_collision :suffix => 'Controller' class_option :helpers, :type => :boolean, :desc => "Generates helper files", :default => !Rails.application.config.hobo.dryml_only_templates def self.banner "rails generate hobo:controller #{self.arguments.map(&:usage).join(' ')}" end def generate_controller if class_path.length == 1 and subsite = class_path.first and ( options[:subsite_controller_is_being_created] or File.exist?(File.join('app/controllers', class_path, "#{subsite}_site_controller.rb")) ) @subsite = subsite.camelize end template 'controller.rb.erb', File.join('app/controllers',"#{file_path}_controller.rb") end def generate_helper return unless options[:helpers] invoke 'helper', [name], options end end, classy_module do class_option :invite_only, :aliases => '-i', :type => :boolean, :desc => "Add features for an invite only website" private def invite_only? options[:invite_only] end end
- Defined in:
- lib/generators/hobo/front_controller/front_controller_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_routes ⇒ Object
- #generate_controller ⇒ Object
- #generate_index ⇒ Object
- #remove_index_html ⇒ Object
Class Method Details
.banner ⇒ Object
11 12 13 |
# File 'lib/generators/hobo/front_controller/front_controller_generator.rb', line 11 def self. "rails generate hobo:front_controller [NAME=front] [options]" end |
Instance Method Details
#add_routes ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/generators/hobo/front_controller/front_controller_generator.rb', line 44 def add_routes return unless [:add_routes] route "get 'search' => '#{file_path}#search', :as => 'site_search'" route "post 'search' => '#{file_path}#search', :as => 'site_search_post'" route "get '#{[:user_resource_name]}s/:id/activate_from_email/:key' => '#{[:user_resource_name]}s#activate', :as => 'activate_from_email'" route "get '#{[:user_resource_name]}s/:id/accept_invitation_from_email/:key' => '#{[:user_resource_name]}s#accept_invitation', :as => 'accept_invitation_from_email'" route "get '#{[:user_resource_name]}s/:id/reset_password_from_email/:key' => '#{[:user_resource_name]}s#reset_password', :as => 'reset_password_from_email'" if class_path.empty? route "root :to => '#{file_path}#index'" route "get ENV['RAILS_RELATIVE_URL_ROOT'] => 'front#index' if ENV['RAILS_RELATIVE_URL_ROOT']" else route "get '#{file_path}' => '#{file_path}#index', :as => '#{file_path.gsub(/\//,'_')}'" end end |
#generate_controller ⇒ Object
31 32 33 |
# File 'lib/generators/hobo/front_controller/front_controller_generator.rb', line 31 def generate_controller template 'controller.rb.erb', File.join('app/controllers',"#{file_path}_controller.rb") end |
#generate_index ⇒ Object
35 36 37 |
# File 'lib/generators/hobo/front_controller/front_controller_generator.rb', line 35 def generate_index template("index.dryml", File.join('app/views', file_path, "index.dryml")) end |
#remove_index_html ⇒ Object
39 40 41 42 |
# File 'lib/generators/hobo/front_controller/front_controller_generator.rb', line 39 def remove_index_html return unless [:delete_index] remove_file File.join(Rails.root, "public/index.html") end |