Sha256: 8dca03405de80b4bcbcafd49de4c3e66a8716789a29775b7e37841f83335f3f2

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

require 'resync'
require_relative 'resource_client_delegate'

module Resync
  class Client
    module Mixins
      # A resource container whose resources are {ZippedResourceList}s
      module DumpIndex
        prepend ResourceClientDelegate

        # Downloads and parses each resource list and returns a flattened enumeration
        # of all zip packages in each contained list. Each contained list is only downloaded
        # as needed, and only downloaded once.
        # @return [Enumerator::Lazy<Resync::Client::Zip::ZipPackages>] the flattened enumeration of resources
        def all_zip_packages
          @zipped_resource_lists ||= {}
          resources.flat_map do |r|
            @zipped_resource_lists[r] ||= r.get_and_parse
            @zipped_resource_lists[r].respond_to?(:zip_packages) ? @zipped_resource_lists[r].zip_packages : []
          end
        end
      end
    end
  end

  class ChangeDumpIndex
    prepend Client::Mixins::DumpIndex
  end

  class ResourceDumpIndex
    prepend Client::Mixins::DumpIndex
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
resync-client-0.2.5 lib/resync/client/mixins/dump_index.rb
resync-client-0.2.4 lib/resync/client/mixins/dump_index.rb