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



22
23
24
25
26
# File 'lib/sdr_client/deposit/file_metadata_builder.rb', line 22

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



17
18
19
# File 'lib/sdr_client/deposit/file_metadata_builder.rb', line 17

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



29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/sdr_client/deposit/file_metadata_builder.rb', line 29

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