Module: OpenFactRuntime

Defined in:
lib/openfact_runtime.rb

Overview

Activates the OpenFact gem while retaining its Facter-compatible Ruby API. OpenFact intentionally provides require 'facter', the Facter namespace, and the facter executable.

Constant Summary collapse

GEM_NAME =
'openfact'

Class Method Summary collapse

Class Method Details

.activate!Object

Raises:

  • (Gem::LoadError)


11
12
13
14
15
16
17
18
19
20
21
# File 'lib/openfact_runtime.rb', line 11

def self.activate!
  OpenVoxAgentRubygems.activate!
  gem(GEM_NAME)
  OpenVoxAgentRubygems.restore_paths!
  require 'syslog' unless Gem.win_platform?
  require 'facter'
  @runtime_specification = Gem.loaded_specs[GEM_NAME]
  raise Gem::LoadError, "The loaded fact implementation is not the #{GEM_NAME} gem" if @runtime_specification.nil?

  true
end

.gem_nameObject



23
24
25
# File 'lib/openfact_runtime.rb', line 23

def self.gem_name
  @runtime_specification&.name || 'unknown'
end

.gem_versionObject



27
28
29
# File 'lib/openfact_runtime.rb', line 27

def self.gem_version
  @runtime_specification&.version&.to_s || 'Unknown'
end