Class: Ecfr::VersionerService::XmlContent

Inherits:
Base show all
Defined in:
lib/ecfr/versioner_service/xml_content.rb

Overview

The XML endpoint will return the full XML available for a given date and hierarchy.

This is used primarily by our internal import processes and to provide links to XML from the web UI.

Constant Summary collapse

XML_PATH =
"v1/full"

Constants inherited from Base

Base::SUPPORTED_ARRAY_ACCESSORS

Instance Attribute Summary collapse

Attributes inherited from Base

#metadata, #request_data, #response_status, #results

Class Method Summary collapse

Methods inherited from Base

base_url, service_name, service_path

Methods inherited from Base

basic_auth_client_options, #each, #initialize, metadata, metadata_key, result_key

Methods included from Extensible

#inherited

Methods included from AttributeMethodDefinition

included, #initialize

Methods inherited from Client

build, cache_key, client, client_pool, delete, execute, get, handle_response, perform, post, purge

Methods included from ParallelClient

included

Constructor Details

This class inherits a constructor from Ecfr::Base

Instance Attribute Details

#xmlString (readonly)

XML document

Returns:

  • (String)


11
12
# File 'lib/ecfr/versioner_service/xml_content.rb', line 11

attribute :xml,
desc: "XML document"

Class Method Details

.find(date, title_number, options = {}) ⇒ <XML>

Retreive the XML for a given date and hierarchy

Parameters:

  • date (<Date, String, 'current'>)

    ISO string or ‘current’

  • title_number (<Integer, String>)

    the title of interest

  • options (<Hash>) (defaults to: {})

    a hash of hierarchy levels for the content desired - see attributes defined in Common::Hierarchy for acceptable keys

Options Hash (options):

  • build_id (<String>)

    internal use only - a specific build id

Returns:

  • (<XML>)

    XML for the full title or pared down to the requested hierarchy



26
27
28
29
30
31
32
33
34
35
# File 'lib/ecfr/versioner_service/xml_content.rb', line 26

def self.find(date, title_number, options = {})
  new(
    {
      xml: get(
        xml_content_path(date, title_number),
        options
      ).body
    }.stringify_keys
  )
end

.url_for(date, title_number, options = {}) ⇒ <String>

Provides a url to the XML content for a given set of parameters

Parameters:

  • date (<Date, String, 'current'>)

    ISO string or ‘current’

  • title_number (<Integer, String>)

    the title of interest

  • options (<Hash>) (defaults to: {})

    a hash of hierarchy levels for the content desired - see attributes defined in Ecfr:Common::Hierarchy for acceptable keys

Options Hash (options):

  • build_id (<String>)

    internal use only - a specific build id

Returns:

  • (<String>)

    URL to retreive XML content for the given parameters



47
48
49
50
51
# File 'lib/ecfr/versioner_service/xml_content.rb', line 47

def self.url_for(date, title_number, options = {})
  path = xml_content_path(date, title_number)

  client.build_url(path, options).to_s
end