Skip to content

Commit

Permalink
more generator things
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg committed Feb 6, 2012
1 parent 946c1b0 commit 7ccd6ba
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 33 deletions.
2 changes: 0 additions & 2 deletions comfy_carousel.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ Gem::Specification.new do |s|
"lib/comfy_carousel/configuration.rb",
"lib/comfy_carousel/engine.rb",
"lib/comfy_carousel/form_builder.rb",
"lib/generators/comfy/README",
"lib/generators/comfy/carousel_generator.rb",
"lib/tasks/.gitkeep",
"log/.gitkeep",
"script/rails",
Expand Down
31 changes: 0 additions & 31 deletions lib/comfy/generators/carousel_generator.rb

This file was deleted.

File renamed without changes.
35 changes: 35 additions & 0 deletions lib/generators/carousel_generator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
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_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_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/README'
end

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

0 comments on commit 7ccd6ba

Please sign in to comment.