Sha256: 08193bb3d775b6c5c2cdc81ff8462573defec0d920a6ef45d9e3a34e7c341f28

Contents?: true

Size: 762 Bytes

Versions: 1

Compression:

Stored size: 762 Bytes

Contents

module Splash
  module Backends
    class File
      include Splash::Config
      def initialize(store)
        @config = get_config[:backends][:stores][store]
        @path = @config[:path]
      end

      def list(pattern='*')
         return Dir.glob(pattern)
      end

      def get(options)
        return ::File.readlines("#{@path}/#{options[:key]}").join
      end

      def put(options)
        ::File.open("#{@path}/#{options[:key]}", 'w') { |file|
          file.write options[:value]
        }
      end

      def del(options)
        ::File.unlink("#{@path}/#{options[:key]}") if File.exist?("#{@path}/#{options[:key]}")
      end

      def exist?(options)
        return ::File.exist?("#{@path}/#{options[:key]}")
      end

    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
prometheus-splash-0.0.3 lib/splash/backends/file.rb