Sha256: 5c4d8aa87f4ca258e8a67c2c2f0e3e2e0f94e646c4ac9273a37a782031007a84

Contents?: true

Size: 956 Bytes

Versions: 12

Compression:

Stored size: 956 Bytes

Contents

module ActiveRecord
  module Generators
    class BestBoyGenerator < Rails::Generators::Base
      include Rails::Generators::Migration
      source_root File.join(File.dirname(__FILE__), 'templates')

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

      def create_migration_file
        %w( create_best_boy_events_table.rb
            add_event_source_to_best_boy_events_table.rb
            create_best_boy_reports.rb
          ).each do |migration_file|
          destination = "db/migrate/#{migration_file.sub(%r\.rb$\, '')}"
          if not self.class.migration_exists?(File.dirname(destination), File.basename(destination))
            migration_template migration_file, destination
          end
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
best_boy-2.2.3 lib/generators/active_record/best_boy_generator.rb
best_boy-2.2.2 lib/generators/active_record/best_boy_generator.rb
best_boy-2.2.1 lib/generators/active_record/best_boy_generator.rb
best_boy-2.2.0 lib/generators/active_record/best_boy_generator.rb
best_boy-2.1.4 lib/generators/active_record/best_boy_generator.rb
best_boy-2.1.3 lib/generators/active_record/best_boy_generator.rb
best_boy-2.1.2 lib/generators/active_record/best_boy_generator.rb
best_boy-2.1.1 lib/generators/active_record/best_boy_generator.rb
best_boy-2.1.0 lib/generators/active_record/best_boy_generator.rb
best_boy-2.0.3 lib/generators/active_record/best_boy_generator.rb
best_boy-2.0.2 lib/generators/active_record/best_boy_generator.rb
best_boy-2.0.0 lib/generators/active_record/best_boy_generator.rb