Class: Comfy::Generators::GalleryGenerator

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object



31
32
33
# File 'lib/generators/comfy/gallery/gallery_generator.rb', line 31

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

Instance Method Details

#generate_initializationObject



23
24
25
# File 'lib/generators/comfy/gallery/gallery_generator.rb', line 23

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

#generate_migrationObject



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/generators/comfy/gallery/gallery_generator.rb', line 11

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

#show_readmeObject



27
28
29
# File 'lib/generators/comfy/gallery/gallery_generator.rb', line 27

def show_readme
  readme 'lib/generators/comfy/gallery/README'
end