Class: NcsNavigator::Mdes::SourceDocuments

Inherits:
Object
  • Object
show all
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

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#baseString

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.

Returns:

  • (String)


24
25
26
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 24

def base
  @base
end

#specification_versionString

Returns The specification version that these documents describe, if more specific than the overall version.

Returns:

  • (String)

    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

#versionString

The MDES version this set of documents describes.

Returns:

  • (String)


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



71
72
73
74
75
76
77
78
79
80
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 71

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.

Returns:



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# 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')
  when '3.3'
    create('3.3', '3.3/NCS_Transmission_Schema_3.3.00.00.xsd', '3.3.00.00')
  else
    raise "MDES #{version} is not supported by this version of ncs_mdes"
  end
end

.xmlnsHash<String, String>

A mapping of prefixes to XML namespaces for use with Nokogiri XPath.

Returns:

  • (Hash<String, String>)


88
89
90
91
92
93
94
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 88

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_tablesString

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.

Returns:

  • (String)


188
189
190
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 188

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.

Parameters:

  • path (String)

Returns:

  • (String)

    the provided path



199
200
201
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 199

def child_or_parent_instrument_tables=(path)
  @child_or_parent_instrument_tables = path
end

#disposition_codesString

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.

Returns:

  • (String)


162
163
164
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 162

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.

Parameters:

  • path (String)

Returns:

  • (String)

    the provided path



173
174
175
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 173

def disposition_codes=(path)
  @disposition_codes = path
end

#heuristic_overridesString

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.

Returns:

  • (String)


138
139
140
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 138

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.

Parameters:

  • path (String)

Returns:

  • (String)

    the provided path



149
150
151
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 149

def heuristic_overrides=(path)
  @heuristic_overrides = path
end

#schemaString

The absolute path to the XML Schema describing the MDES transmission structure for this instance.

Returns:

  • (String)


113
114
115
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 113

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.

Parameters:

  • path (String)

Returns:

  • (String)

    the provided path



124
125
126
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 124

def schema=(path)
  @schema = path
end

#xmlnsHash

Instance-level alias for xmlns.

Returns:

  • (Hash)


41
# File 'lib/ncs_navigator/mdes/source_documents.rb', line 41

def_delegator self, :xmlns