summaryrefslogtreecommitdiffstats
path: root/lib/puppet/indirector/facts/facter.rb
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-07-09 18:12:17 -0700
committerMarkus Roberts <Markus@reality.com>2010-07-09 18:12:17 -0700
commit3180b9d9b2c844dade1d361326600f7001ec66dd (patch)
tree98fe7c5ac7eb942aac9c39f019a17b0b3f5a57f4 /lib/puppet/indirector/facts/facter.rb
parent543225970225de5697734bfaf0a6eee996802c04 (diff)
downloadpuppet-3180b9d9b2c844dade1d361326600f7001ec66dd.tar.gz
puppet-3180b9d9b2c844dade1d361326600f7001ec66dd.tar.xz
puppet-3180b9d9b2c844dade1d361326600f7001ec66dd.zip
Code smell: Two space indentation
Replaced 106806 occurances of ^( +)(.*$) with The ruby community almost universally (i.e. everyone but Luke, Markus, and the other eleven people who learned ruby in the 1900s) uses two-space indentation. 3 Examples: The code: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") becomes: end # Tell getopt which arguments are valid def test_get_getopt_args element = Setting.new :name => "foo", :desc => "anything", :settings => Puppet::Util::Settings.new assert_equal([["--foo", GetoptLong::REQUIRED_ARGUMENT]], element.getopt_args, "Did not produce appropriate getopt args") The code: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object becomes: assert_equal(str, val) assert_instance_of(Float, result) end # Now test it with a passed object The code: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end becomes: end assert_nothing_raised do klass[:Yay] = "boo" klass["Cool"] = :yayness end
Diffstat (limited to 'lib/puppet/indirector/facts/facter.rb')
-rw-r--r--lib/puppet/indirector/facts/facter.rb126
1 files changed, 63 insertions, 63 deletions
diff --git a/lib/puppet/indirector/facts/facter.rb b/lib/puppet/indirector/facts/facter.rb
index a3ce79b06..ab7378a34 100644
--- a/lib/puppet/indirector/facts/facter.rb
+++ b/lib/puppet/indirector/facts/facter.rb
@@ -2,82 +2,82 @@ require 'puppet/node/facts'
require 'puppet/indirector/code'
class Puppet::Node::Facts::Facter < Puppet::Indirector::Code
- desc "Retrieve facts from Facter. This provides a somewhat abstract interface
- between Puppet and Facter. It's only `somewhat` abstract because it always
- returns the local host's facts, regardless of what you attempt to find."
+ desc "Retrieve facts from Facter. This provides a somewhat abstract interface
+ between Puppet and Facter. It's only `somewhat` abstract because it always
+ returns the local host's facts, regardless of what you attempt to find."
- def self.load_fact_plugins
- # Add any per-module fact directories to the factpath
- module_fact_dirs = Puppet[:modulepath].split(":").collect do |d|
- ["lib", "plugins"].map do |subdirectory|
- Dir.glob("#{d}/*/#{subdirectory}/facter")
- end
- end.flatten
- dirs = module_fact_dirs + Puppet[:factpath].split(":")
- x = dirs.each do |dir|
- load_facts_in_dir(dir)
- end
+ def self.load_fact_plugins
+ # Add any per-module fact directories to the factpath
+ module_fact_dirs = Puppet[:modulepath].split(":").collect do |d|
+ ["lib", "plugins"].map do |subdirectory|
+ Dir.glob("#{d}/*/#{subdirectory}/facter")
+ end
+ end.flatten
+ dirs = module_fact_dirs + Puppet[:factpath].split(":")
+ x = dirs.each do |dir|
+ load_facts_in_dir(dir)
end
+ end
- def self.load_facts_in_dir(dir)
- return unless FileTest.directory?(dir)
+ def self.load_facts_in_dir(dir)
+ return unless FileTest.directory?(dir)
- Dir.chdir(dir) do
- Dir.glob("*.rb").each do |file|
- fqfile = ::File.join(dir, file)
- begin
- Puppet.info "Loading facts in #{::File.basename(file.sub(".rb",''))}"
- Timeout::timeout(self.timeout) do
- load file
- end
- rescue SystemExit,NoMemoryError
- raise
- rescue Exception => detail
- Puppet.warning "Could not load fact file #{fqfile}: #{detail}"
- end
- end
+ Dir.chdir(dir) do
+ Dir.glob("*.rb").each do |file|
+ fqfile = ::File.join(dir, file)
+ begin
+ Puppet.info "Loading facts in #{::File.basename(file.sub(".rb",''))}"
+ Timeout::timeout(self.timeout) do
+ load file
+ end
+ rescue SystemExit,NoMemoryError
+ raise
+ rescue Exception => detail
+ Puppet.warning "Could not load fact file #{fqfile}: #{detail}"
end
+ end
end
+ end
- def self.timeout
- timeout = Puppet[:configtimeout]
- case timeout
- when String
- if timeout =~ /^\d+$/
- timeout = Integer(timeout)
- else
- raise ArgumentError, "Configuration timeout must be an integer"
- end
- when Integer # nothing
- else
- raise ArgumentError, "Configuration timeout must be an integer"
- end
-
- timeout
+ def self.timeout
+ timeout = Puppet[:configtimeout]
+ case timeout
+ when String
+ if timeout =~ /^\d+$/
+ timeout = Integer(timeout)
+ else
+ raise ArgumentError, "Configuration timeout must be an integer"
+ end
+ when Integer # nothing
+ else
+ raise ArgumentError, "Configuration timeout must be an integer"
end
- def initialize(*args)
- super
- self.class.load_fact_plugins
- end
+ timeout
+ end
- def destroy(facts)
- raise Puppet::DevError, "You cannot destroy facts in the code store; it is only used for getting facts from Facter"
- end
+ def initialize(*args)
+ super
+ self.class.load_fact_plugins
+ end
- # Look a host's facts up in Facter.
- def find(request)
- result = Puppet::Node::Facts.new(request.key, Facter.to_hash)
+ def destroy(facts)
+ raise Puppet::DevError, "You cannot destroy facts in the code store; it is only used for getting facts from Facter"
+ end
- result.add_local_facts
- result.stringify
- result.downcase_if_necessary
+ # Look a host's facts up in Facter.
+ def find(request)
+ result = Puppet::Node::Facts.new(request.key, Facter.to_hash)
- result
- end
+ result.add_local_facts
+ result.stringify
+ result.downcase_if_necessary
- def save(facts)
- raise Puppet::DevError, "You cannot save facts to the code store; it is only used for getting facts from Facter"
- end
+ result
+ end
+
+ def save(facts)
+ raise Puppet::DevError, "You cannot save facts to the code store; it is only used for getting facts from Facter"
+ end
end