Class: Serverkit::Resources::Line

Inherits:
Base
  • Object
show all
Defined in:
lib/serverkit/resources/line.rb

Overview

Ensure a particular line is in a file, or replace an existing line using regexp.

Examples:

Example line resource that ensures a line is in /etc/sudoers

- type: line
  path: /etc/sudoers
  line: "#includedir /etc/sudoers.d"

Constant Summary collapse

DEFAULT_STATE =
"present"

Instance Attribute Summary

Attributes inherited from Base

#attributes, #backend, #check_result, #recheck_result, #recipe

Instance Method Summary collapse

Methods inherited from Base

abstract_class?, #all_errors, attribute, #handlers, #id, #initialize, #notifiable?, #run_apply, #run_check, #successful?, #successful_on_check?, #successful_on_recheck?, #to_a

Constructor Details

This class inherits a constructor from Serverkit::Resources::Base

Instance Method Details

#applyObject

Note:

Override



18
19
20
21
22
# File 'lib/serverkit/resources/line.rb', line 18

def apply
  if has_correct_file?
    send_applied_remote_file_content_to_path
  end
end

#checkObject

Note:

Override



25
26
27
# File 'lib/serverkit/resources/line.rb', line 25

def check
  has_correct_file? && has_correct_line?
end