Sha256: 77edc8852903979684691bdb940bf99c1ae7cbc67991dca791fd22450ed8ce4c

Contents?: true

Size: 942 Bytes

Versions: 9

Compression:

Stored size: 942 Bytes

Contents

require 'rbconfig'

# A module to return config related data
#
module Facter::Util::Config

  def self.ext_fact_loader
    @ext_fact_loader || Facter::Util::DirectoryLoader.default_loader
  end

  def self.ext_fact_loader=(loader)
    @ext_fact_loader = loader
  end

  def self.is_mac?
    RbConfig::CONFIG['host_os'] =~ /darwin/i
  end

  # Returns true if OS is windows
  def self.is_windows?
    RbConfig::CONFIG['host_os'] =~ /mswin|win32|dos|mingw|cygwin/i
  end

  def self.windows_data_dir
    if Dir.const_defined? 'COMMON_APPDATA' then
      Dir::COMMON_APPDATA
    else
      nil
    end
  end

  def self.external_facts_dirs
    windows_dir = windows_data_dir
    if windows_dir.nil? then
      ["/etc/facter/facts.d", "/etc/puppetlabs/facter/facts.d"]
    else
      [File.join(windows_dir, 'PuppetLabs', 'facter', 'facts.d')]
    end
  end
end

if Facter::Util::Config.is_windows?
  require 'rubygems'
  require 'win32/dir'
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
facter-1.7.3 lib/facter/util/config.rb
facter-1.7.3.rc1 lib/facter/util/config.rb
facter-1.7.2 lib/facter/util/config.rb
facter-1.7.2.rc1 lib/facter/util/config.rb
facter-1.7.1 lib/facter/util/config.rb
facter-1.7.1.rc1 lib/facter/util/config.rb
facter-1.7.0 lib/facter/util/config.rb
facter-1.7.0.rc2 lib/facter/util/config.rb
facter-1.7.0.rc1 lib/facter/util/config.rb