Class: Connector::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Connector::Generators::InstallGenerator
- Defined in:
- lib/generators/connector/install_generator.rb
Instance Method Summary collapse
- #copy_admin_view ⇒ Object
- #copy_entity ⇒ Object
- #copy_example_entity ⇒ Object
- #copy_external ⇒ Object
- #copy_home ⇒ Object
- #copy_oauth_controller ⇒ Object
- #include_helpers ⇒ Object
- #include_routes ⇒ Object
- #maestrano_generator ⇒ Object
Instance Method Details
#copy_admin_view ⇒ Object
61 62 63 64 |
# File 'lib/generators/connector/install_generator.rb', line 61 def copy_admin_view copy_file 'admin_controller.rb', 'app/controllers/admin_controller.rb' copy_file 'admin_index.html.erb', 'app/views/admin/index.html.erb' end |
#copy_entity ⇒ Object
44 45 46 |
# File 'lib/generators/connector/install_generator.rb', line 44 def copy_entity copy_file 'entity.rb', 'app/models/maestrano/connector/rails/entity.rb' end |
#copy_example_entity ⇒ Object
52 53 54 |
# File 'lib/generators/connector/install_generator.rb', line 52 def copy_example_entity copy_file 'example_entity.rb', 'app/models/entities/example_entitiy.rb' end |
#copy_external ⇒ Object
48 49 50 |
# File 'lib/generators/connector/install_generator.rb', line 48 def copy_external copy_file 'external.rb', 'app/models/maestrano/connector/rails/external.rb' end |
#copy_home ⇒ Object
56 57 58 59 |
# File 'lib/generators/connector/install_generator.rb', line 56 def copy_home copy_file 'home_controller.rb', 'app/controllers/home_controller.rb' copy_file 'home_index.html.erb', 'app/views/home/index.html.erb' end |
#copy_oauth_controller ⇒ Object
66 67 68 |
# File 'lib/generators/connector/install_generator.rb', line 66 def copy_oauth_controller copy_file 'oauth_controller.rb', 'app/controllers/oauth_controller.rb' end |
#include_helpers ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/generators/connector/install_generator.rb', line 11 def include_helpers sentinel = 'class ApplicationController < ActionController::Base' code_lines = [ "helper Maestrano::Connector::Rails::Engine.helpers", "include Maestrano::Connector::Rails::SessionHelper" ] in_root do gsub_file 'app/controllers/application_controller.rb', /(#{Regexp.escape(sentinel)})/mi do |match| "#{match}\n #{code_lines.join("\n ")}\n" end end end |
#include_routes ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/generators/connector/install_generator.rb', line 25 def include_routes sentinel = 'Rails.application.routes.draw do' code_lines = [ "mount Maestrano::Connector::Rails::Engine, at: '/'\n", "root 'home#index'", "get 'home/index' => 'home#index'", "get 'admin/index' => 'admin#index'", "put 'admin/update' => 'admin#update'", "post 'admin/synchronize' => 'admin#synchronize'", "put 'admin/toggle_sync' => 'admin#toggle_sync'" ] in_root do gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match| "#{match}\n #{code_lines.join("\n ")}\n" end end end |
#maestrano_generator ⇒ Object
6 7 8 9 |
# File 'lib/generators/connector/install_generator.rb', line 6 def maestrano_generator #Temporary # generate 'maestrano:initializer' end |