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:, basepath:) ⇒ FileMetadataBuilder

Returns a new instance of FileMetadataBuilder.

Parameters:

  • files (Array<String>)

    the list of relative filepaths for which to generate metadata



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

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

Class Method Details

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

Returns a map of relative filepaths to a map of metadata.

Parameters:

  • files (Array<String>)

    the list of relative filepaths for which to generate metadata

Returns:

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

    a map of relative filepaths to a map of metadata



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

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

Instance Method Details

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

Returns a map of relative filepaths to a map of metadata.

Returns:

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

    a map of relative filepaths to a map of metadata



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

def build
  files.each do |filepath|
    OPERATIONS.each do |operation|
      result = operation.for(filepath: absolute_filepath_for(filepath))
      next if result.nil?

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