Class: OCFL::Inventory
- Inherits:
-
Object
- Object
- OCFL::Inventory
- Defined in:
- lib/ocfl/inventory.rb
Overview
Represents the JSON file that stores the object inventory ocfl.io/1.1/spec/#inventory
Defined Under Namespace
Classes: InventoryStruct
Constant Summary collapse
- URI_1_1 =
"https://ocfl.io/1.1/spec/#inventory"
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
- #content_directory ⇒ Object
- #head_version ⇒ Object
-
#initialize(data:) ⇒ Inventory
constructor
A new instance of Inventory.
-
#path(logical_path) ⇒ String?
The path to the file relative to the object root.
Constructor Details
#initialize(data:) ⇒ Inventory
Returns a new instance of Inventory.
22 23 24 |
# File 'lib/ocfl/inventory.rb', line 22 def initialize(data:) @data = data end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
26 27 28 |
# File 'lib/ocfl/inventory.rb', line 26 def data @data end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
26 27 28 |
# File 'lib/ocfl/inventory.rb', line 26 def errors @errors end |
Instance Method Details
#content_directory ⇒ Object
31 32 33 |
# File 'lib/ocfl/inventory.rb', line 31 def content_directory data.contentDirectory || "content" end |
#head_version ⇒ Object
46 47 48 |
# File 'lib/ocfl/inventory.rb', line 46 def head_version versions[head] end |
#path(logical_path) ⇒ String?
Returns the path to the file relative to the object root. (e.g. v2/content/image.tiff).
36 37 38 39 40 41 42 43 44 |
# File 'lib/ocfl/inventory.rb', line 36 def path(logical_path) return unless head_version # object does not exist on disk digest, = state.find { |_, logical_paths| logical_paths.include?(logical_path) } return unless digest manifest[digest].find { |content_path| content_path.match(%r{\Av\d+/#{content_directory}/#{logical_path}\z}) } end |