Class: DataPackage::Registry
- Inherits:
-
Object
- Object
- DataPackage::Registry
- Includes:
- Helpers
- Defined in:
- lib/datapackage/registry.rb
Overview
Allow loading Data Package profiles from the official registry.
Constant Summary collapse
- DEFAULT_REGISTRY_URL =
'https://specs.frictionlessdata.io/schemas/registry.json'.freeze
- DEFAULT_REGISTRY_PATH =
File.join(File.(File.dirname(__FILE__)), '..', 'profiles', 'registry.json').freeze
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#profiles ⇒ Object
readonly
Returns the value of attribute profiles.
Instance Method Summary collapse
-
#initialize ⇒ Registry
constructor
A new instance of Registry.
Methods included from Helpers
#base_path, #dereference_descriptor, #is_fully_qualified_url?, #is_safe_path?, #join_paths, #load_json, #resolve_json_reference
Constructor Details
#initialize ⇒ Registry
Returns a new instance of Registry.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/datapackage/registry.rb', line 12 def initialize @path = DEFAULT_REGISTRY_PATH @profiles = get_registry(DEFAULT_REGISTRY_PATH) rescue Errno::ENOENT raise RegistryException.new 'Registry path is not valid' rescue OpenURI::HTTPError, SocketError => e raise RegistryException.new "Registry URL returned #{e.}" rescue JSON::ParserError raise RegistryException.new 'Registry descriptor is not valid JSON' rescue KeyError raise RegistryException.new 'Property `id` is mandatory for profiles' end |
Instance Attribute Details
#path ⇒ Object (readonly)
Returns the value of attribute path.
7 8 9 |
# File 'lib/datapackage/registry.rb', line 7 def path @path end |
#profiles ⇒ Object (readonly)
Returns the value of attribute profiles.
7 8 9 |
# File 'lib/datapackage/registry.rb', line 7 def profiles @profiles end |