| Class | Symbiosis::ConfigFile |
| In: |
common/lib/symbiosis/config_file.rb
|
| Parent: | Object |
This class is used to make configuration files easier to handle.
The idea is that we write an MD5 sum to the file in a parseable way, and then check that to see if it has changed, or not.
This class is a base that should be absorbed into child classes.
| comment_char | [R] | |
| domain | [R] | |
| filename | [R] | |
| template | [R] |
Allow the ERB interpreter to be set by any subclass. This allows automatic escaping to be set up, for example.
Sets up a configuration file ‘filename’. The comment character ‘comment_char’ is used before the MD5 sum, and is assumed to be a hash.
This tests to see if the configuration has changed. First it checks to see if there is an MD5 sum in the file (defined by filename), and if so, it checks to see if that MD5 sum is correct for that file. If the MD5 sums match, then false is returned, otherwise true.
If no MD5 sum is found, the phrase " DO NOT EDIT THIS FILE - CHANGES WILL BE OVERWRITTEN", prepended by the comment_char is looked for. If that phrase is found, then false is returned.
If neither an MD5 or a warning could be found, then the file is assumed to have changed, so the method returns true.
Set the domain — potentially used in tests later, or in the template. Must be a Symbiosis::Domain.
Template the configuration. Adds " Checksum MD5 " and the MD5 hash of the preceding configuration, prepended by comment_char and to the end of the generated config.
See if the generated config is OK. This method always returns true, and thus should be overwritten in any child class.
Does the configuration need updating. It tests to see if the MD5 of the current file, and a new configuration based on templ match.
If no checksum is found in the original file, it returns true.
Writes the configuration specified by config to the filename specified in the constructor. The opts has takes options for the Symbiosis::Utils#safe_open method.