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 (TrueClass, FalseClass) (defaults to: false)

    (false) Check if file exist



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

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

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

  if RUBY_VERSION < '1.9.3'
    File.open(path, 'w') { |f| f << content }
  else
    File.write(path, content)
  end

  self
end