Class: Keyrack::Store::SSH
- Inherits:
-
Object
- Object
- Keyrack::Store::SSH
- Defined in:
- lib/keyrack/store/ssh.rb
Instance Method Summary collapse
-
#initialize(options) ⇒ SSH
constructor
A new instance of SSH.
- #read ⇒ Object
- #write(data) ⇒ Object
Constructor Details
#initialize(options) ⇒ SSH
Returns a new instance of SSH.
4 5 6 7 8 9 |
# File 'lib/keyrack/store/ssh.rb', line 4 def initialize() @host = ['host'] @user = ['user'] @path = ['path'] @port = ['port'] || 22 end |
Instance Method Details
#read ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/keyrack/store/ssh.rb', line 11 def read begin result = nil Net::SSH.start(@host, @user, :port => @port) do |ssh| result = ssh.scp.download!(@path) end result rescue Net::SCP::Error nil end end |
#write(data) ⇒ Object
23 24 25 26 27 |
# File 'lib/keyrack/store/ssh.rb', line 23 def write(data) Net::SSH.start(@host, @user, :port => @port) do |ssh| ssh.scp.upload!(StringIO.new(data), @path) end end |