Sha256: 119a4a906163ee006e27f45c8f31323ca4bb754f9a8b1497ff2c530f98c1bc0f

Contents?: true

Size: 809 Bytes

Versions: 12

Compression:

Stored size: 809 Bytes

Contents

# Requires
require 'rails/generators'
require 'rails/generators/migration'

class PurgatoryGenerator < Rails::Generators::Base
  include Rails::Generators::Migration
  def self.source_root
    @source_root ||= File.join(File.dirname(__FILE__), 'templates')
  end

  def self.next_migration_number(dirname)
    if ActiveRecord::Base.timestamped_migrations
      Time.new.utc.strftime("%Y%m%d%H%M%S")
    else
      "%.3d" % (current_migration_number(dirname) + 1)
    end
  end

  def create_migration_file
    migration_template 'create_purgatories.rb', 'db/migrate/create_purgatories.rb'
  end

  def create_initializer_file
    create_file 'config/initializers/purgatory.rb', <<-eos
PurgatoryModule.configure do |config|
  config.user_class_name = 'User'
end

require 'purgatory/purgatory'
    eos
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
purgatory-2.14.0 lib/generators/purgatory/purgatory_generator.rb
purgatory-2.13.0 lib/generators/purgatory/purgatory_generator.rb
purgatory-2.12.0 lib/generators/purgatory/purgatory_generator.rb
purgatory-2.11.0 lib/generators/purgatory/purgatory_generator.rb
purgatory-2.10.0 lib/generators/purgatory/purgatory_generator.rb
purgatory-2.9.0 lib/generators/purgatory/purgatory_generator.rb
purgatory-2.8.0 lib/generators/purgatory/purgatory_generator.rb
purgatory-2.7.0 lib/generators/purgatory/purgatory_generator.rb
purgatory-2.6.0 lib/generators/purgatory/purgatory_generator.rb
purgatory-2.5.0 lib/generators/purgatory/purgatory_generator.rb
purgatory-2.4.0 lib/generators/purgatory/purgatory_generator.rb
purgatory-2.3.0 lib/generators/purgatory/purgatory_generator.rb