Class: SdrClient::Deposit::MatchingFileGroupingStrategy

Inherits:
Object
  • Object
show all
Defined in:
lib/sdr_client/deposit/matching_file_grouping_strategy.rb

Overview

This strategy is for building one file set per set of similarly prefixed uploaded files

Class Method Summary collapse

Class Method Details

.run(uploads: []) ⇒ Array<Array<SdrClient::Deposit::Files::DirectUploadResponse>>

Returns uploads the grouped uploaded files.

Parameters:

Returns:



9
10
11
12
13
14
# File 'lib/sdr_client/deposit/matching_file_grouping_strategy.rb', line 9

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.basename(ul.filename, '.*') }.values
end