module Pione::Location
Location
is a name space for all location classes.
Constants
- SCHEMES
known schemes table
Public Class Methods
LocationScheme(name, opts={})
click to toggle source
Returns a new scheme. Use this method for inheriting BasicScheme if you create new scheme.
@return [Class]
# File lib/pione/location/location-scheme.rb, line 24 def LocationScheme(name, opts={}) klass = Class.new(LocationScheme) def klass.inherited(scheme) name = self.instance_variable_get(:@scheme_name) URI.install_scheme(name.upcase, scheme) scheme.instance_variable_set(:@storage, @storage) end klass.instance_variable_set(:@scheme_name, name.upcase) storage_flag = opts[:storage] || false klass.instance_variable_set(:@storage, storage_flag) return klass end
[](address)
click to toggle source
Return the location object corresponding to the address.
@param address [URI,String]
URI or location address
@return [BasicLocation]
location object
# File lib/pione/location/basic-location.rb, line 13 def [](address) if address.kind_of?(Hash) return create_git_repository_location(address) if address[:git] return create_data_location(address[:data]) if address[:data] else return create_data_location(address) end end
Private Class Methods
create_data_location(address)
click to toggle source
Return the resource location.
# File lib/pione/location/basic-location.rb, line 25 def create_data_location(address) uri = URI.parse(address.to_s) uri = uri.scheme ? uri : URI.parse("local:%s" % Pathname.new(uri.path).expand_path) if location_class = SCHEMES[uri.scheme] location_class.new(uri) else raise ArgumentError.new(uri) end end
create_git_repository_location(address)
click to toggle source
Return the git repository location.
# File lib/pione/location/basic-location.rb, line 36 def create_git_repository_location(address) GitRepositoryLocation.new(address) end
Private Instance Methods
LocationScheme(name, opts={})
click to toggle source
Returns a new scheme. Use this method for inheriting BasicScheme if you create new scheme.
@return [Class]
# File lib/pione/location/location-scheme.rb, line 24 def LocationScheme(name, opts={}) klass = Class.new(LocationScheme) def klass.inherited(scheme) name = self.instance_variable_get(:@scheme_name) URI.install_scheme(name.upcase, scheme) scheme.instance_variable_set(:@storage, @storage) end klass.instance_variable_set(:@scheme_name, name.upcase) storage_flag = opts[:storage] || false klass.instance_variable_set(:@storage, storage_flag) return klass end