Class: Producer::Core::Remote::FS
- Inherits:
-
Object
- Object
- Producer::Core::Remote::FS
- Defined in:
- lib/producer/core/remote/fs.rb
Instance Attribute Summary collapse
-
#sftp ⇒ Object
readonly
Returns the value of attribute sftp.
Instance Method Summary collapse
- #chmod(path, mode) ⇒ Object
- #dir?(path) ⇒ Boolean
- #file?(path) ⇒ Boolean
- #file_read(path) ⇒ Object
- #file_write(path, content) ⇒ Object
-
#initialize(sftp) ⇒ FS
constructor
A new instance of FS.
- #mkdir(path, attributes = {}) ⇒ Object
- #setstat(path, attributes) ⇒ Object
Constructor Details
#initialize(sftp) ⇒ FS
Returns a new instance of FS.
7 8 9 |
# File 'lib/producer/core/remote/fs.rb', line 7 def initialize sftp @sftp = sftp end |
Instance Attribute Details
#sftp ⇒ Object (readonly)
Returns the value of attribute sftp.
5 6 7 |
# File 'lib/producer/core/remote/fs.rb', line 5 def sftp @sftp end |
Instance Method Details
#chmod(path, mode) ⇒ Object
27 28 29 |
# File 'lib/producer/core/remote/fs.rb', line 27 def chmod path, mode setstat path, permissions: mode end |
#dir?(path) ⇒ Boolean
11 12 13 14 15 |
# File 'lib/producer/core/remote/fs.rb', line 11 def dir? path sftp.stat!(path).directory? rescue Net::SFTP::StatusException false end |
#file?(path) ⇒ Boolean
17 18 19 20 21 |
# File 'lib/producer/core/remote/fs.rb', line 17 def file? path sftp.stat!(path).file? rescue Net::SFTP::StatusException false end |
#file_read(path) ⇒ Object
35 36 37 38 39 |
# File 'lib/producer/core/remote/fs.rb', line 35 def file_read path sftp.file.open path, &:read rescue Net::SFTP::StatusException nil end |
#file_write(path, content) ⇒ Object
41 42 43 44 45 |
# File 'lib/producer/core/remote/fs.rb', line 41 def file_write path, content sftp.file.open path, 'w' do |f| f.write content end end |
#mkdir(path, attributes = {}) ⇒ Object
31 32 33 |
# File 'lib/producer/core/remote/fs.rb', line 31 def mkdir path, attributes = {} sftp.mkdir! path, attributes end |
#setstat(path, attributes) ⇒ Object
23 24 25 |
# File 'lib/producer/core/remote/fs.rb', line 23 def setstat path, attributes sftp.setstat! path, attributes end |