Class: RemoteRun::Host::LockFile::RemoteFile
- Inherits:
-
Object
- Object
- RemoteRun::Host::LockFile::RemoteFile
- Defined in:
- lib/remote_run/host.rb
Instance Method Summary collapse
- #delete(file_path) ⇒ Object
- #exist?(file_path) ⇒ Boolean
-
#initialize(hostname, configuration) ⇒ RemoteFile
constructor
A new instance of RemoteFile.
- #read(file_path) ⇒ Object
- #run(command) ⇒ Object
- #run_and_test(command) ⇒ Object
- #write(file_path, text) ⇒ Object
Constructor Details
#initialize(hostname, configuration) ⇒ RemoteFile
Returns a new instance of RemoteFile.
96 97 98 99 |
# File 'lib/remote_run/host.rb', line 96 def initialize(hostname, configuration) @hostname = hostname @configuration = configuration end |
Instance Method Details
#delete(file_path) ⇒ Object
113 114 115 |
# File 'lib/remote_run/host.rb', line 113 def delete(file_path) run_and_test("rm -f #{file_path}") end |
#exist?(file_path) ⇒ Boolean
101 102 103 |
# File 'lib/remote_run/host.rb', line 101 def exist?(file_path) run_and_test("test -f #{file_path}") end |
#read(file_path) ⇒ Object
105 106 107 |
# File 'lib/remote_run/host.rb', line 105 def read(file_path) run("test -e #{file_path} && cat #{file_path}") end |
#run(command) ⇒ Object
117 118 119 |
# File 'lib/remote_run/host.rb', line 117 def run(command) `ssh #{@configuration.} #{$runner.login_as}@#{@hostname} '#{command};'`.strip end |
#run_and_test(command) ⇒ Object
121 122 123 |
# File 'lib/remote_run/host.rb', line 121 def run_and_test(command) system("ssh #{@configuration.} #{$runner.login_as}@#{@hostname} '#{command}' 2>/dev/null") end |
#write(file_path, text) ⇒ Object
109 110 111 |
# File 'lib/remote_run/host.rb', line 109 def write(file_path, text) run_and_test("test -e #{file_path} || echo #{text} > #{file_path}") end |