Sha256: f7f633a660c912d3f928d1661a61d211fefbffe2b4f2c3956a285c2d318b4d36

Contents?: true

Size: 540 Bytes

Versions: 8

Compression:

Stored size: 540 Bytes

Contents

require 'yaml'

module Choria
  class Colt
    class Cache
      def initialize(path:, force_refresh: false)
        @path = path
        @data = YAML.safe_load File.read(@path)
        @clean = true unless force_refresh
      rescue Errno::ENOENT
        @clean = false
      end

      def dirty?
        !clean?
      end

      def clean?
        @clean
      end

      def load
        @data
      end

      def save(data)
        @data = data
        File.write @path, data.to_yaml
        @clean = true
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
choria-colt-0.6.0 lib/choria/colt/cache.rb
choria-colt-0.5.1 lib/choria/colt/cache.rb
choria-colt-0.5.0 lib/choria/colt/cache.rb
choria-colt-0.4.0 lib/choria/colt/cache.rb
choria-colt-0.3.0 lib/choria/colt/cache.rb
choria-colt-0.2.0 lib/choria/colt/cache.rb
choria-colt-0.1.1 lib/choria/colt/cache.rb
choria-colt-0.1.0 lib/choria/colt/cache.rb