Class: Cms9::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Cms9::Generators::InstallGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/cms9/install/install_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #copy_ckeditor_config ⇒ Object
- #copy_initializer ⇒ Object
- #generate_migration ⇒ Object
- #mount_engine_route ⇒ Object
- #show_info ⇒ Object
Class Method Details
.next_migration_number(dirname) ⇒ Object
36 37 38 |
# File 'lib/generators/cms9/install/install_generator.rb', line 36 def self.next_migration_number(dirname) ActiveRecord::Generators::Base.next_migration_number(dirname) end |
Instance Method Details
#copy_ckeditor_config ⇒ Object
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/generators/cms9/install/install_generator.rb', line 25 def copy_ckeditor_config copy_file 'templates/ckeditor_config.js', 'app/assets/javascripts/ckeditor/config.js' data = File.read("app/assets/javascripts/ckeditor/config.js") filtered_data = data.gsub("cms9", file_name) File.open("app/assets/javascripts/ckeditor/config.js", "w") do |f| f.write(filtered_data) end end |
#copy_initializer ⇒ Object
19 20 21 22 23 |
# File 'lib/generators/cms9/install/install_generator.rb', line 19 def copy_initializer puts "Copying necessary files..." copy_file 'templates/cms9_configurator.rb', 'config/initializers/cms9_configurator.rb' puts "" end |
#generate_migration ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/generators/cms9/install/install_generator.rb', line 40 def generate_migration cms9_file_dir = File.('../../../../../db/migrate/.', __FILE__) files = [] Dir.foreach(cms9_file_dir) do |file| files << file unless file =~ /^\.\.?$/ end files.each do |migration| destination = File.('db/migrate/' + migration, self.destination_root) migration_dir = File.dirname(destination) only_name = File.basename(migration, File.extname(migration)) destination = self.class.migration_exists?(migration_dir, only_name) if destination puts "\n\e[0m\e[31mFound existing " + migration + " migration. Remove it if you want to regenerate.\e[0m" else puts "" migration_template '../../../../db/migrate/' + migration, 'db/migrate/' + migration end end end |
#mount_engine_route ⇒ Object
13 14 15 16 17 |
# File 'lib/generators/cms9/install/install_generator.rb', line 13 def mount_engine_route puts "\nMounting Cms9::Engine on " + "/" + file_name + " route" route "mount Cms9::Engine => " + "'/" + file_name + "'" puts "\n" end |
#show_info ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/generators/cms9/install/install_generator.rb', line 63 def show_info puts "\n *************************************************************************" puts " * *" puts " * Everything is almost done. Please don\'t forget to *" puts " * * run migrations -> `\033[32mrails db:migrate\033[0m` *" puts " * *" puts " * Some things you must do manually if you haven\'t yet *" puts " * Visit \033[32mhttps://github.com/klikaba/cms9\033[0m for more informations *" puts " * *" puts " *************************************************************************\n\n" end |