Class: SdrClient::RedesignedClient::MatchingFileGroupingStrategy

Inherits:
Object
  • Object
show all
Defined in:
lib/sdr_client/redesigned_client/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::RedesignedClient::DirectUploadResponse>>

Returns uploads the grouped uploaded files.

Parameters:

Returns:



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

def self.run(uploads: [])
  # Call `#values` on the result of the grouping operation because:
  #   1) `StructuralGrouper#build_filesets` expects an array of arrays (not hashes); and
  #   2) the keys aren't used anywhere
  uploads.group_by do |ul|
    ::File.join(::File.dirname(ul.filename), ::File.basename(ul.filename, '.*'))
  end.values
end