lib/rconf/configurator.rb in rconf-0.5.6 vs lib/rconf/configurator.rb in rconf-0.5.8
- old
+ new
@@ -7,10 +7,12 @@
# licensee is strictly subject to the terms and conditions,
# including confidentiality obligations, set forth in the applicable
# License Agreement between RightScale.com, Inc. and
# the licensee
+require 'digest/sha1'
+
module RightConf
# Configurator mixin, defines DSL and common validation method
module Configurator
@@ -116,11 +118,25 @@
#
# === Return
# true:: Always return true
def run(*args)
init
- Platform.dispatch(*args) { :run }
+ sha = Profile.configurator_signature(self.class.key)
+ if sha != signature
+ Platform.dispatch(*args) { :run }
+ Profile.set_configurator_signature(self.class.key, signature)
+ end
true
+ end
+
+ # Calculate unique SHA for current settings
+ #
+ # === Return
+ # sha(String):: SHA for current settings
+ def signature
+ return '' if @settings_values.nil?
+ blob = @settings_values.inject('') { |b, (k, v)| b += "#{k}:#{v};" }
+ sha = Digest::SHA1.hexdigest(blob)
end
# Get value of configuration option
#
# === Parameters