Class: ConfigCurator::ConfigFile

Inherits:
Unit
  • Object
show all
Defined in:
lib/config_curator/units/config_file.rb

Overview

A config file is a file that should be copied.

Constant Summary

Constants inherited from Unit

Unit::DEFAULT_OPTIONS

Instance Attribute Summary collapse

Attributes inherited from Unit

#hosts, #logger, #packages

Instance Method Summary collapse

Methods inherited from Unit

#allowed_host?, #destination_path, #initialize, #options, #package_lookup, #packages_installed?, #source_path

Constructor Details

This class inherits a constructor from ConfigCurator::Unit

Instance Attribute Details

#fmodeObject

Returns the value of attribute fmode.



6
7
8
# File 'lib/config_curator/units/config_file.rb', line 6

def fmode
  @fmode
end

#groupObject

Returns the value of attribute group.



6
7
8
# File 'lib/config_curator/units/config_file.rb', line 6

def group
  @group
end

#ownerObject

Returns the value of attribute owner.



6
7
8
# File 'lib/config_curator/units/config_file.rb', line 6

def owner
  @owner
end

Instance Method Details

#destinationObject

Note:

Use #source by default.

Returns the value of attribute destination.



18
19
20
21
# File 'lib/config_curator/units/config_file.rb', line 18

def destination
  super
  @destination ||= source
end

#installObject

Installs the unit.



24
25
26
27
28
29
30
31
# File 'lib/config_curator/units/config_file.rb', line 24

def install
  s = super
  return s unless s
  install_file
  set_mode
  set_owner
  true
end

#install?Boolean

Checks if the unit should be installed.



34
35
36
37
38
39
40
# File 'lib/config_curator/units/config_file.rb', line 34

def install?
  s = super
  return s unless s
  fail InstallFailed, "No file source path specified." if source_path.nil?
  fail InstallFailed, "Source path does not exist: #{source}" unless File.exists? source_path
  true
end

#sourceObject

Will use files of the form filename.hostname.ext if found. (see Unit#source)



10
11
12
13
14
# File 'lib/config_curator/units/config_file.rb', line 10

def source
  path = super
  host_specific_file = search_for_host_specific_file path if path
  if host_specific_file then return host_specific_file else return path end
end