summaryrefslogtreecommitdiffstats
path: root/lib/puppet/provider/confine
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/provider/confine')
-rw-r--r--lib/puppet/provider/confine/exists.rb28
-rw-r--r--lib/puppet/provider/confine/false.rb24
-rw-r--r--lib/puppet/provider/confine/feature.rb20
-rw-r--r--lib/puppet/provider/confine/true.rb26
-rw-r--r--lib/puppet/provider/confine/variable.rb102
5 files changed, 100 insertions, 100 deletions
diff --git a/lib/puppet/provider/confine/exists.rb b/lib/puppet/provider/confine/exists.rb
index 27c404acb..085118b2a 100644
--- a/lib/puppet/provider/confine/exists.rb
+++ b/lib/puppet/provider/confine/exists.rb
@@ -1,22 +1,22 @@
require 'puppet/provider/confine'
class Puppet::Provider::Confine::Exists < Puppet::Provider::Confine
- def self.summarize(confines)
- confines.inject([]) { |total, confine| total + confine.summary }
- end
+ def self.summarize(confines)
+ confines.inject([]) { |total, confine| total + confine.summary }
+ end
- def pass?(value)
- if for_binary?
- return false unless value = binary(value)
- end
- value and FileTest.exist?(value)
+ def pass?(value)
+ if for_binary?
+ return false unless value = binary(value)
end
+ value and FileTest.exist?(value)
+ end
- def message(value)
- "file #{value} does not exist"
- end
+ def message(value)
+ "file #{value} does not exist"
+ end
- def summary
- result.zip(values).inject([]) { |array, args| val, f = args; array << f unless val; array }
- end
+ def summary
+ result.zip(values).inject([]) { |array, args| val, f = args; array << f unless val; array }
+ end
end
diff --git a/lib/puppet/provider/confine/false.rb b/lib/puppet/provider/confine/false.rb
index b5b2b51c8..1c11dd40f 100644
--- a/lib/puppet/provider/confine/false.rb
+++ b/lib/puppet/provider/confine/false.rb
@@ -1,19 +1,19 @@
require 'puppet/provider/confine'
class Puppet::Provider::Confine::False < Puppet::Provider::Confine
- def self.summarize(confines)
- confines.inject(0) { |count, confine| count + confine.summary }
- end
+ def self.summarize(confines)
+ confines.inject(0) { |count, confine| count + confine.summary }
+ end
- def pass?(value)
- ! value
- end
+ def pass?(value)
+ ! value
+ end
- def message(value)
- "true value when expecting false"
- end
+ def message(value)
+ "true value when expecting false"
+ end
- def summary
- result.find_all { |v| v == false }.length
- end
+ def summary
+ result.find_all { |v| v == false }.length
+ end
end
diff --git a/lib/puppet/provider/confine/feature.rb b/lib/puppet/provider/confine/feature.rb
index 8cd5daaec..b223b8b11 100644
--- a/lib/puppet/provider/confine/feature.rb
+++ b/lib/puppet/provider/confine/feature.rb
@@ -1,17 +1,17 @@
require 'puppet/provider/confine'
class Puppet::Provider::Confine::Feature < Puppet::Provider::Confine
- def self.summarize(confines)
- confines.collect { |c| c.values }.flatten.uniq.find_all { |value| ! confines[0].pass?(value) }
- end
+ def self.summarize(confines)
+ confines.collect { |c| c.values }.flatten.uniq.find_all { |value| ! confines[0].pass?(value) }
+ end
- # Is the named feature available?
- def pass?(value)
- Puppet.features.send(value.to_s + "?")
- end
+ # Is the named feature available?
+ def pass?(value)
+ Puppet.features.send(value.to_s + "?")
+ end
- def message(value)
- "feature #{value} is missing"
- end
+ def message(value)
+ "feature #{value} is missing"
+ end
end
diff --git a/lib/puppet/provider/confine/true.rb b/lib/puppet/provider/confine/true.rb
index 86b3b144f..559f2675f 100644
--- a/lib/puppet/provider/confine/true.rb
+++ b/lib/puppet/provider/confine/true.rb
@@ -1,20 +1,20 @@
require 'puppet/provider/confine'
class Puppet::Provider::Confine::True < Puppet::Provider::Confine
- def self.summarize(confines)
- confines.inject(0) { |count, confine| count + confine.summary }
- end
+ def self.summarize(confines)
+ confines.inject(0) { |count, confine| count + confine.summary }
+ end
- def pass?(value)
- # Double negate, so we only get true or false.
- ! ! value
- end
+ def pass?(value)
+ # Double negate, so we only get true or false.
+ ! ! value
+ end
- def message(value)
- "false value when expecting true"
- end
+ def message(value)
+ "false value when expecting true"
+ end
- def summary
- result.find_all { |v| v == true }.length
- end
+ def summary
+ result.find_all { |v| v == true }.length
+ end
end
diff --git a/lib/puppet/provider/confine/variable.rb b/lib/puppet/provider/confine/variable.rb
index 84f7e4044..af8e5d314 100644
--- a/lib/puppet/provider/confine/variable.rb
+++ b/lib/puppet/provider/confine/variable.rb
@@ -5,55 +5,55 @@ require 'puppet/provider/confine'
# is set explicitly by the ConfineCollection class -- from this class,
# it's not obvious how the name would ever get set.
class Puppet::Provider::Confine::Variable < Puppet::Provider::Confine
- # Provide a hash summary of failing confines -- the key of the hash
- # is the name of the confine, and the value is the missing yet required values.
- # Only returns failed values, not all required values.
- def self.summarize(confines)
- result = Hash.new { |hash, key| hash[key] = [] }
- confines.inject(result) { |total, confine| total[confine.name] += confine.values unless confine.valid?; total }
- end
-
- # This is set by ConfineCollection.
- attr_accessor :name
-
- # Retrieve the value from facter
- def facter_value
- @facter_value ||= ::Facter.value(name).to_s.downcase
- end
-
- def initialize(values)
- super
- @values = @values.collect { |v| v.to_s.downcase }
- end
-
- def message(value)
- "facter value '#{test_value}' for '#{self.name}' not in required list '#{values.join(",")}'"
- end
-
- # Compare the passed-in value to the retrieved value.
- def pass?(value)
- test_value.downcase.to_s == value.to_s.downcase
- end
-
- def reset
- # Reset the cache. We want to cache it during a given
- # run, but not across runs.
- @facter_value = nil
- end
-
- def valid?
- @values.include?(test_value.to_s.downcase)
- ensure
- reset
- end
-
- private
-
- def setting?
- Puppet.settings.valid?(name)
- end
-
- def test_value
- setting? ? Puppet.settings[name] : facter_value
- end
+ # Provide a hash summary of failing confines -- the key of the hash
+ # is the name of the confine, and the value is the missing yet required values.
+ # Only returns failed values, not all required values.
+ def self.summarize(confines)
+ result = Hash.new { |hash, key| hash[key] = [] }
+ confines.inject(result) { |total, confine| total[confine.name] += confine.values unless confine.valid?; total }
+ end
+
+ # This is set by ConfineCollection.
+ attr_accessor :name
+
+ # Retrieve the value from facter
+ def facter_value
+ @facter_value ||= ::Facter.value(name).to_s.downcase
+ end
+
+ def initialize(values)
+ super
+ @values = @values.collect { |v| v.to_s.downcase }
+ end
+
+ def message(value)
+ "facter value '#{test_value}' for '#{self.name}' not in required list '#{values.join(",")}'"
+ end
+
+ # Compare the passed-in value to the retrieved value.
+ def pass?(value)
+ test_value.downcase.to_s == value.to_s.downcase
+ end
+
+ def reset
+ # Reset the cache. We want to cache it during a given
+ # run, but not across runs.
+ @facter_value = nil
+ end
+
+ def valid?
+ @values.include?(test_value.to_s.downcase)
+ ensure
+ reset
+ end
+
+ private
+
+ def setting?
+ Puppet.settings.valid?(name)
+ end
+
+ def test_value
+ setting? ? Puppet.settings[name] : facter_value
+ end
end