lib/config_skeleton.rb in config_skeleton-0.4.0 vs lib/config_skeleton.rb in config_skeleton-0.4.1
- old
+ new
@@ -369,11 +369,11 @@
# @param force_reload [Boolean] Whether the regenerate_config was called with force_reload
# @param existing_config_hash [String] MD5 hash of the config file before regeneration.
#
# @note this can optionally be implemented by subclasses.
#
- def before_regenerate_config(force_reload:, existing_config_hash:); end
+ def before_regenerate_config(force_reload:, existing_config_hash:, existing_config_data:); end
# Run code after the config is regenerated and potentially a new file is written.
#
# @param force_reload [Boolean] Whether the regenerate_config was called with force_reload
# @param config_was_different [Boolean] Whether the diff of the old and new config was different.
@@ -463,11 +463,16 @@
# received, for instance), set `force_reload: true` and we'll be really insistent.
#
# @return [void]
#
def regenerate_config(force_reload: false)
- existing_config_hash = Digest::MD5.hexdigest(File.read(config_file))
- before_regenerate_config(force_reload: force_reload, existing_config_hash: existing_config_hash)
+ data = File.read(config_file)
+ existing_config_hash = Digest::MD5.hexdigest(data)
+ before_regenerate_config(
+ force_reload: force_reload,
+ existing_config_hash: existing_config_hash,
+ existing_config_data: data
+ )
logger.debug(logloc) { "force? #{force_reload.inspect}" }
tmpfile = Tempfile.new(service_name, File.dirname(config_file))
logger.debug(logloc) { "Tempfile is #{tmpfile.path}" }
unless (new_config = instrumented_config_data).nil?