Class: DataPackage::Registry
- Inherits:
-
Object
- Object
- DataPackage::Registry
- 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.(File.dirname(__FILE__)), '..', '..', 'datapackage', 'schemas', 'registry.csv')
Instance Attribute Summary collapse
-
#base_path ⇒ Object
readonly
Returns the value of attribute base_path.
Instance Method Summary collapse
- #available_profiles ⇒ Object
- #get(profile_id) ⇒ Object
-
#initialize(registry_path_or_url = DEFAULT_REGISTRY_PATH) ⇒ Registry
constructor
A new instance of Registry.
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_path ⇒ Object (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_profiles ⇒ Object
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 |