Class: Ragdoll::InitGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Ragdoll::InitGenerator
- Includes:
- Rails::Generators::Migration
- Defined in:
- lib/generators/ragdoll/init_generator.rb
Class Method Summary collapse
-
.next_migration_number(dirname) ⇒ Object
Required for Rails::Generators::Migration.
Instance Method Summary collapse
Class Method Details
.next_migration_number(dirname) ⇒ Object
Required for Rails::Generators::Migration
64 65 66 |
# File 'lib/generators/ragdoll/init_generator.rb', line 64 def self.next_migration_number(dirname) ::ActiveRecord::Generators::Base.next_migration_number(dirname) end |
Instance Method Details
#copy_migrations ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/generators/ragdoll/init_generator.rb', line 17 def copy_migrations say "Installing Ragdoll migrations..." # Find the ragdoll gem path begin ragdoll_path = Gem::Specification.find_by_name('ragdoll').gem_dir rescue Gem::MissingSpecError # If not found as a gem (e.g., using path in Gemfile), try to find it relative to this engine ragdoll_path = File.("../../../../../ragdoll", __dir__) end migration_source_path = File.join(ragdoll_path, 'db/migrate') if File.exist?(migration_source_path) Dir.glob("#{migration_source_path}/*.rb").each do |migration_file| migration_name = File.basename(migration_file) # Check if migration already exists in the app if migration_exists?(migration_name) say_status "skip", migration_name, :yellow else copy_file migration_file, "db/migrate/#{migration_name}" say_status "copied", migration_name, :green end end else say "Warning: Could not find Ragdoll migrations at #{migration_source_path}", :red end end |
#create_initializer_file ⇒ Object
13 14 15 |
# File 'lib/generators/ragdoll/init_generator.rb', line 13 def create_initializer_file template "ragdoll_config.rb", "config/initializers/ragdoll_config.rb" end |
#show_readme ⇒ Object
47 48 49 |
# File 'lib/generators/ragdoll/init_generator.rb', line 47 def show_readme readme "INSTALL" if behavior == :invoke end |