module Torba::RemoteSources::Common
Public Instance Methods
[](pattern)
click to toggle source
Expands pattern inside content of the remote source. @return [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.
@param pattern [String] see {www.rubydoc.info/stdlib/core/Dir#glob-class_method Dir.glob}
for pattern examples
@note Unlike Dir.glob doesn't include directories.
# File lib/torba/remote_sources/common.rb, line 10 def [](pattern) ensure_cached Dir.glob(File.join(cache_path, pattern)).sort.reject{ |path| File.directory?(path) }.map do |path| [File.absolute_path(path), path.sub(/#{cache_path}\/?/, "")] end end
digest()
click to toggle source
@return [String] unique short name used as a representation of the remote source.
Used by default as a cache folder name.
# File lib/torba/remote_sources/common.rb, line 20 def digest raise NotImplementedError end
Private Instance Methods
cache_path()
click to toggle source
# File lib/torba/remote_sources/common.rb, line 26 def cache_path @cache_path ||= File.join(Torba.cache_path, digest) end
ensure_cached()
click to toggle source
# File lib/torba/remote_sources/common.rb, line 30 def ensure_cached raise NotImplementedError end