Class: NcsNavigator::Mdes::SourceDocuments
- Inherits:
-
Object
- Object
- NcsNavigator::Mdes::SourceDocuments
- Extended by:
- Forwardable
- Defined in:
- lib/ncs_navigator/mdes/source_documents.rb
Overview
Implements the mechanism for determining where the MDES documents are stored on a particular system.
Constant Summary collapse
- BASE_ENV_VAR =
'NCS_MDES_DOCS_DIR'
Instance Attribute Summary collapse
-
#base ⇒ String
The base path for all paths that are not explicitly configured.
-
#specification_version ⇒ String
The specification version that these documents describe, if more specific than the overall version.
-
#version ⇒ String
The MDES version this set of documents describes.
Class Method Summary collapse
- .create(version, schema, specification_version = nil) ⇒ Object
-
.get(version) ⇒ SourceDocuments
Constructs an appropriate instance for the given version.
-
.xmlns ⇒ Hash<String, String>
A mapping of prefixes to XML namespaces for use with Nokogiri XPath.
Instance Method Summary collapse
-
#disposition_codes ⇒ String
The absolute path to a YAML-formatted document defining the disposition codes as found in the Master Data Element Specifications spreadsheet.
-
#disposition_codes=(path) ⇒ String
Set the path to the disposition codes document.
-
#heuristic_overrides ⇒ String
The absolute path to a YAML-formatted document defining overrides of heuristics this library uses to do mapping when there is insufficient computable information in the other source documents.
-
#heuristic_overrides=(path) ⇒ String
Set the path to the heuristics override document.
-
#schema ⇒ String
The absolute path to the XML Schema describing the MDES transmission structure for this instance.
-
#schema=(path) ⇒ String
Set the path to the MDES transmission structure XML Schema.
-
#xmlns ⇒ Hash
Instance-level alias for SourceDocuments.xmlns.
Instance Attribute Details
#base ⇒ String
The base path for all paths that are not explicitly
configured. It defaults to 'documents'
within this gem and may
be globally overridden by setting NCS_MDES_DOCS_DIR
in the
runtime environment.
There's probably no reason to change this in the current version of the gem.
24 25 26 |
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 24 def base @base end |
#specification_version ⇒ String
Returns The specification version that these documents describe, if more specific than the overall version.
35 36 37 |
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 35 def specification_version @specification_version end |
#version ⇒ String
The MDES version this set of documents describes.
30 31 32 |
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 30 def version @version end |
Class Method Details
.create(version, schema, specification_version = nil) ⇒ Object
65 66 67 68 69 70 71 72 73 |
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 65 def create(version, schema, specification_version=nil) self.new.tap do |sd| sd.version = version sd.schema = schema sd.heuristic_overrides = "#{version}/heuristic_overrides.yml" sd.disposition_codes = "#{version}/disposition_codes.yml" sd.specification_version = specification_version end end |
.get(version) ⇒ SourceDocuments
Constructs an appropriate instance for the given version.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 48 def get(version) case version when '1.2' create('1.2', '1.2/Data_Transmission_Schema_V1.2.xsd') when '2.0' create('2.0', '2.0/NCS_Transmission_Schema_2.0.01.02.xml', '2.0.01.02') when '2.1' create('2.1', '2.1/NCS_Transmission_Schema_2.1.00.00.xsd', '2.1.00.00') when '2.2' create('2.2', '2.2/NCS_Transmission_Schema_2.2.01.01.xsd', '2.2.01.01') when '3.0' create('3.0', '3.0/NCS_Transmission_Schema_3.0.00.09.xsd', '3.0.00.09') else raise "MDES #{version} is not supported by this version of ncs_mdes" end end |
.xmlns ⇒ Hash<String, String>
A mapping of prefixes to XML namespaces for use with Nokogiri XPath.
81 82 83 84 85 86 87 |
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 81 def xmlns { 'xs' => 'http://www.w3.org/2001/XMLSchema', 'ncs' => 'http://www.nationalchildrensstudy.gov', 'ncsdoc' => 'http://www.nationalchildrensstudy.gov/doc' } end |
Instance Method Details
#disposition_codes ⇒ String
The absolute path to a YAML-formatted document defining the disposition codes as found in the Master Data Element Specifications spreadsheet.
This is path is optional; if one is not provided no disposition codes will be loaded.
155 156 157 |
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 155 def disposition_codes absolutize(@disposition_codes) end |
#disposition_codes=(path) ⇒ String
Set the path to the disposition codes document.
If the path is relative (i.e., it does not begin with /
), it
will be interpreted relative to #base.
166 167 168 |
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 166 def disposition_codes=(path) @disposition_codes = path end |
#heuristic_overrides ⇒ String
The absolute path to a YAML-formatted document defining overrides of heuristics this library uses to do mapping when there is insufficient computable information in the other source documents.
This is path is optional; if one is not provided no overrides will be attempted.
131 132 133 |
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 131 def heuristic_overrides absolutize(@heuristic_overrides) end |
#heuristic_overrides=(path) ⇒ String
Set the path to the heuristics override document.
If the path is relative (i.e., it does not begin with /
), it
will be interpreted relative to #base.
142 143 144 |
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 142 def heuristic_overrides=(path) @heuristic_overrides = path end |
#schema ⇒ String
The absolute path to the XML Schema describing the MDES transmission structure for this instance.
106 107 108 |
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 106 def schema absolutize(@schema) end |
#schema=(path) ⇒ String
Set the path to the MDES transmission structure XML Schema.
If the path is relative (i.e., it does not begin with /
), it
will be interpreted relative to #base.
117 118 119 |
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 117 def schema=(path) @schema = path end |
#xmlns ⇒ Hash
Instance-level alias for xmlns.
41 |
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 41 def_delegator self, :xmlns |