Class: Ezid::Metadata Private
- Inherits:
-
Hashie::Mash
- Object
- Hashie::Mash
- Ezid::Metadata
- Defined in:
- lib/ezid/metadata.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
EZID metadata collection for an identifier.
Constant Summary collapse
- ANVL_SEPARATOR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
EZID metadata field/value separator
": "- ELEMENT_VALUE_SEPARATOR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
EZID metadata field value separator
" | "- ESCAPE_VALUES_RE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Characters to escape in element values on output to EZID
/[%\r\n]/- ESCAPE_NAMES_RE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Characters to escape in element names on output to EZID
/[%:\r\n]/- UNESCAPE_RE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Character sequence to unescape from EZID
/%\h\h/- COMMENT_RE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
A comment line
/^#.*(\r?\n)?/- LINE_CONTINUATION_RE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
A line continuation
/\r?\n\s+/- LINE_ENDING_RE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
A line ending
/\r?\n/- COOWNERS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
EZID reserved metadata elements
"_coowners".freeze
- CREATED =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"_created".freeze
- DATACENTER =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"_datacenter".freeze
- EXPORT =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"_export".freeze
- OWNER =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"_owner".freeze
- OWNERGROUP =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"_ownergroup".freeze
- PROFILE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"_profile".freeze
- SHADOWEDBY =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"_shadowedby".freeze
- SHADOWS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"_shadows".freeze
- STATUS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"_status".freeze
- TARGET =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"_target".freeze
- UPDATED =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
"_updated".freeze
- RESERVED =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
[ COOWNERS, CREATED, DATACENTER, EXPORT, OWNER, OWNERGROUP, PROFILE, SHADOWEDBY, SHADOWS, STATUS, TARGET, UPDATED ].freeze
- READONLY =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
[ CREATED, DATACENTER, OWNER, OWNERGROUP, SHADOWEDBY, SHADOWS, UPDATED ].freeze
Instance Method Summary collapse
- #created ⇒ Object private
- #elements ⇒ Object private
-
#initialize(data = nil, default = nil) ⇒ Metadata
constructor
private
A new instance of Metadata.
- #replace(data) ⇒ Object private
-
#to_anvl(include_readonly = true) ⇒ String
private
Output metadata in EZID ANVL format.
- #to_s ⇒ Object private
- #update(data) ⇒ Object private
- #updated ⇒ Object private
Constructor Details
#initialize(data = nil, default = nil) ⇒ Metadata
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Metadata.
61 62 63 64 65 66 67 |
# File 'lib/ezid/metadata.rb', line 61 def initialize(data=nil, default=nil) unless default.nil? raise ::NotImplementedError, "ezid-client does not support default metadata values." end super() update(data) if data end |
Instance Method Details
#created ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
75 76 77 |
# File 'lib/ezid/metadata.rb', line 75 def created to_time(_created) end |
#elements ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
69 70 71 72 73 |
# File 'lib/ezid/metadata.rb', line 69 def elements warn "[DEPRECATION] `Ezid::Metadata#elements` is deprecated and will be removed in ezid-client 2.0." \ " Use the `Ezid::Metadata` instance itself instead. (called from #{caller.first})" self end |
#replace(data) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
87 88 89 |
# File 'lib/ezid/metadata.rb', line 87 def replace(data) super coerce(data) end |
#to_anvl(include_readonly = true) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Output metadata in EZID ANVL format
94 95 96 97 98 99 100 101 102 |
# File 'lib/ezid/metadata.rb', line 94 def to_anvl(include_readonly = true) hsh = to_h hsh.reject! { |k, v| READONLY.include?(k) } unless include_readonly lines = hsh.map do |name, value| element = [escape(ESCAPE_NAMES_RE, name), escape(ESCAPE_VALUES_RE, value)] element.join(ANVL_SEPARATOR) end lines.join("\n").force_encoding(Encoding::UTF_8) end |
#to_s ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
104 105 106 |
# File 'lib/ezid/metadata.rb', line 104 def to_s to_anvl end |
#update(data) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
83 84 85 |
# File 'lib/ezid/metadata.rb', line 83 def update(data) super coerce(data) end |
#updated ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
79 80 81 |
# File 'lib/ezid/metadata.rb', line 79 def updated to_time(_updated) end |