Class: DataPackage::Registry

Inherits:
Object
  • Object
show all
Defined in:
lib/datapackage/registry.rb

Overview

Allow loading Data Package profiles from a registry.

Constant Summary collapse

DEFAULT_REGISTRY_URL =
'http://schemas.datapackages.org/registry.csv'
DEFAULT_REGISTRY_PATH =
File.join(File.expand_path(File.dirname(__FILE__)), '..', '..', 'datapackage', 'schemas', 'registry.csv')

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(registry_path_or_url = DEFAULT_REGISTRY_PATH) ⇒ Registry

Returns a new instance of Registry.



12
13
14
15
16
17
18
19
20
21
# File 'lib/datapackage/registry.rb', line 12

def initialize(registry_path_or_url = DEFAULT_REGISTRY_PATH)
  registry_path_or_url ||= DEFAULT_REGISTRY_PATH
  if File.file?(registry_path_or_url)
    @base_path = File.dirname(
      File.absolute_path(registry_path_or_url)
    )
  end
  @profiles = {}
  @registry = get_registry(registry_path_or_url)
end

Instance Attribute Details

#base_pathObject (readonly)

Returns the value of attribute base_path.



10
11
12
# File 'lib/datapackage/registry.rb', line 10

def base_path
  @base_path
end

Instance Method Details

#available_profilesObject



27
28
29
# File 'lib/datapackage/registry.rb', line 27

def available_profiles
  @registry
end

#get(profile_id) ⇒ Object



23
24
25
# File 'lib/datapackage/registry.rb', line 23

def get(profile_id)
  @profiles[profile_id] ||= get_profile(profile_id)
end