Class: Rtprov::Sftp

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, user, password) ⇒ Sftp

Returns a new instance of Sftp.



8
9
10
11
12
# File 'lib/rtprov/sftp.rb', line 8

def initialize(host, user, password)
  @host = host.dup.freeze
  @user = user.dup.freeze
  @password = password.dup.freeze
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



6
7
8
# File 'lib/rtprov/sftp.rb', line 6

def host
  @host
end

#passwordObject (readonly)

Returns the value of attribute password.



6
7
8
# File 'lib/rtprov/sftp.rb', line 6

def password
  @password
end

#userObject (readonly)

Returns the value of attribute user.



6
7
8
# File 'lib/rtprov/sftp.rb', line 6

def user
  @user
end

Instance Method Details

#get(src) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/rtprov/sftp.rb', line 14

def get(src)
  Dir.mktmpdir do |dir|
    dest = File.join(dir, File.basename(src))
    run "get #{src} -o #{dest}"
    File.read(dest)
  end
end

#put(src, dest) ⇒ Object



22
23
24
# File 'lib/rtprov/sftp.rb', line 22

def put(src, dest)
  run "put #{src} -o #{dest}"
end