Sha256: 6b3ac0dbbed70bc608d411e45dd828b3df53f0149a0c9cf6335c47b5d1924281

Contents?: true

Size: 812 Bytes

Versions: 28

Compression:

Stored size: 812 Bytes

Contents

# frozen_string_literal: true

module SdrClient
  module Deposit
    # This strategy is for building one file set per set of similarly prefixed uploaded files
    class MatchingFileGroupingStrategy
      # @param [Array<SdrClient::Deposit::Files::DirectUploadResponse>] uploads the uploaded files to attach.
      # @return [Array<Array<SdrClient::Deposit::Files::DirectUploadResponse>>] uploads the grouped uploaded files.
      def self.run(uploads: [])
        # Call `#values` on the result of the grouping operation because 1)
        # `Process#build_filesets` expects an array of arrays, not an array of
        # hashes, and 2) the keys aren't used anywhere
        uploads.group_by { |ul| ::File.join(::File.dirname(ul.filename), ::File.basename(ul.filename, '.*')) }.values
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
sdr-client-2.18.0 lib/sdr_client/deposit/matching_file_grouping_strategy.rb
sdr-client-2.17.0 lib/sdr_client/deposit/matching_file_grouping_strategy.rb
sdr-client-2.16.0 lib/sdr_client/deposit/matching_file_grouping_strategy.rb
sdr-client-2.13.2 lib/sdr_client/deposit/matching_file_grouping_strategy.rb
sdr-client-2.13.1 lib/sdr_client/deposit/matching_file_grouping_strategy.rb
sdr-client-2.13.0 lib/sdr_client/deposit/matching_file_grouping_strategy.rb
sdr-client-2.13.0.beta2 lib/sdr_client/deposit/matching_file_grouping_strategy.rb
sdr-client-2.13.0.beta1 lib/sdr_client/deposit/matching_file_grouping_strategy.rb
sdr-client-2.12.0 lib/sdr_client/deposit/matching_file_grouping_strategy.rb
sdr-client-2.11.1 lib/sdr_client/deposit/matching_file_grouping_strategy.rb
sdr-client-2.11.0 lib/sdr_client/deposit/matching_file_grouping_strategy.rb
sdr-client-2.10.1 lib/sdr_client/deposit/matching_file_grouping_strategy.rb
sdr-client-2.10.0 lib/sdr_client/deposit/matching_file_grouping_strategy.rb
sdr-client-2.9.0 lib/sdr_client/deposit/matching_file_grouping_strategy.rb
sdr-client-2.8.0 lib/sdr_client/deposit/matching_file_grouping_strategy.rb
sdr-client-2.7.1 lib/sdr_client/deposit/matching_file_grouping_strategy.rb
sdr-client-2.7.0 lib/sdr_client/deposit/matching_file_grouping_strategy.rb
sdr-client-2.6.0 lib/sdr_client/deposit/matching_file_grouping_strategy.rb
sdr-client-2.5.0 lib/sdr_client/deposit/matching_file_grouping_strategy.rb
sdr-client-2.4.0 lib/sdr_client/deposit/matching_file_grouping_strategy.rb