Class: WristbandGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- WristbandGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/wristband/wristband_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #generate_controllers ⇒ Object
- #generate_migration ⇒ Object
- #generate_models ⇒ Object
- #generate_tests ⇒ Object
- #generate_user_mailer ⇒ Object
- #generate_views ⇒ Object
Class Method Details
.next_migration_number(dirname) ⇒ Object
62 63 64 65 66 |
# File 'lib/generators/wristband/wristband_generator.rb', line 62 def self.next_migration_number(dirname) orm = Rails.configuration.generators.[:rails][:orm] require "rails/generators/#{orm}" "#{orm.to_s.camelize}::Generators::Base".constantize.next_migration_number(dirname) end |
Instance Method Details
#generate_controllers ⇒ Object
12 13 14 15 16 17 |
# File 'lib/generators/wristband/wristband_generator.rb', line 12 def generate_controllers puts "\t== Controllers ==" copy_file 'app/controllers/users_controller.rb', 'app/controllers/users_controller.rb' copy_file 'app/controllers/sessions_controller.rb', 'app/controllers/sessions_controller.rb' copy_file 'app/controllers/passwords_controller.rb', 'app/controllers/passwords_controller.rb' end |
#generate_migration ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/generators/wristband/wristband_generator.rb', line 49 def generate_migration puts "\t== Migration ==" destination = File.('db/migrate/01_create_users_table.rb', self.destination_root) migration_dir = File.dirname(destination) destination = self.class.migration_exists?(migration_dir, 'create_users_table') if destination puts "\e[0m\e[31mFound existing create_users_table.rb migration. Remove it if you want to regenerate.\e[0m" else migration_template 'db/migrate/01_create_users_table.rb', 'db/migrate/create_users_table.rb' end end |
#generate_models ⇒ Object
6 7 8 9 10 |
# File 'lib/generators/wristband/wristband_generator.rb', line 6 def generate_models puts "\t== Models ==" copy_file 'app/models/user.rb', 'app/models/user.rb' copy_file 'app/models/session_user.rb', 'app/models/session_user.rb' end |
#generate_tests ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/generators/wristband/wristband_generator.rb', line 34 def generate_tests puts "\t== Test helper and Dummies ==" copy_file 'test/test_helper.rb', 'test/test_helper.rb' copy_file 'test/dummy/user.rb', 'test/dummy/user.rb' puts "\t== Unit tests ==" copy_file 'test/unit/user_test.rb', 'test/unit/user_test.rb' copy_file 'test/unit/session_user_test.rb', 'test/unit/session_user_test.rb' copy_file 'test/unit/user_mailer_test.rb', 'test/unit/user_mailer_test.rb' puts "\t== Functional tests ==" copy_file 'test/functional/sessions_controller_test.rb', 'test/functional/sessions_controller_test.rb' copy_file 'test/functional/passwords_controller_test.rb', 'test/functional/passwords_controller_test.rb' end |
#generate_user_mailer ⇒ Object
27 28 29 30 31 32 |
# File 'lib/generators/wristband/wristband_generator.rb', line 27 def generate_user_mailer puts "\t== User Mailer ==" copy_file 'app/mailers/user_mailer.rb', 'app/mailers/user_mailer.rb' copy_file'app/views/user_mailer/password_reset.html.haml', 'app/views/user_mailer/password_reset.html.haml' copy_file 'app/views/user_mailer/password_reset.text.haml', 'app/views/user_mailer/password_reset.text.haml' end |
#generate_views ⇒ Object
19 20 21 22 23 24 25 |
# File 'lib/generators/wristband/wristband_generator.rb', line 19 def generate_views puts "\t== Views ==" copy_file 'app/views/users/show.html.haml', 'app/views/users/show.html.haml' copy_file 'app/views/sessions/new.html.haml', 'app/views/sessions/new.html.haml' copy_file 'app/views/passwords/new.html.haml', 'app/views/passwords/new.html.haml' copy_file 'app/views/passwords/edit.html.haml', 'app/views/passwords/edit.html.haml' end |