Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Testing confines. They don't work yet

  • Loading branch information...
commit 55489de4cc22e330fdbceef6227b628716d7d03f 1 parent fe9dcff
@cosimo authored
Showing with 13 additions and 8 deletions.
  1. +10 −6 lib/Facter/Util/Confine.pm
  2. +3 −2 lib/Facter/Util/Resolution.pm
View
16 lib/Facter/Util/Confine.pm
@@ -14,7 +14,10 @@ has @.values is rw;
# Add the restriction. Requires the fact name, an operator, and the value
# we're comparing to.
-method initialize($fact, *@values) {
+method BUILD ($fact, *@values) {
+
+ Facter.debug("Building confine for " ~ $fact ~ " = " ~ @values.perl);
+
die "The fact name must be provided" unless $fact; # ArgumentError
die "One or more values must be provided" if @values.elems == 0;
$.fact = $fact;
@@ -28,21 +31,22 @@ method Str { # ruby: to_s
}
# Evaluate the fact, returning true or false.
-method true {
+method Bool {
+
+ Facter.debug("Confine processing: checking truth for fact " ~ $.fact ~ " = " ~ @.values.perl);
unless my $fact = Facter.get_fact($.fact) {
Facter.debug("No fact for $.fact");
- return False
+ return False;
}
my $value = Facter::Util::Values.convert($fact.value);
-
- return False if ! $value.defined;
+ return False unless $value.defined;
for @.values -> $v {
$v = Facter::Util::Values.convert($v);
next unless $v.WHAT == $value.WHAT; # ruby's .class
- return True if $value == $v;
+ return True if $value eq $v;
}
return False
View
5 lib/Facter/Util/Resolution.pm
@@ -91,8 +91,9 @@ method exec($code, $interpreter = $INTERPRETER) {
# Add a new confine to the resolution mechanism.
method confine(%confines) {
require Facter::Util::Confine;
- for %confines.kv -> $fact, $values {
- @.confines.push(Facter::Util::Confine.new($fact, $values));
+ for %confines.kv -> $fact, $value {
+ Facter.debug("Adding confine '$fact' => '$value'");
+ @.confines.push(Facter::Util::Confine.new($fact, $value));
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.