Sha256: 4863fd70bee39a5c2f58f6c4d3f396fd4efbf70e08592cba36bec8cea5e9592f

Contents?: true

Size: 1.57 KB

Versions: 16

Compression:

Stored size: 1.57 KB

Contents

module Facter
  if RUBY_PLATFORM == "java"
    # For JRuby, require 'facter.jar'
    begin
      require 'facter.jar'
    rescue LoadError
      raise LoadError.new('libfacter was not built with JRuby support.')
    end

    # Pass value call through to JNI interface
    def self.value(name)
      Java::ComPuppetlabs::Facter.lookup(name)
    end

    def self.search(*paths)
      # No-op; we don't support custom facts under JRuby
    end

    def self.version
      Java::ComPuppetlabs::Facter.lookup("facterversion")
    end

    def self.add(*params)
      raise 'adding facts under JRuby is not implemented.'
    end

  else
    # Simply require libfacter.so; this will define all of the Facter API
    begin
      facter_dir = ENV['FACTERDIR'] || File.join(File.expand_path("#{File.dirname(__FILE__)}"), '${LIBFACTER_INSTALL_RELATIVE}')
      #
      # This is a cmake pre-processor check. On *nix it will end up '' == '1'
      # On windows, where we want the changes it will be '1' == '1'
      #
      # Facter requires the extra inclusion of puppet/bin as the libfacter.so
      # lib requires libraries and executables from that directory
      if '${WIN32}' == '1'
        ENV['PATH'] = "#{File.join(facter_dir, 'bin')}#{File::PATH_SEPARATOR}#{File.join(facter_dir, '../puppet/bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
      end
      require "#{facter_dir}/${LIBFACTER_INSTALL_DESTINATION}/libfacter.so"
    rescue LoadError
      raise LoadError, "libfacter was not found. Please make sure it was installed to the expected location.\n" + ($!.message || ''), $!.backtrace
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
facter-3.12.2.cfacter.20181217 ext/facter/facter/lib/facter.rb.in
facter-3.12.1.cfacter.20181031 ext/facter/facter/lib/facter.rb.in
facter-3.11.6.cfacter.20181031 ext/facter/facter/lib/facter.rb.in
facter-3.12.1.cfacter.20181023 ext/facter/facter/lib/facter.rb.in
facter-3.11.5.cfacter.20181022 ext/facter/facter/lib/facter.rb.in
facter-3.12.0.cfacter.20181004 ext/facter/facter/lib/facter.rb.in
facter-3.12.0.cfacter.20181001 ext/facter/facter/lib/facter.rb.in
facter-3.12.0.cfacter.20180918 ext/facter/facter/lib/facter.rb.in
facter-3.11.4.cfacter.20180821 ext/facter/facter/lib/facter.rb.in
facter-3.11.3.cfacter.20180716 ext/facter/facter/lib/facter.rb.in
facter-3.11.2.cfacter.20180612 ext/facter/facter/lib/facter.rb.in
facter-3.9.6.cfacter.20180612 ext/facter/facter/lib/facter.rb.in
facter-3.11.2.cfacter.20180606 ext/facter/facter/lib/facter.rb.in
facter-3.9.6.cfacter.20180606 ext/facter/facter/lib/facter.rb.in
facter-3.11.0.cfacter.20180319 ext/facter/facter/lib/facter.rb.in
cfacter-3.11.0.rc.20180314 ext/facter/facter/lib/facter.rb.in