Sha256: d9ae16b52054a2231279a5a9c29fc37ab0f4c3276efcdef1832cbb14f6c0fad5

Contents?: true

Size: 793 Bytes

Versions: 3

Compression:

Stored size: 793 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 # TODO to_sym
        end

        # Dumps the index hash in json format.
        #
        def dump hash
          create_directory cache_path
          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.4.3 lib/picky/backends/memory/json.rb
picky-3.4.2 lib/picky/backends/memory/json.rb
picky-3.4.1 lib/picky/backends/memory/json.rb