diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/facter/util/fact.rb | 4 | ||||
-rw-r--r-- | lib/facter/util/loader.rb | 2 | ||||
-rw-r--r-- | lib/facter/util/resolution.rb | 17 |
3 files changed, 9 insertions, 14 deletions
diff --git a/lib/facter/util/fact.rb b/lib/facter/util/fact.rb index e78ed97..935b3c1 100644 --- a/lib/facter/util/fact.rb +++ b/lib/facter/util/fact.rb @@ -41,9 +41,7 @@ class Facter::Util::Fact # Immediately sort the resolutions, so that we always have # a sorted list for looking up values. - # We always want to look them up in the order of number of - # confines, so the most restricted resolution always wins. - @resolves.sort! { |a, b| b.length <=> a.length } + @resolves.sort! { |a, b| b.weight <=> a.weight } return resolve end diff --git a/lib/facter/util/loader.rb b/lib/facter/util/loader.rb index b6aa8de..a52012c 100644 --- a/lib/facter/util/loader.rb +++ b/lib/facter/util/loader.rb @@ -90,7 +90,7 @@ class Facter::Util::Loader next if fact and env_name != fact Facter.add($1) do - from_environment + has_weight 1_000_000 setcode { value } end diff --git a/lib/facter/util/resolution.rb b/lib/facter/util/resolution.rb index 2ca2447..d82fab2 100644 --- a/lib/facter/util/resolution.rb +++ b/lib/facter/util/resolution.rb @@ -85,9 +85,8 @@ class Facter::Util::Resolution end end - # Say this resolution came from the environment - def from_environment - @from_environment = true + def has_weight(weight) + @weight = weight end # Create a new resolution mechanism. @@ -96,15 +95,13 @@ class Facter::Util::Resolution @confines = [] @value = nil @timeout = 0 - @from_environment = false + @weight = nil end - # Return the number of confines. - def length - # If the resolution came from an environment variable - # say we're very very sure about the value of the resolution - if @from_environment - 1_000_000_000 + # Return the importance of this resolution. + def weight + if @weight + @weight else @confines.length end |