module CFacter
  # Gets the version of native facter.
  # @return [String] The version of native facter.
  # @api public
  def self.version
    initialize
    Facter.version
  end

  # Initializes native facter.
  # @api public
  def self.initialize
    begin
      require "#{ENV['CFACTER_DIR'] || '/usr'}/lib/libfacter.so"
    rescue LoadError
      raise LoadError.new('libfacter was not found. Please make sure native facter is installed.')
    end
  end
end
