-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Oleg
committed
Feb 6, 2012
1 parent
946c1b0
commit 7ccd6ba
Showing
4 changed files
with
35 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |