module Rails::Generators::Migration::ClassMethods

def current_migration_number(dirname) #:nodoc:

:nodoc:
def current_migration_number(dirname) #:nodoc:
  migration_lookup_at(dirname).collect do |file|
    File.basename(file).split("_").first.to_i
  end.max.to_i
end

def migration_exists?(dirname, file_name) #:nodoc:

:nodoc:
def migration_exists?(dirname, file_name) #:nodoc:
  migration_lookup_at(dirname).grep(/\d+_#{file_name}.rb$/).first
end

def migration_lookup_at(dirname) #:nodoc:

:nodoc:
def migration_lookup_at(dirname) #:nodoc:
  Dir.glob("#{dirname}/[0-9]*_*.rb")
end

def next_migration_number(dirname) #:nodoc:

:nodoc:
def next_migration_number(dirname) #:nodoc:
  raise NotImplementedError
end