Class: Authlogic::Generators::CompleteGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Authlogic::Generators::CompleteGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/authlogic/complete/complete_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_application_controller_helper_methods ⇒ Object
- #add_default_users_to_populate_rake_task ⇒ Object
- #add_routes ⇒ Object
- #create__unit_tests ⇒ Object
- #create_controllers ⇒ Object
- #create_database_migration ⇒ Object
- #create_functional_tests ⇒ Object
- #create_models ⇒ Object
- #create_user_fixtures ⇒ Object
- #create_views ⇒ Object
- #setup_test_helper ⇒ Object
Class Method Details
.next_migration_number(dirname) ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/generators/authlogic/complete/complete_generator.rb', line 61 def self.next_migration_number(dirname) if ActiveRecord::Base. Time.now.utc.strftime("%Y%m%d%H%M%S") else "%.3d" % (current_migration_number(dirname) + 1) end end |
Instance Method Details
#add_application_controller_helper_methods ⇒ Object
22 23 24 |
# File 'lib/generators/authlogic/complete/complete_generator.rb', line 22 def add_application_controller_helper_methods inject_into_file "#{Rails.root}/app/controllers/application_controller.rb", IO.read("#{CompleteGenerator.source_root}/_application_controller.rb"), :after => "protect_from_forgery" end |
#add_default_users_to_populate_rake_task ⇒ Object
30 31 32 |
# File 'lib/generators/authlogic/complete/complete_generator.rb', line 30 def add_default_users_to_populate_rake_task inject_into_file "#{Rails.root}/lib/tasks/populate.rake", IO.read("#{CompleteGenerator.source_root}/_populate.rake"), :after => "require 'faker'" end |
#add_routes ⇒ Object
34 35 36 |
# File 'lib/generators/authlogic/complete/complete_generator.rb', line 34 def add_routes inject_into_file "#{Rails.root}/config/routes.rb", IO.read("#{CompleteGenerator.source_root}/_routes.rb"), :after => "::Application.routes.draw do" end |
#create__unit_tests ⇒ Object
48 49 50 |
# File 'lib/generators/authlogic/complete/complete_generator.rb', line 48 def create__unit_tests copy_file "user_test.rb", "#{Rails.root}/test/unit/user_test.rb" end |
#create_controllers ⇒ Object
17 18 19 20 |
# File 'lib/generators/authlogic/complete/complete_generator.rb', line 17 def create_controllers copy_file "users_controller.rb", "#{Rails.root}/app/controllers/users_controller.rb" copy_file "user_sessions_controller.rb", "#{Rails.root}/app/controllers/user_sessions_controller.rb" end |
#create_database_migration ⇒ Object
69 70 71 |
# File 'lib/generators/authlogic/complete/complete_generator.rb', line 69 def create_database_migration migration_template "migration_create_users.rb", "db/migrate/create_users.rb" end |
#create_functional_tests ⇒ Object
52 53 54 55 |
# File 'lib/generators/authlogic/complete/complete_generator.rb', line 52 def create_functional_tests copy_file "users_controller_test.rb", "#{Rails.root}/test/functional/users_controller_test.rb" copy_file "user_sessions_controller_test.rb", "#{Rails.root}/test/functional/user_sessions_controller_test.rb" end |
#create_models ⇒ Object
12 13 14 15 |
# File 'lib/generators/authlogic/complete/complete_generator.rb', line 12 def create_models copy_file "user.rb", "#{Rails.root}/app/models/user.rb" copy_file "user_session.rb", "#{Rails.root}/app/models/user_session.rb" end |
#create_user_fixtures ⇒ Object
57 58 59 |
# File 'lib/generators/authlogic/complete/complete_generator.rb', line 57 def create_user_fixtures copy_file "users.yml", "#{Rails.root}/test/fixtures/users.yml" end |
#create_views ⇒ Object
26 27 28 |
# File 'lib/generators/authlogic/complete/complete_generator.rb', line 26 def create_views end |
#setup_test_helper ⇒ Object
38 39 40 41 42 43 44 45 46 |
# File 'lib/generators/authlogic/complete/complete_generator.rb', line 38 def setup_test_helper inject_into_file "#{Rails.root}/test/test_helper.rb", IO.read("#{CompleteGenerator.source_root}/_test_helper_require.rb"), :after => "require 'rails/test_help'" inject_into_class "#{Rails.root}/test/test_helper.rb", ActiveSupport::TestCase do IO.read(File.('../', __FILE__) + "/templates/_test_helper_fixture_settings.rb") end append_file "#{Rails.root}/test/test_helper.rb" do IO.read("#{CompleteGenerator.source_root}/_test_helper_setup.rb") end end |