Class: Arpa::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Arpa::Generators::InstallGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/arpa/install_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #add_controllers ⇒ Object
- #add_routes ⇒ Object
- #copy_locales ⇒ Object
- #copy_resources_views_files ⇒ Object
- #copy_stylesheet_files ⇒ Object
- #create_migrate_files ⇒ Object
Class Method Details
.next_migration_number(dirname) ⇒ Object
8 9 10 11 |
# File 'lib/generators/arpa/install_generator.rb', line 8 def self.next_migration_number(dirname) return Time.new.utc.strftime("%Y%m%d%H%M%S") if ActiveRecord::Base. "%.3d" % (current_migration_number(dirname) + 1) end |
Instance Method Details
#add_controllers ⇒ Object
38 39 40 41 42 |
# File 'lib/generators/arpa/install_generator.rb', line 38 def add_controllers copy_file '../../arpa/controllers/resources_controller.rb', 'app/controllers/arpa/resources_controller.rb' copy_file '../../arpa/controllers/roles_controller.rb', 'app/controllers/arpa/roles_controller.rb' copy_file '../../arpa/controllers/profiles_controller.rb', 'app/controllers/arpa/profiles_controller.rb' end |
#add_routes ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/generators/arpa/install_generator.rb', line 44 def add_routes route "scope module: :arpa do\n resources :resources do\ncollection do\n get 'generate_resources_and_actions'\nend\n end\n\n resources :roles do\ncollection do\n delete ':id', to: 'roles#remove'\nend\n end\n\n resources :profiles do\ncollection do\n delete ':id', to: 'profiles#remove'\nend\n end\n end\n RUBY\nend\n" |
#copy_locales ⇒ Object
68 69 70 |
# File 'lib/generators/arpa/install_generator.rb', line 68 def copy_locales copy_file '../../config/locales/arpa.en.yml', 'config/locales/arpa.en.yml' end |
#copy_resources_views_files ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/generators/arpa/install_generator.rb', line 17 def copy_resources_views_files copy_file '../../arpa/views/resources/index.html.erb', 'app/views/arpa/resources/index.html.erb' copy_file '../../arpa/views/resources/show.html.erb', 'app/views/arpa/resources/show.html.erb' copy_file '../../arpa/views/roles/index.html.erb', 'app/views/arpa/roles/index.html.erb' copy_file '../../arpa/views/roles/show.html.erb', 'app/views/arpa/roles/show.html.erb' copy_file '../../arpa/views/roles/new.html.erb', 'app/views/arpa/roles/new.html.erb' copy_file '../../arpa/views/roles/edit.html.erb', 'app/views/arpa/roles/edit.html.erb' copy_file '../../arpa/views/roles/_form.html.erb', 'app/views/arpa/roles/_form.html.erb' copy_file '../../arpa/views/profiles/index.html.erb', 'app/views/arpa/profiles/index.html.erb' copy_file '../../arpa/views/profiles/show.html.erb', 'app/views/arpa/profiles/show.html.erb' copy_file '../../arpa/views/profiles/new.html.erb', 'app/views/arpa/profiles/new.html.erb' copy_file '../../arpa/views/profiles/edit.html.erb', 'app/views/arpa/profiles/edit.html.erb' copy_file '../../arpa/views/profiles/_form.html.erb', 'app/views/arpa/profiles/_form.html.erb' end |
#copy_stylesheet_files ⇒ Object
34 35 36 |
# File 'lib/generators/arpa/install_generator.rb', line 34 def copy_stylesheet_files copy_file '../../arpa/assets/stylesheets/arpa_accordion.scss', 'app/assets/stylesheets/arpa/arpa_accordion.scss' end |
#create_migrate_files ⇒ Object
13 14 15 |
# File 'lib/generators/arpa/install_generator.rb', line 13 def create_migrate_files migration_template 'templates/migration.rb', 'db/migrate/create_arpa_tables.rb' end |