Class: Aruba::Platforms::ArubaFileCreator

Inherits:
Object
  • Object
show all
Defined in:
lib/aruba/platforms/aruba_file_creator.rb

Overview

Normal File Creator This class is not meant to be used directly by users.

Instance Method Summary collapse

Instance Method Details

#call(path, content, check_presence = false) ⇒ Object

Write File

Parameters:

  • path (String)

    The path to write content to

  • content (Object)

    The content of the file

  • check_presence (Boolean) (defaults to: false)

    (false) Check if file exist



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/aruba/platforms/aruba_file_creator.rb', line 20

def call(path, content, check_presence = false)
  if check_presence && !Aruba.platform.file?(path)
    raise "Expected #{path} to be present"
  end

  Aruba.platform.mkdir(File.dirname(path))

  File.write(path, content)

  self
end