Sha256: 4f1fbb19771655c61fdc778847518381b9cbee24574c7693b5ae71acfa8082a7

Contents?: true

Size: 1.03 KB

Versions: 7

Compression:

Stored size: 1.03 KB

Contents

class SofaGalleryGenerator < Rails::Generators::Base
  
  require 'rails/generators/active_record'
  include Rails::Generators::Migration
  include Thor::Actions
  
  source_root File.expand_path('../../..', __FILE__)
  
  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
  
  def generate_initialization
    copy_file 'config/initializers/sofa_gallery.rb', 'config/initializers/sofa_gallery.rb'
  end
  
  def show_readme
    readme 'lib/generators/README'
  end
  
  def self.next_migration_number(dirname)
    ActiveRecord::Generators::Base.next_migration_number(dirname)
  end
  
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
sofa_gallery-0.0.6 lib/generators/sofa_gallery_generator.rb
sofa_gallery-0.0.5 lib/generators/sofa_gallery_generator.rb
sofa_gallery-0.0.4 lib/generators/sofa_gallery_generator.rb
sofa_gallery-0.0.3 lib/generators/sofa_gallery_generator.rb
sofa_gallery-0.0.2 lib/generators/sofa_gallery_generator.rb
sofa_gallery-0.0.1 lib/generators/sofa_gallery_generator.rb
sofa_gallery-0.0.0 lib/generators/sofa_gallery_generator.rb