Sha256: 578bf0b61d06e96c2b687c36453121568fbba0a67f7f7d8ff69a94b471d6a1b9

Contents?: true

Size: 843 Bytes

Versions: 3

Compression:

Stored size: 843 Bytes

Contents

module Picky

  module Backends

    class Memory

      # Memory-based index files dumped in the JSON format.
      #
      class JSON < Basic

        # Uses the extension "json".
        #
        def extension
          :json
        end

        # The initial content before loading.
        #
        def initial
          {}
        end

        # Loads the index hash from json format.
        #
        def load
          Yajl::Parser.parse ::File.open(cache_path, 'r'), symbolize_keys: true
        end

        # Dumps the index hash in json format.
        #
        def dump hash
          hash.dump_json cache_path
        end

        # A json file does not provide retrieve functionality.
        #
        def retrieve
          raise "Can't retrieve from JSON file. Use text file."
        end

      end

    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
picky-3.2.0 lib/picky/backends/memory/json.rb
picky-3.1.13 lib/picky/backends/memory/json.rb
picky-3.1.12 lib/picky/backends/memory/json.rb