Sha256: 23c4b188654691e42938e20832f5a268702e9d806f2b62ea797a3e26e4cdfeab
Contents?: true
Size: 1.36 KB
Versions: 6
Compression:
Stored size: 1.36 KB
Contents
require_relative 'constants' module UnderConstruction module Generators class ConfigGenerator < ::Rails::Generators::Base source_root File.expand_path("../templates", __FILE__) desc 'Configs application controller' def edit_application_Controller if File.exist?(Rails.root + "app/controllers/application_controller.rb") insert_into_file "app/controllers/application_controller.rb", APPLICATION_CONFIG_TXT, :after => "protect_from_forgery" else raise 'Couldn\'t find application_controller file' end end def copy_config_file copy_file 'under_construction.yml', 'config/under_construction.yml' end def config_route_file file_path = 'config/routes.rb' gsub_file file_path, /match "under_construction", :to => redirect\('\/'\)/, '' insert_into_file file_path, ROUTES_CONFIG_TXT, after: /Application.routes.draw do/ gsub_file file_path, /(Application.routes.draw do)(.*)(end)/m, '\1\2'+"#{ROUTES_REDIRECT_TO_TXT}" + '\3' end def copy_index_file_to_app directory 'under_construction', 'app/views/under_construction' end def copy_scheduler_initializer destination_path = 'config/initializers/under_construction_scheduler.rb' copy_file 'under_construction_scheduler.rb', destination_path end end end end
Version data entries
6 entries across 6 versions & 1 rubygems