Class: Downloads::Servers::Remote

Inherits:
Base
  • Object
show all
Defined in:
lib/downloads/servers/remote.rb

Instance Method Summary collapse

Methods inherited from Base

#exists?, #filenames

Constructor Details

#initialize(host, directory, cache_path) ⇒ Remote

Returns a new instance of Remote.



6
7
8
9
10
11
12
# File 'lib/downloads/servers/remote.rb', line 6

def initialize(host, directory, cache_path)
  @host       = host
  @directory  = directory
  @cache_path = cache_path
  @connection = nil
  @files      = File.exists?(@cache_path) ? YAML.load_file(@cache_path) : nil
end

Instance Method Details

#filesObject



14
15
16
17
# File 'lib/downloads/servers/remote.rb', line 14

def files
  populate_file_cache unless @files
  @files
end

#rsync_pathObject



19
20
21
# File 'lib/downloads/servers/remote.rb', line 19

def rsync_path
  "#{@host}:#{@directory}/"
end

#run(command) ⇒ Object



23
24
25
26
27
# File 'lib/downloads/servers/remote.rb', line 23

def run(command)
  result = run_in_directory(command)
  populate_file_cache
  result
end