Sha256: 7fe4a33e973d5a2775940b0e32c933903b0f9e9d51c1cfca15850e30de4caf69

Contents?: true

Size: 741 Bytes

Versions: 9

Compression:

Stored size: 741 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

        # 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

9 entries across 9 versions & 1 rubygems

Version Path
picky-3.1.9 lib/picky/backends/memory/json.rb
picky-3.1.8 lib/picky/backends/memory/json.rb
picky-3.1.7 lib/picky/backends/memory/json.rb
picky-3.1.6 lib/picky/backends/memory/json.rb
picky-3.1.5 lib/picky/backends/memory/json.rb
picky-3.1.4 lib/picky/backends/memory/json.rb
picky-3.1.3 lib/picky/backends/memory/json.rb
picky-3.1.2 lib/picky/backends/memory/json.rb
picky-3.1.1 lib/picky/backends/memory/json.rb