Module: Pione::Location

Defined in:
lib/pione/location.rb,
lib/pione/location/ftp-location.rb,
lib/pione/location/local-scheme.rb,
lib/pione/location/myftp-scheme.rb,
lib/pione/location/data-location.rb,
lib/pione/location/http-location.rb,
lib/pione/location/basic-location.rb,
lib/pione/location/dropbox-scheme.rb,
lib/pione/location/https-location.rb,
lib/pione/location/local-location.rb,
lib/pione/location/location-scheme.rb,
lib/pione/location/broadcast-scheme.rb,
lib/pione/location/dropbox-location.rb,
lib/pione/location/location-exception.rb,
lib/pione/location/notification-scheme.rb,
lib/pione/location/git-repository-location.rb

Overview

Location is a name space for all location classes.

Defined Under Namespace

Classes: BasicLocation, BroadcastScheme, DataLocation, DropboxLocation, DropboxLocationUnavailable, DropboxScheme, ExistAlready, FTPLocation, GitError, GitRepositoryLocation, HTTPLocation, HTTPSLocation, InvalidFileOperation, LocalLocation, LocalScheme, LocationError, LocationScheme, MyFTPScheme, NotFound, NotLocal, NotificationBroadcastScheme, NotificationMulticastScheme, NotificationUnicastScheme

Constant Summary collapse

SCHEMES =

known schemes table

{}

Class Method Summary collapse

Class Method Details

.[](address) ⇒ BasicLocation

Return the location object corresponding to the address.

Parameters:

  • address (URI, String)

    URI or location address

Returns:



13
14
15
16
17
18
19
20
# 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

.LocationScheme(name, opts = {}) ⇒ Class

Returns a new scheme. Use this method for inheriting BasicScheme if you create new scheme.

Returns:

  • (Class)


24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# 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