Class: Captivate::RemoteDir

Inherits:
Object
  • Object
show all
Defined in:
lib/captivate.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ RemoteDir

Returns a new instance of RemoteDir.



131
132
133
134
# File 'lib/captivate.rb', line 131

def initialize(options)
  @host, @path = options[:host], options[:path]
  SystemCall.new("ssh #{@host} mkdir #{@path}")
end

Instance Method Details

#new_subdir(dirname) ⇒ Object



145
146
147
# File 'lib/captivate.rb', line 145

def new_subdir(dirname)
  self.class.new(:host => @host, :path => "#{@path}/#{dirname}")
end

#upload(file_path, dest_filename = file_path) ⇒ Object

Raises:

  • (Errno::ENOENT)


136
137
138
139
140
141
142
143
# File 'lib/captivate.rb', line 136

def upload(file_path, dest_filename = file_path)
  raise(Errno::ENOENT, file_path) unless File.exists?(file_path)
  if File.directory?(file_path)
    SystemCall.new("scp -r #{file_path} #{@host}:#{@path}/#{File.basename(dest_filename)}")
  else
    SystemCall.new("scp #{file_path} #{@host}:#{@path}/#{File.basename(dest_filename)}")
  end
end