Class: SdrClient::Deposit::FileMetadataBuilder

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

Overview

Build basic metadata for files, iterating over a series of operations The available options are here: github.com/sul-dlss/sdr-client/blob/v0.8.1/lib/sdr_client/deposit/file.rb#L8-L10

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(files:, files_metadata:) ⇒ FileMetadataBuilder

Returns a new instance of FileMetadataBuilder.

Parameters:

  • files (Array<String>)

    the list of files for which to generate metadata



26
27
28
29
# File 'lib/sdr_client/deposit/file_metadata_builder.rb', line 26

def initialize(files:, files_metadata:)
  @files = files
  @files_metadata = 
end

Class Method Details

.build(files:, files_metadata:) ⇒ Hash<String, Hash<String, String>>

Parameters:

  • files (Array<String>)

    the list of files for which to generate metadata

Returns:

  • (Hash<String, Hash<String, String>>)


21
22
23
# File 'lib/sdr_client/deposit/file_metadata_builder.rb', line 21

def self.build(files:, files_metadata:)
  new(files: files, files_metadata: .dup).build
end

Instance Method Details

#buildHash<String, Hash<String, String>>

Returns:

  • (Hash<String, Hash<String, String>>)


32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/sdr_client/deposit/file_metadata_builder.rb', line 32

def build
  files.each do |file_path|
    file_key = ::File.basename(file_path)
    OPERATIONS.each do |operation|
      result = operation.for(file_path: file_path)
      next if result.nil?

      [file_key] ||= {}
      [file_key][operation::NAME] = result
    end
  end
  
end