Class: Sprinkle::Installers::ReplaceText

Inherits:
Installer
  • Object
show all
Defined in:
lib/sprinkle/installers/replace_text.rb

Overview

Replace text installer

This installer replaces a text with another one in a file.

Example Usage

Change ssh port in /etc/ssh/sshd_config

package :magic_beans do
  replace_text 'Port 22', 'Port 2500', '/etc/ssh/sshd_config'
end

If you user has access to ‘sudo’ and theres a file that requires priveledges, you can pass :sudo => true

package :magic_beans do
  replace_text 'Port 22', 'Port 2500', '/etc/ssh/sshd_config', :sudo => true
end

A special verify step exists for this very installer its known as file_contains, it will test that a file indeed contains a substring that you send it.

Instance Attribute Summary collapse

Attributes inherited from Installer

#delivery, #options, #package, #post, #pre

Attributes included from Configurable

#delivery

Instance Method Summary collapse

Methods inherited from Installer

#process

Methods included from Configurable

#assert_delivery, #defaults, #method_missing, #option?

Constructor Details

#initialize(parent, regex, text, path, options = {}, &block) ⇒ ReplaceText

:nodoc:



29
30
31
32
33
34
# File 'lib/sprinkle/installers/replace_text.rb', line 29

def initialize(parent, regex, text, path, options={}, &block) #:nodoc:
  super parent, options, &block
  @regex = regex
  @text = text
  @path = path
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Sprinkle::Configurable

Instance Attribute Details

#pathObject

:nodoc:



27
28
29
# File 'lib/sprinkle/installers/replace_text.rb', line 27

def path
  @path
end

#regexObject

:nodoc:



27
28
29
# File 'lib/sprinkle/installers/replace_text.rb', line 27

def regex
  @regex
end

#textObject

:nodoc:



27
28
29
# File 'lib/sprinkle/installers/replace_text.rb', line 27

def text
  @text
end