class Producer::Core::Remote::FS

Attributes

sftp[R]

Public Class Methods

new(sftp) click to toggle source
# File lib/producer/core/remote/fs.rb, line 7
def initialize sftp
  @sftp = sftp
end

Public Instance Methods

chmod(path, mode) click to toggle source
# File lib/producer/core/remote/fs.rb, line 27
def chmod path, mode
  setstat path, permissions: mode
end
dir?(path) click to toggle source
# File lib/producer/core/remote/fs.rb, line 11
def dir? path
  sftp.stat!(path).directory?
rescue Net::SFTP::StatusException
  false
end
file?(path) click to toggle source
# 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) click to toggle source
# 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) click to toggle source
# 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 = {}) click to toggle source
# File lib/producer/core/remote/fs.rb, line 31
def mkdir path, attributes = {}
  sftp.mkdir! path, attributes
end
setstat(path, attributes) click to toggle source
# File lib/producer/core/remote/fs.rb, line 23
def setstat path, attributes
  sftp.setstat! path, attributes
end