Sha256: bd9b11a779ed143e659a50a0740e3c863edb8c831123ab96c6ceb3e47ada688f

Contents?: true

Size: 1.22 KB

Versions: 3

Compression:

Stored size: 1.22 KB

Contents

module Comfy
  module Generators
    class CarouselGenerator < 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_carousel.rb', self.destination_root)
        migration_dir = File.dirname(destination)
        destination   = self.class.migration_exists?(migration_dir, 'create_comfy_carousel')
        
        if destination
          puts "\e[0m\e[31mFound existing create_comfy_carousel.rb migration. Remove it if you want to regenerate.\e[0m"
        else
          migration_template 'db/migrate/01_create_comfy_carousel.rb', 'db/migrate/create_comfy_carousel.rb'
        end
      end
      
      def generate_initialization
        copy_file 'config/initializers/comfy_carousel.rb', 'config/initializers/comfy_carousel.rb'
      end
      
      def show_readme
        readme 'lib/generators/comfy/carousel/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_carousel-0.0.3 lib/generators/comfy/carousel/carousel_generator.rb
comfy_carousel-0.0.2 lib/generators/comfy/carousel/carousel_generator.rb
comfy_carousel-0.0.1 lib/generators/comfy/carousel/carousel_generator.rb