Sha256: 41e96dcfcff2ea09fd34cd6e814a008c0715f2fcc935e53f1732afd3b594760e

Contents?: true

Size: 1.01 KB

Versions: 2

Compression:

Stored size: 1.01 KB

Contents

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

module Import
  module Generators
    class InstallGenerator < Rails::Generators::Base
      include Rails::Generators::Migration
    
      def self.source_root
        File.join(File.dirname(__FILE__), 'templates')
      end
    
       # Implement the required interface for Rails::Generators::Migration.
       # taken from http://github.com/rails/rails/blob/master/activerecord/lib/generators/active_record.rb
      def self.next_migration_number(dirname) #:nodoc:
        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_migrations
        Dir["#{self.class.source_root}/migrations/*.rb"].sort.each do |filepath|
          name = File.basename(filepath)
          migration_template "migrations/#{name}", "db/migrate/#{name.gsub(/^\d+_/,'')}"
          sleep 1
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
import-0.0.3 lib/generators/import/install/install_generator.rb
import-0.0.2 lib/generators/import/install/install_generator.rb