def eval_condition(expr, val, plugin)
if( expr =~ /\s+or\s+/ )
expr.split(/\s+or\s+/).any?{|x| eval_condition(x.strip,val,plugin) }
elsif( expr =~ /\s+and\s+/ )
expr.split(/\s+and\s+/).all?{|x| eval_condition(x.strip,val,plugin) }
elsif( expr =~ /^not\s+(.+)$/ )
! eval_condition($1.strip,val,plugin)
else
case expr
when /^([^!=<>~\s\(\)]+(\([^!=<>~\s\(\)]*\))?)\s*(=|!=|<|>|<=|>=|=~|!~|<=?|>=?)\s*([^!=<>~\s\(\)]+(\([^!=<>~\s\(\)]*\))?)$/
lhs = eval_expr($1.strip,val,plugin)
op = $3
rhs = eval_expr($4.strip,val,plugin)
unless( lhs.nil? || rhs.nil? )
case op
when '='
(lhs == rhs)
when '<', '<'
(lhs < rhs)
when '<=', '<='
(lhs <= rhs)
when '>', '>'
(lhs > rhs)
when '>=', '>='
(lhs >= rhs)
when '=~'
(lhs =~ rhs)
when '!~'
(lhs !~ rhs)
else
raise(NotImplementedError, "'#{op}'")
end
else
false
end
when /^([^=<>~]+)$/
eval_expr($1.strip,val,plugin)
else
nil
end
end
end