Class: Conjure::Service::RemoteFileSet

Inherits:
Object
  • Object
show all
Defined in:
lib/conjure/service/remote_file_set.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ RemoteFileSet

Returns a new instance of RemoteFileSet.



6
7
8
9
# File 'lib/conjure/service/remote_file_set.rb', line 6

def initialize(options)
  @shell = options[:shell]
  @files = options[:files].to_a
end

Instance Method Details

#removeObject



19
20
21
# File 'lib/conjure/service/remote_file_set.rb', line 19

def remove
  @files.each{|local_path, remote_path| @shell.run "rm -f #{remote_path}"}
end

#uploadObject



11
12
13
14
15
16
17
# File 'lib/conjure/service/remote_file_set.rb', line 11

def upload
  dir_names = @files.map{|local_path, remote_path| File.dirname remote_path}.uniq
  @shell.run "mkdir -p #{dir_names.join ' '}" if dir_names.any?
  @files.each do |local_path, remote_path|
    @shell.session.scp.upload! local_path, remote_path
  end
end