Method: DataPackage::Resource.load
- Defined in:
- lib/datapackage/resource.rb
.load(resource, base_path = '') ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/datapackage/resource.rb', line 8 def self.load(resource, base_path = '') # This returns if there are no alternative ways to access the data OR there # is a base_path which is a URL if is_url?(resource, base_path) RemoteResource.new(resource, base_path) else # If there's a data attribute, we definitely want an inline resource if resource['data'] InlineResource.new(resource) else # If the file exists - we want a local resource if file_exists?(resource, base_path) LocalResource.new(resource, base_path) # If it doesn't exist and there's a URL to grab the data from, we want # a remote resource elsif resource['url'] RemoteResource.new(resource, base_path) end end end end |