Sha256: 9fcd5f4069f6d2cff7fae421090d49c0e6068e2cc44f3e986428cb177457323d

Contents?: true

Size: 658 Bytes

Versions: 5

Compression:

Stored size: 658 Bytes

Contents

module CrossStub
  module Stores
    class File < Base

      def initialize(file, truncate = true)
        @file = file
        super(truncate)
      end

      def current
        @file
      end

      def previous
        "#{@file}.stale"
      end

      private


        def exists?(file)
          ::File.exists?(file)
        end

        def dump(file, data)
          ::File.open(file,'w') {|f| Marshal.dump(data, f) } rescue nil
        end

        def load(file)
          ::File.open(file,'r') {|f| Marshal.load(f) } rescue {}
        end

        def delete(file)
          ::File.delete(file) if exists?(file)
        end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
cross-stub-0.2.4 lib/cross-stub/stores/file.rb
cross-stub-0.2.3 lib/cross-stub/stores/file.rb
cross-stub-0.2.2 lib/cross-stub/stores/file.rb
cross-stub-0.2.1 lib/cross-stub/stores/file.rb
cross-stub-0.2.0 lib/cross-stub/stores/file.rb