Class: SdrClient::Deposit::FileMetadataBuilder
- Inherits:
-
Object
- Object
- SdrClient::Deposit::FileMetadataBuilder
- 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
- #build ⇒ Hash<String, Hash<String, String>>
-
#initialize(files:, files_metadata:) ⇒ FileMetadataBuilder
constructor
A new instance of FileMetadataBuilder.
Constructor Details
#initialize(files:, files_metadata:) ⇒ FileMetadataBuilder
Returns a new instance of FileMetadataBuilder.
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>>
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
#build ⇒ 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 |