Class: SdrClient::Deposit::UploadFilesMetadataBuilder
- Inherits:
-
Object
- Object
- SdrClient::Deposit::UploadFilesMetadataBuilder
- Defined in:
- lib/sdr_client/deposit/upload_files_metadata_builder.rb
Overview
Collecting all the metadata about the files for a deposit
Instance Attribute Summary collapse
-
#basepath ⇒ Object
readonly
Returns the value of attribute basepath.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#mime_types ⇒ Object
readonly
Returns the value of attribute mime_types.
Class Method Summary collapse
-
.build(files:, mime_types:, basepath:) ⇒ Hash<String, Files::DirectUploadRequest>
The metadata for uploading the files.
Instance Method Summary collapse
- #absolute_filepath_for(filepath) ⇒ Object
-
#build ⇒ Hash<String, Files::DirectUploadRequest>
The metadata for uploading the files.
-
#initialize(files:, mime_types:, basepath:) ⇒ UploadFilesMetadataBuilder
constructor
A new instance of UploadFilesMetadataBuilder.
Constructor Details
#initialize(files:, mime_types:, basepath:) ⇒ UploadFilesMetadataBuilder
Returns a new instance of UploadFilesMetadataBuilder.
18 19 20 21 22 |
# File 'lib/sdr_client/deposit/upload_files_metadata_builder.rb', line 18 def initialize(files:, mime_types:, basepath:) @files = files @mime_types = mime_types @basepath = basepath end |
Instance Attribute Details
#basepath ⇒ Object (readonly)
Returns the value of attribute basepath.
24 25 26 |
# File 'lib/sdr_client/deposit/upload_files_metadata_builder.rb', line 24 def basepath @basepath end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
24 25 26 |
# File 'lib/sdr_client/deposit/upload_files_metadata_builder.rb', line 24 def files @files end |
#mime_types ⇒ Object (readonly)
Returns the value of attribute mime_types.
24 25 26 |
# File 'lib/sdr_client/deposit/upload_files_metadata_builder.rb', line 24 def mime_types @mime_types end |
Class Method Details
.build(files:, mime_types:, basepath:) ⇒ Hash<String, Files::DirectUploadRequest>
Returns the metadata for uploading the files.
11 12 13 |
# File 'lib/sdr_client/deposit/upload_files_metadata_builder.rb', line 11 def self.build(files:, mime_types:, basepath:) new(files: files, mime_types: mime_types, basepath: basepath).build end |
Instance Method Details
#absolute_filepath_for(filepath) ⇒ Object
35 36 37 |
# File 'lib/sdr_client/deposit/upload_files_metadata_builder.rb', line 35 def absolute_filepath_for(filepath) ::File.join(basepath, filepath) end |
#build ⇒ Hash<String, Files::DirectUploadRequest>
Returns the metadata for uploading the files.
27 28 29 30 31 32 33 |
# File 'lib/sdr_client/deposit/upload_files_metadata_builder.rb', line 27 def build files.each_with_object({}) do |filepath, obj| obj[filepath] = Files::DirectUploadRequest.from_file(absolute_filepath_for(filepath), file_name: filepath, content_type: mime_types[filepath]) end end |