class CouchMigrate::FilePersistedList

Public Class Methods

new(meta_file_directory="db/migrate") click to toggle source
Calls superclass method CouchMigrate::BasePersistedList::new
# File lib/couch_migrate/file_persisted_list.rb, line 6
def initialize(meta_file_directory="db/migrate")
  super()
  path = Pathname.new(meta_file_directory)
  path.mkpath
  @path = path+"meta.yml"
  read
  self
end

Protected Instance Methods

cleanup() click to toggle source
# File lib/couch_migrate/file_persisted_list.rb, line 28
def cleanup
  File.delete(@path.to_s) rescue nil
  # @path.delete rescue nil # fakefs does not handle this correctly
end
read() click to toggle source
# File lib/couch_migrate/file_persisted_list.rb, line 17
def read
  @data = YAML.load(File.read(@path)) rescue {}
  @data[:complete] ||= []
  @list = @data[:complete]
end
write() click to toggle source
# File lib/couch_migrate/file_persisted_list.rb, line 23
def write
  @data[:complete] = @list
  File.open(@path,"w"){|f| f<< YAML.dump(@data) }
end