Module: PEBuild::Transfer

Defined in:
lib/pe_build/transfer.rb

Defined Under Namespace

Modules: File, OpenURI Classes: UnhandledURIScheme

Constant Summary collapse

IMPLEMENTATIONS =
{
  'http'  => PEBuild::Transfer::OpenURI,
  'https' => PEBuild::Transfer::OpenURI,
  'ftp'   => PEBuild::Transfer::OpenURI,
  'file'  => PEBuild::Transfer::File,
  nil     => PEBuild::Transfer::File, # Assume that URIs without a scheme are files
}

Class Method Summary collapse

Class Method Details

.copy(src, dst) ⇒ Object

Parameters:

  • src (URI)

    The local file path path to the file to copy

  • dst (String)

    The path to destination of the copied file



21
22
23
24
25
26
27
28
29
30
# File 'lib/pe_build/transfer.rb', line 21

def self.copy(src, dst)
  scheme = src.scheme

  if (mod = IMPLEMENTATIONS[scheme])
    mod.copy(src, dst)
  else
    raise UnhandledURIScheme, :scheme => scheme,
                              :supported => IMPLEMENTATIONS.keys
  end
end

.read(src) ⇒ String

Return the contents of a local or remote file.

Parameters:

  • src (URI)

    The URI of the source file.

Returns:

  • (String)

    The contents of the source file.

Raises:

Since:

  • 0.9.0



39
40
41
42
43
44
45
46
47
48
# File 'lib/pe_build/transfer.rb', line 39

def self.read(src)
  scheme = src.scheme

  if (mod = IMPLEMENTATIONS[scheme])
    mod.read(src)
  else
    raise UnhandledURIScheme, :scheme => scheme,
                              :supported => IMPLEMENTATIONS.keys
  end
end