Skip to content

Instantly share code, notes, and snippets.

@mikepea
Created April 30, 2010 14:05
Show Gist options
  • Select an option

  • Save mikepea/385247 to your computer and use it in GitHub Desktop.

Select an option

Save mikepea/385247 to your computer and use it in GitHub Desktop.
diff --git a/lib/mcollective/util.rb b/lib/mcollective/util.rb
index abd5791..6870709 100644
--- a/lib/mcollective/util.rb
+++ b/lib/mcollective/util.rb
@@ -55,10 +55,19 @@ module MCollective
# If the passed value starts with a / it's assumed to be regex
# and will use regex to match
def self.has_fact?(fact, value)
- value = Regexp.new(value.gsub("\/", "")) if value.match("^/")
-
- if value.is_a?(Regexp)
- return true if Facts.get_fact(fact).match(value)
+ case value
+ when /^\//
+ return true if Facts.get_fact(fact).match( Regexp.new(value.gsub("\/", "")) )
+ when /^>=/
+ return true if Facts.get_fact(fact) >= value
+ when /^<=/
+ return true if Facts.get_fact(fact) =< value
+ when /^</
+ return true if Facts.get_fact(fact) < value
+ when /^>/
+ return true if Facts.get_fact(fact) > value
+ when /^!/
+ return true if Facts.get_fact(fact) != value
else
return true if Facts.get_fact(fact) == value
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment