Created
April 30, 2010 14:05
-
-
Save mikepea/385247 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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