Class: Merritt::Manifest
- Inherits:
-
Object
- Object
- Merritt::Manifest
- Defined in:
- lib/merritt/manifest.rb,
lib/merritt/manifest/file.rb,
lib/merritt/manifest/fields.rb,
lib/merritt/manifest/object.rb,
lib/merritt/manifest/data_one.rb,
lib/merritt/manifest/module_info.rb
Overview
A Merritt manifest file
Defined Under Namespace
Modules: Field, Fields, File Classes: DataONE, Object
Constant Summary collapse
- PROFILE_BASE_URI =
Base for all recognized profile URIs
'http://uc3.cdlib.org/registry/ingest/manifest/'.freeze
- CHECKM_0_7 =
Checkm 0.7 conformance level
'checkm_0.7'.freeze
- NAME =
The name of this gem
'merritt-manifest'.freeze
- VERSION =
The version of this gem
'0.1.1'.freeze
- COPYRIGHT =
The copyright notice for this gem
'Copyright (c) 2017 The Regents of the University of California'.freeze
Instance Attribute Summary collapse
-
#conformance ⇒ String
readonly
The conformance level.
-
#entries ⇒ Array<Hash<String, Object>>
readonly
The entries.
-
#fields ⇒ Array<String>
readonly
The field names, in the form prefix:fieldname.
-
#prefixes ⇒ Hash{Symbol => URI}
readonly
A map from namespace prefixes to their URIs.
-
#profile ⇒ URI
readonly
The profile URI.
Instance Method Summary collapse
-
#initialize(conformance: CHECKM_0_7, profile:, prefixes: {}, fields: [], entries: []) ⇒ Manifest
constructor
Creates a new manifest.
-
#write_to(io) ⇒ Object
Writes this manifest to the specified IO.
-
#write_to_string ⇒ String
Writes this manifest as a string.
Constructor Details
#initialize(conformance: CHECKM_0_7, profile:, prefixes: {}, fields: [], entries: []) ⇒ Manifest
Creates a new manifest. Note that the prefix, field, and entry arrays are copied on initialization, as are the individual entry hashes.
41 42 43 44 45 46 47 |
# File 'lib/merritt/manifest.rb', line 41 def initialize(conformance: CHECKM_0_7, profile:, prefixes: {}, fields: [], entries: []) @conformance = conformance @profile = normalize_profile_uri(profile).freeze @prefixes = normalize_prefixes(prefixes).freeze @fields = validate_fields(fields).freeze @entries = normalize_entries(entries).freeze end |
Instance Attribute Details
#conformance ⇒ String (readonly)
Returns the conformance level.
14 15 16 |
# File 'lib/merritt/manifest.rb', line 14 def conformance @conformance end |
#entries ⇒ Array<Hash<String, Object>> (readonly)
Returns the entries.
26 27 28 |
# File 'lib/merritt/manifest.rb', line 26 def entries @entries end |
#fields ⇒ Array<String> (readonly)
Returns the field names, in the form prefix:fieldname.
23 24 25 |
# File 'lib/merritt/manifest.rb', line 23 def fields @fields end |
#prefixes ⇒ Hash{Symbol => URI} (readonly)
Returns a map from namespace prefixes to their URIs.
20 21 22 |
# File 'lib/merritt/manifest.rb', line 20 def prefixes @prefixes end |
#profile ⇒ URI (readonly)
Returns the profile URI.
17 18 19 |
# File 'lib/merritt/manifest.rb', line 17 def profile @profile end |
Instance Method Details
#write_to(io) ⇒ Object
Writes this manifest to the specified IO
51 52 53 54 55 56 57 58 |
# File 'lib/merritt/manifest.rb', line 51 def write_to(io) write_sc(io, conformance) write_sc(io, 'profile', profile) prefixes.each { |prefix, url| write_sc(io, 'prefix', "#{prefix}:", url) } write_sc(io, 'fields', *fields) entries.each { |entry| io.puts(entry_line(entry)) } write_sc(io, 'eof') end |
#write_to_string ⇒ String
Writes this manifest as a string
62 63 64 65 66 |
# File 'lib/merritt/manifest.rb', line 62 def write_to_string io = StringIO.new write_to(io) io.string end |