Class: UnderConstruction::Generators::ClearGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- UnderConstruction::Generators::ClearGenerator
- Defined in:
- lib/generators/under_construction/clear_generator.rb
Instance Method Summary collapse
Instance Method Details
#clear_application_controller ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'lib/generators/under_construction/clear_generator.rb', line 7 def clear_application_controller if File.exist?('app/controllers/application_controller.rb') # remove the exact block we've inserted. We don't want # to remove the block if user has edited it gsub_file 'app/controllers/application_controller.rb', /#{Regexp.escape(APPLICATION_CONFIG_TXT)}/, '' end end |
#clear_routes_file ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/generators/under_construction/clear_generator.rb', line 16 def clear_routes_file file_path = 'config/routes.rb' gsub_file file_path, /#{Regexp.escape(ROUTES_CONFIG_TXT)}/, '' gsub_file file_path, /#{Regexp.escape(ROUTES_REDIRECT_TO_TXT)}/, '' if ::Rails::VERSION::MAJOR >= 4 insert_into_file file_path, ROUTES_CLEAR_TXT, after: /Rails.application.routes.draw do/ else insert_into_file file_path, ROUTES_CLEAR_TXT, after: /Application.routes.draw do/ end end |
#remove_scheduler_file ⇒ Object
27 28 29 30 31 32 |
# File 'lib/generators/under_construction/clear_generator.rb', line 27 def remove_scheduler_file file_path = 'config/initializers/under_construction_scheduler.rb' if File.exist? file_path remove_file file_path end end |