Class: Longleaf::MetadataLocation
- Inherits:
-
Object
- Object
- Longleaf::MetadataLocation
- Defined in:
- lib/longleaf/models/metadata_location.rb
Overview
A location in which metadata associated with registered files is stored.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#digests ⇒ Object
readonly
Returns the value of attribute digests.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#contains?(md_path) ⇒ Boolean
True if the metadata path is contained by the path for this location.
-
#initialize(config) ⇒ MetadataLocation
constructor
A new instance of MetadataLocation.
-
#relative_file_path_for(md_path) ⇒ Object
Transforms the given metadata path into a relative storage location path.
Constructor Details
#initialize(config) ⇒ MetadataLocation
Returns a new instance of MetadataLocation.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/longleaf/models/metadata_location.rb', line 11 def initialize(config) raise ArgumentError.new("Config parameter is required") unless config @path = config[AF::LOCATION_PATH] raise ArgumentError.new("Parameter path is required") unless @path @path += '/' unless @path.end_with?('/') digests = config[AF::METADATA_DIGESTS] if digests.nil? @digests = [] elsif digests.is_a?(String) @digests = [digests.downcase] else @digests = digests.map(&:downcase) end DigestHelper::validate_algorithms(@digests) end |
Instance Attribute Details
#digests ⇒ Object (readonly)
Returns the value of attribute digests.
9 10 11 |
# File 'lib/longleaf/models/metadata_location.rb', line 9 def digests @digests end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/longleaf/models/metadata_location.rb', line 8 def path @path end |
Instance Method Details
#contains?(md_path) ⇒ Boolean
Returns true if the metadata path is contained by the path for this location.
43 44 45 |
# File 'lib/longleaf/models/metadata_location.rb', line 43 def contains?(md_path) md_path.start_with?(@path) end |
#relative_file_path_for(md_path) ⇒ Object
Transforms the given metadata path into a relative storage location path
31 32 33 34 35 36 37 38 39 |
# File 'lib/longleaf/models/metadata_location.rb', line 31 def relative_file_path_for(md_path) rel_md_path = relativize(md_path) if rel_md_path.end_with?(MetadataSerializer::) rel_md_path[0..-MetadataSerializer::.length - 1] else rel_md_path end end |