Class: SofaGalleryGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration, Thor::Actions
Defined in:
lib/generators/sofa_gallery_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object



29
30
31
# File 'lib/generators/sofa_gallery_generator.rb', line 29

def self.next_migration_number(dirname)
  ActiveRecord::Generators::Base.next_migration_number(dirname)
end

Instance Method Details

#generate_initializationObject



21
22
23
# File 'lib/generators/sofa_gallery_generator.rb', line 21

def generate_initialization
  copy_file 'config/initializers/sofa_gallery.rb', 'config/initializers/sofa_gallery.rb'
end

#generate_migrationObject



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/generators/sofa_gallery_generator.rb', line 9

def generate_migration
  destination   = File.expand_path('db/migrate/01_create_sofa_gallery.rb', self.destination_root)
  migration_dir = File.dirname(destination)
  destination   = self.class.migration_exists?(migration_dir, 'create_sofa_gallery')
  
  if destination
    puts "\e[0m\e[31mFound existing create_cms_gallery.rb migration. Remove it if you want to regenerate.\e[0m"
  else
    migration_template 'db/migrate/01_create_sofa_gallery.rb', 'db/migrate/create_sofa_gallery.rb'
  end
end

#show_readmeObject



25
26
27
# File 'lib/generators/sofa_gallery_generator.rb', line 25

def show_readme
  readme 'lib/generators/README'
end