Module: TrainSH::Mixin::FileHelpers

Defined in:
lib/trainsh/mixin/file_helpers.rb

Instance Method Summary collapse

Instance Method Details

#read_file(path) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/trainsh/mixin/file_helpers.rb', line 6

def read_file(path)
  remotefile = session.file(path)
  say format('Remote file %<filename>s does not exist', filename: path) unless remotefile.exist?

  localfile = Tempfile.open
  localfile.write(remotefile.content || '')
  localfile.close

  localfile
end

#write_file(path, content) ⇒ Object



17
18
19
20
# File 'lib/trainsh/mixin/file_helpers.rb', line 17

def write_file(path, content)
  remotefile = session.file(path)
  remotefile.content = content
end