class Mongration::File

@private

Attributes

file_name[R]

Public Class Methods

all() click to toggle source
# File lib/mongration/file.rb, line 28
def self.all
  pending + migrated
end
all_file_names() click to toggle source
# File lib/mongration/file.rb, line 10
def self.all_file_names
  Dir[::File.join(Mongration.configuration.dir, '*.rb')].map do |path|
    path.pathmap('%f')
  end
end
last() click to toggle source
# File lib/mongration/file.rb, line 32
def self.last
  all.max
end
migrated() click to toggle source
# File lib/mongration/file.rb, line 20
def self.migrated
  wrap(migrated_file_names).sort
end
migrated_file_names() click to toggle source
# File lib/mongration/file.rb, line 24
def self.migrated_file_names
  Migration.file_names
end
new(file_name) click to toggle source
# File lib/mongration/file.rb, line 42
def initialize(file_name)
  @file_name = file_name
end
pending() click to toggle source
# File lib/mongration/file.rb, line 16
def self.pending
  wrap(all_file_names - migrated_file_names).sort
end
wrap(file_names) click to toggle source
# File lib/mongration/file.rb, line 36
def self.wrap(file_names)
  file_names.map { |file_name| new(file_name) }
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/mongration/file.rb, line 62
def <=>(other)
  number <=> other.number
end
_load()
Alias for: load
class_name() click to toggle source
# File lib/mongration/file.rb, line 50
def class_name
  underscored_name.camelize
end
klass() click to toggle source
# File lib/mongration/file.rb, line 71
def klass
  class_name.constantize
end
load() click to toggle source
# File lib/mongration/file.rb, line 67
def load
  _load(::File.join(Mongration.configuration.dir, @file_name))
end
Also aliased as: _load
name() click to toggle source
# File lib/mongration/file.rb, line 46
def name
  underscored_name.gsub('_', ' ')
end
number() click to toggle source
# File lib/mongration/file.rb, line 58
def number
  version.to_i
end
version() click to toggle source
# File lib/mongration/file.rb, line 54
def version
  file_name.split('_').first
end

Private Instance Methods

underscored_name() click to toggle source
# File lib/mongration/file.rb, line 77
def underscored_name
  @file_name.chomp('.rb').gsub(/^\d+_/, '')
end