Sha256: 5bf97d3aa9fcce0feb2d6c9a648bbe5122ec83c1638bd46f3f473b4e37e5eb32

Contents?: true

Size: 763 Bytes

Versions: 16

Compression:

Stored size: 763 Bytes

Contents

require 'rails/generators/migration'

module ActsAsVotable
  class MigrationGenerator < Rails::Generators::Base
    include Rails::Generators::Migration

    desc "Generates migration for votable (votes table)"

    def self.orm
      Rails::Generators.options[:rails][:orm]
    end

    def self.source_root
      File.join(File.dirname(__FILE__), 'templates', (orm.to_s unless orm.class.eql?(String)) )
    end

    def self.orm_has_migration?
      [:active_record].include? orm
    end

    def self.next_migration_number(path)
      Time.now.utc.strftime("%Y%m%d%H%M%S")
    end

    def create_migration_file
      if self.class.orm_has_migration?
        migration_template 'migration.rb', 'db/migrate/acts_as_votable_migration'
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
acts_as_votable-0.8.0 lib/generators/acts_as_votable/migration/migration_generator.rb
acts_as_votable-0.7.1 lib/generators/acts_as_votable/migration/migration_generator.rb
acts_as_votable-0.7.0 lib/generators/acts_as_votable/migration/migration_generator.rb
acts_as_votable-0.6.0 lib/generators/acts_as_votable/migration/migration_generator.rb
acts_as_votable-0.5.0 lib/generators/acts_as_votable/migration/migration_generator.rb
acts_as_votable-0.4.0 lib/generators/acts_as_votable/migration/migration_generator.rb
jy-acts_as_votable-0.3.1 lib/generators/acts_as_votable/migration/migration_generator.rb
acts_as_votable-0.3.1 lib/generators/acts_as_votable/migration/migration_generator.rb
acts_as_votable-0.3.0 lib/generators/acts_as_votable/migration/migration_generator.rb
acts_as_votable-0.2.0 lib/generators/acts_as_votable/migration/migration_generator.rb
acts_as_votable-0.1.3 lib/generators/acts_as_votable/migration/migration_generator.rb
acts_as_votable-0.1.2 lib/generators/acts_as_votable/migration/migration_generator.rb
acts_as_votable-0.1.1 lib/generators/acts_as_votable/migration/migration_generator.rb
acts_as_votable-0.1.0 lib/generators/acts_as_votable/migration/migration_generator.rb
acts_as_votable-0.0.5 lib/generators/acts_as_votable/migration/migration_generator.rb
acts_as_votable-0.0.4 lib/generators/acts_as_votable/migration/migration_generator.rb