Class: Ckeditor::Generators::InstallGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Ckeditor::Generators::InstallGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/ckeditor/install_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#copy_initializer ⇒ Object
copy configuration.
- #create_ckeditor_migration ⇒ Object
- #create_models ⇒ Object
- #create_uploaders ⇒ Object
- #mount_engine ⇒ Object
Class Method Details
.next_migration_number(_dirname) ⇒ Object
24 25 26 |
# File 'lib/generators/ckeditor/install_generator.rb', line 24 def self.next_migration_number(_dirname) Time.now.utc.strftime('%Y%m%d%H%M%S') end |
.source_root ⇒ Object
20 21 22 |
# File 'lib/generators/ckeditor/install_generator.rb', line 20 def self.source_root @source_root ||= File.(File.join(File.dirname(__FILE__), 'templates')) end |
Instance Method Details
#copy_initializer ⇒ Object
copy configuration
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/generators/ckeditor/install_generator.rb', line 29 def copy_initializer template 'ckeditor.rb', 'config/initializers/ckeditor.rb' if backend_dragonfly? template 'base/dragonfly/initializer.rb', 'config/initializers/ckeditor_dragonfly.rb' end if backend_shrine? template 'base/shrine/initializer.rb', 'config/initializers/ckeditor_shrine.rb' end end |
#create_ckeditor_migration ⇒ Object
67 68 69 70 71 72 |
# File 'lib/generators/ckeditor/install_generator.rb', line 67 def create_ckeditor_migration return unless ['active_record'].include?(orm) migration_template "#{generator_dir}/migration.rb", File.join('db/migrate', 'create_ckeditor_assets.rb') end |
#create_models ⇒ Object
45 46 47 48 49 50 |
# File 'lib/generators/ckeditor/install_generator.rb', line 45 def create_models [:asset, :picture, :attachment_file].each do |filename| template "#{generator_dir}/ckeditor/#{filename}.rb", File.join('app/models', ckeditor_dir, "#{filename}.rb") end end |
#create_uploaders ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/generators/ckeditor/install_generator.rb', line 52 def create_uploaders if backend_carrierwave? template "#{uploaders_dir}/ckeditor_attachment_file_uploader.rb", File.join('app/uploaders', 'ckeditor_attachment_file_uploader.rb') template "#{uploaders_dir}/ckeditor_picture_uploader.rb", File.join('app/uploaders', 'ckeditor_picture_uploader.rb') end if backend_shrine? template "#{uploaders_dir}/ckeditor_attachment_uploader.rb", File.join('app/uploaders', 'ckeditor_attachment_uploader.rb') end end |
#mount_engine ⇒ Object
41 42 43 |
# File 'lib/generators/ckeditor/install_generator.rb', line 41 def mount_engine route "mount Ckeditor::Engine => '/ckeditor'" end |