Sha256: 99609f14dcedadbd51f9346ea053c85330b83d0e5a8f0b1d9c97f2af0fbc34e8

Contents?: true

Size: 1.23 KB

Versions: 3

Compression:

Stored size: 1.23 KB

Contents

module Comfy
  module Generators
    class GalleryGenerator < 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_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
      
      def generate_initialization
        copy_file 'config/initializers/comfy_gallery.rb', 'config/initializers/comfy_gallery.rb'
      end
      
      def show_readme
        readme 'lib/generators/comfy/gallery/README'
      end
      
      def self.next_migration_number(dirname)
        ActiveRecord::Generators::Base.next_migration_number(dirname)
      end
      
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
comfy_gallery-0.1.3 lib/generators/comfy/gallery/gallery_generator.rb
comfy_gallery-0.1.2 lib/generators/comfy/gallery/gallery_generator.rb
comfy_gallery-0.1.1 lib/generators/comfy/gallery/gallery_generator.rb