Sha256: 6e6de0c9ea4c897fcfe5880b624b4b5a629a2f24903c310ce511244d2c8f2ff8

Contents?: true

Size: 1.19 KB

Versions: 6

Compression:

Stored size: 1.19 KB

Contents

module Comfy
  module Generators
    class BlogGenerator < 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_blog.rb', self.destination_root)
        migration_dir = File.dirname(destination)
        destination   = self.class.migration_exists?(migration_dir, 'create_comfy_blog')
        
        if destination
          puts "\e[0m\e[31mFound existing create_comfy_blog.rb migration. Remove it if you want to regenerate.\e[0m"
        else
          migration_template 'db/migrate/01_create_comfy_blog.rb', 'db/migrate/create_comfy_blog.rb'
        end
      end
      
      def generate_initialization
        copy_file 'config/initializers/comfy_blog.rb', 'config/initializers/comfy_blog.rb'
      end
      
      def show_readme
        readme 'lib/generators/comfy/blog/README'
      end
      
      def self.next_migration_number(dirname)
        ActiveRecord::Generators::Base.next_migration_number(dirname)
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
comfy_blog-0.1.8 lib/generators/comfy/blog/blog_generator.rb
comfy_blog-0.1.7 lib/generators/comfy/blog/blog_generator.rb
comfy_blog-0.1.6 lib/generators/comfy/blog/blog_generator.rb
comfy_blog-0.1.5 lib/generators/comfy/blog/blog_generator.rb
comfy_blog-0.1.4 lib/generators/comfy/blog/blog_generator.rb
comfy_blog-0.1.3 lib/generators/comfy/blog/blog_generator.rb