Sha256: ead4ce9f4d3cc783e5981bddcede43249008603d7ebe74872f8e20e9a6548dc5

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

require 'rails/generators'

class SanteyBlogGenerator < Rails::Generators::Base
  include Rails::Generators::Migration
  
  class_option :css,     :type => :boolean, :default => false, :desc => "--css option - Install stylesheets to public/stylesheets"
  class_option :migrate, :type => :boolean, :default => false, :desc => "--migrate option - Install migrations to db/migrate"
  
  def self.source_root
    @source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
  end
  
  def self.next_migration_number(dirname)
    Time.now.strftime("%Y%m%d%H%M%S")
  end
  
  def install_config
    directory "initializers", "config/initializers"
  end
  
  # copy stylesheets to public folder
  def install_css
  	if options[:css] == true
      directory "css", "public/stylesheets/santey_blog"
      directory "images", "public/images/santey_blog"
    end
  end
  
  # copy migrations to db/migrate
  def install_migrations
    migration_template "migrations/create_posts.rb", File.join('db/migrate', "create_posts.rb") if options[:migrate] == true
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
santey_blog-0.2.1 lib/generators/santey_blog_generator.rb
santey_blog-0.2.0 lib/generators/santey_blog_generator.rb