Class: DataPackage::Registry

Inherits:
Object
  • Object
show all
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.expand_path(File.dirname(__FILE__)), '..', 'profiles', 'registry.json').freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#base_path, #dereference_descriptor, #is_fully_qualified_url?, #is_safe_path?, #join_paths, #load_json, #resolve_json_reference

Constructor Details

#initializeRegistry

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.message}"
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

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/datapackage/registry.rb', line 7

def path
  @path
end

#profilesObject (readonly)

Returns the value of attribute profiles.



7
8
9
# File 'lib/datapackage/registry.rb', line 7

def profiles
  @profiles
end