Class: Comfy::Generators::BlogGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- Comfy::Generators::BlogGenerator
- Includes:
- Rails::Generators::Migration, Thor::Actions
- Defined in:
- lib/generators/comfy/blog/blog_generator.rb
Class Method Summary collapse
Instance Method Summary collapse
- #generate_initialization ⇒ Object
- #generate_migration ⇒ Object
- #generate_routing ⇒ Object
- #generate_views ⇒ Object
- #show_readme ⇒ Object
Class Method Details
.next_migration_number(dirname) ⇒ Object
12 13 14 |
# File 'lib/generators/comfy/blog/blog_generator.rb', line 12 def self.next_migration_number(dirname) ActiveRecord::Generators::Base.next_migration_number(dirname) end |
Instance Method Details
#generate_initialization ⇒ Object
28 29 30 31 |
# File 'lib/generators/comfy/blog/blog_generator.rb', line 28 def generate_initialization copy_file 'config/initializers/comfy_blog.rb', 'config/initializers/comfy_blog.rb' end |
#generate_migration ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/generators/comfy/blog/blog_generator.rb', line 16 def generate_migration destination = File.('db/migrate/01_create_blog.rb', self.destination_root) migration_dir = File.dirname(destination) destination = self.class.migration_exists?(migration_dir, 'create_blog') if destination puts "\e[0m\e[31mFound existing create_blog migration. Remove it if you want to regenerate.\e[0m" else migration_template 'db/migrate/01_create_blog.rb', 'db/migrate/create_blog.rb' end end |
#generate_routing ⇒ Object
33 34 35 36 37 |
# File 'lib/generators/comfy/blog/blog_generator.rb', line 33 def generate_routing route_string = " comfy_route :blog_admin, :path => '/admin'\n" route_string << " comfy_route :blog, :path => '/blog'\n" route route_string[2..-1] end |
#generate_views ⇒ Object
39 40 41 |
# File 'lib/generators/comfy/blog/blog_generator.rb', line 39 def generate_views directory 'app/views/blog', 'app/views/blog' end |
#show_readme ⇒ Object
43 44 45 |
# File 'lib/generators/comfy/blog/blog_generator.rb', line 43 def show_readme readme 'lib/generators/comfy/blog/README' end |