Class: ThorSsh::LocalFile
- Inherits:
-
Object
- Object
- ThorSsh::LocalFile
- Defined in:
- lib/thor-ssh/local_file.rb
Instance Attribute Summary collapse
-
#base ⇒ Object
readonly
Returns the value of attribute base.
Instance Method Summary collapse
- #binread(path) ⇒ Object
-
#binwrite(path, data) ⇒ Object
TODO: we should just move this to a more standard thing.
- #chmod(mode, file_name) ⇒ Object
- #exists?(path) ⇒ Boolean
-
#identical?(file1, file2) ⇒ Boolean
See if these paths point to the same inode.
-
#initialize(base) ⇒ LocalFile
constructor
A new instance of LocalFile.
- #link(old_name, new_name) ⇒ Object
-
#mkdir_p(path) ⇒ Object
Creates the directory at the path on the remote server.
-
#rm_rf(path) ⇒ Object
(also: #unlink)
Remote the file/folder on the remote server.
- #run(command) ⇒ Object
- #symlink(old_name, new_name) ⇒ Object
Constructor Details
#initialize(base) ⇒ LocalFile
Returns a new instance of LocalFile.
7 8 9 |
# File 'lib/thor-ssh/local_file.rb', line 7 def initialize(base) @base = base end |
Instance Attribute Details
#base ⇒ Object (readonly)
Returns the value of attribute base.
5 6 7 |
# File 'lib/thor-ssh/local_file.rb', line 5 def base @base end |
Instance Method Details
#binread(path) ⇒ Object
38 39 40 41 42 43 44 45 |
# File 'lib/thor-ssh/local_file.rb', line 38 def binread(path) data = nil File.open(path, "rb") do |f| data = f.read end return data end |
#binwrite(path, data) ⇒ Object
TODO: we should just move this to a more standard thing
48 49 50 51 52 |
# File 'lib/thor-ssh/local_file.rb', line 48 def binwrite(path, data) File.open(path, 'wb') do |file| file.write(data) end end |
#chmod(mode, file_name) ⇒ Object
54 55 56 |
# File 'lib/thor-ssh/local_file.rb', line 54 def chmod(mode, file_name) File.chmod(mode, file_name) end |
#exists?(path) ⇒ Boolean
11 12 13 |
# File 'lib/thor-ssh/local_file.rb', line 11 def exists?(path) File.exists?(path) end |
#identical?(file1, file2) ⇒ Boolean
See if these paths point to the same inode
59 60 61 |
# File 'lib/thor-ssh/local_file.rb', line 59 def identical?(file1, file2) File.identical?(file1, file2) end |
#link(old_name, new_name) ⇒ Object
34 35 36 |
# File 'lib/thor-ssh/local_file.rb', line 34 def link(old_name, new_name) File.link(old_name, new_name) end |
#mkdir_p(path) ⇒ Object
Creates the directory at the path on the remote server
20 21 22 |
# File 'lib/thor-ssh/local_file.rb', line 20 def mkdir_p(path) FileUtils.mkdir_p(path) end |
#rm_rf(path) ⇒ Object Also known as: unlink
Remote the file/folder on the remote server
25 26 27 |
# File 'lib/thor-ssh/local_file.rb', line 25 def rm_rf(path) FileUtils.rm_rf(path) end |
#run(command) ⇒ Object
15 16 17 |
# File 'lib/thor-ssh/local_file.rb', line 15 def run(command) return system(command) end |
#symlink(old_name, new_name) ⇒ Object
30 31 32 |
# File 'lib/thor-ssh/local_file.rb', line 30 def symlink(old_name, new_name) File.symlink(old_name, new_name) end |