Sha256: e1bb81c2838d4984a91c81487c1d88f62a1114cd62a1cdeac5c7f67700566ca3

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require 'rails/generators/migration'
require 'rails/generators/active_record'

class RatemeGenerator < Rails::Generators::Base
  include Rails::Generators::Migration
  source_root File.expand_path('../templates', __FILE__)

  class_option :migration, 
    :type => :boolean, 
    :default => true, 
    :description => "Generate a migration file for this model"

  class_option :stylesheet, 
    :type => :boolean, 
    :default => true, 
    :description => "Generate the images, stylesheet and javascript"

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

  def generate_layout
    template "model.rb", 
      "app/models/rating.rb"

    if options.migration?
      migration_template "migration.rb", 
        "db/migrate/create_ratings.rb"
    end

    if options.stylesheet?
      copy_file "stylesheet.css",
        "public/stylesheets/rateme.css"

      copy_file "javascript.js", 
        "public/javascripts/rateme.js"

      copy_file "stars.gif", 
        "public/images/stars.gif"

      copy_file "spinner.gif", 
        "public/images/spinner.gif"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rateme-0.1.0 lib/generators/rateme/rateme_generator.rb