Sha256: b97ab4d2260a129d4949f8e08c2d8bf9be31c9f810c869b6f2103e15173da3b9

Contents?: true

Size: 599 Bytes

Versions: 4

Compression:

Stored size: 599 Bytes

Contents

require 'pathname'
require 'yaml'

module CouchMigrate
  class FilePersistedList < BasePersistedList
    def initialize(directory="db/migrate")
      super()
      path = Pathname.new(directory)
      path.mkpath
      @path = path+"meta.yml"
      read
      self
    end

    protected

    def read
      @data = YAML.load(File.read(@path)) rescue {}
      @data[:complete] ||= []
      @list = @data[:complete]
    end

    def write
      @data[:complete] = @list
      File.open(@path,"w"){|f| f<< YAML.dump(@data) }
    end

    def cleanup
      @path.delete rescue nil
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
couch-migrate-1.1.2 lib/couch_migrate/file_persisted_list.rb
couch-migrate-1.1.1 lib/couch_migrate/file_persisted_list.rb
couch-migrate-1.1.0 lib/couch_migrate/file_persisted_list.rb
couch-migrate-1.0.0 lib/couch_migrate/file_persisted_list.rb