Method: Chef::Util::FileEdit#initialize

Defined in:
lib/chef/util/file_edit.rb

#initialize(filepath) ⇒ FileEdit

Returns a new instance of FileEdit.

Raises:

  • (ArgumentError)

31
32
33
34
35
36
37
# File 'lib/chef/util/file_edit.rb', line 31

def initialize(filepath)
  @original_pathname = filepath
  @file_edited = false

  raise ArgumentError, "File doesn't exist" unless File.exist? @original_pathname
  raise ArgumentError, "File is blank" unless (@contents = File.new(@original_pathname).readlines).length > 0
end