Class/Module Index [+]

Quicksearch

Facter::Application

Public Class Methods

create_directory_loader(dir) click to toggle source
# File lib/facter/application.rb, line 10
def self.create_directory_loader(dir)
  begin
    Facter::Util::Config.ext_fact_loader = Facter::Util::DirectoryLoader.loader_for(dir)
  rescue Facter::Util::DirectoryLoader::NoSuchDirectoryError => error
    Facter.log_exception(error, "Specified external facts directory #{dir} does not exist.")
    exit(1)
  end
end
create_nothing_loader() click to toggle source
# File lib/facter/application.rb, line 19
def self.create_nothing_loader
  Facter::Util::Config.ext_fact_loader = Facter::Util::NothingLoader.new
end
run(argv) click to toggle source
# File lib/facter/application.rb, line 23
def self.run(argv)
  options = parse(argv)

  # Accept fact names to return from the command line
  names = argv

  # Change location of external facts dir
  # Check here for valid ext_dir and exit program

  # Create the facts hash that is printed to standard out.
  unless names.empty?
    facts = {}
    names.each do |name|
      begin
        facts[name] = Facter.value(name)
      rescue => error
        Facter.log_exception(error, "Could not retrieve #{name}: #{error.message}")
        exit(10)
      end
    end
  end

  # Print everything if they didn't ask for specific facts.
  facts ||= Facter.to_hash

  output = nil

  if options[:yaml]
    output = Facter::Util::Formatter.format_yaml(facts)
  elsif options[:json]
    output = Facter::Util::Formatter.format_json(facts)
  elsif options[:plaintext]
    output = Facter::Util::Formatter.format_plaintext(facts)
  else
    output = Facter::Util::Formatter.format_plaintext(facts)
  end

  puts output
  exit(0)

rescue => e
  Facter.log_exception(e)
  exit(12)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.