Permalink
Browse files

[rightscale] Change the marker to only use two regexes and a case sta…

…tement instead of if/elsif/end. Also added YARD doc for it.

(cherry picked from commit 0d98d4a)
  • Loading branch information...
1 parent 7a57fe6 commit 61932a15fed16828c065ae565f18ba4520d9ac46 @douglaswth douglaswth committed Sep 19, 2012
Showing with 7 additions and 10 deletions.
  1. +7 −10 cookbooks/rightscale/definitions/rightscale_marker.rb
@@ -5,31 +5,28 @@
# RightScale Terms of Service available at http://www.rightscale.com/terms.php and,
# if applicable, other agreements such as a RightScale Master Subscription Agreement.
+# Marks the beginning and end of a Chef recipe converge in RightScale Audit Entries and logs.
+#
+# @param [String, Symbol] name The marker to use; can be +:begin+ or +:end+. Also, +:start+ and +:stop+ will work.
define :rightscale_marker do
recipe_name = "#{self.cookbook_name}" + "::" + "#{self.recipe_name}"
location = params[:name] ? params[:name] : "start"
- # translate symbols to strings ie :begin = "begin"
- location = location.to_s
-
- # detect if used 'begin' instead of 'start' or 'stop' instead of 'end'
- location = "start" if location =~ /^begin$/
- location = "end" if location =~ /^stop$/
-
- if location =~ /^start$/
+ case location.to_s
+ when /^(start|begin)$/
# We use Chef::Log.info here to get clear output
ruby_block "log marker" do
block do
Chef::Log.info "********************************************************************************"
Chef::Log.info "*RS> Running recipe #{recipe_name} ****"
end
end
- elsif location =~ /^end$/
+ when /^(stop|end)$/
# Do nothing
else
- log "unknown marker"
+ Chef::Log.warn "unknown marker (#{location})"
end
end

0 comments on commit 61932a1

Please sign in to comment.