Module: Torba::RemoteSources::Common

Included in:
Targz, Zip
Defined in:
lib/torba/remote_sources/common.rb

Overview

Since:

  • 0.1.0

Instance Method Summary collapse

Instance Method Details

#[](pattern) ⇒ Array<Array(String, String)>

Note:

Unlike Dir.glob doesn’t include directories.

Expands pattern inside content of the remote source.

Parameters:

  • pattern (String)

    see Dir.glob for pattern examples

Returns:

  • (Array<Array(String, String)>)

    where first element of the tuple is an absolute path to cached file and second element is the same path relative to cache directory.

Since:

  • 0.1.0



10
11
12
13
14
15
16
# File 'lib/torba/remote_sources/common.rb', line 10

def [](pattern)
  ensure_cached

  Dir.glob(File.join(cache_path, pattern)).reject{ |path| File.directory?(path) }.map do |path|
    [File.absolute_path(path), path.sub(/#{cache_path}\/?/, "")]
  end
end

#digestString

Returns unique short name used as a representation of the remote source. Used by default as a cache folder name.

Returns:

  • (String)

    unique short name used as a representation of the remote source. Used by default as a cache folder name.

Raises:

  • (NotImplementedError)

Since:

  • 0.1.0



20
21
22
# File 'lib/torba/remote_sources/common.rb', line 20

def digest
  raise NotImplementedError
end