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
-
#child_or_parent_instrument_tables ⇒ String
The absolute path to a YAML-formatted document defining a hash with two keys:
child_instrument_tables
andparent_instrument_tables
. -
#child_or_parent_instrument_tables=(path) ⇒ String
Set the path to the child-or-parent instrument tables document.
-
#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
69 70 71 72 73 74 75 76 77 78 |
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 69 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.child_or_parent_instrument_tables = "#{version}/child_or_parent_instrument_tables.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 64 65 66 67 |
# 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') when '3.1' create('3.1', '3.1/NCS_Transmission_Schema_3.1.01.00.xsd', '3.1.01.00') when '3.2' create('3.2', '3.2/NCS_Transmission_Schema_3.2.00.00.xsd', '3.2.00.00') 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.
86 87 88 89 90 91 92 |
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 86 def xmlns { 'xs' => 'http://www.w3.org/2001/XMLSchema', 'ncs' => 'http://www.nationalchildrensstudy.gov', 'ncsdoc' => 'http://www.nationalchildrensstudy.gov/doc' } end |
Instance Method Details
#child_or_parent_instrument_tables ⇒ String
The absolute path to a YAML-formatted document defining a hash with two
keys: child_instrument_tables
and parent_instrument_tables
. The value
for each should be a list of MDES table names (lower case) which are in
that category.
This is path is optional; if one is not provided TransmissionTable#child_instrument_table? and TransmissionTable#parent_instrument_table? will be nil for all tables.
186 187 188 |
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 186 def child_or_parent_instrument_tables absolutize(@child_or_parent_instrument_tables) end |
#child_or_parent_instrument_tables=(path) ⇒ String
Set the path to the child-or-parent instrument tables document.
If the path is relative (i.e., it does not begin with /
), it
will be interpreted relative to #base.
197 198 199 |
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 197 def child_or_parent_instrument_tables=(path) @child_or_parent_instrument_tables = path end |
#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.
160 161 162 |
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 160 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.
171 172 173 |
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 171 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.
136 137 138 |
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 136 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.
147 148 149 |
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 147 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.
111 112 113 |
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 111 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.
122 123 124 |
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 122 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 |