Module: OpenVoxRuntime
- Defined in:
- lib/openvox_runtime.rb
Constant Summary collapse
- GEM_NAME =
'openvox'
Class Method Summary collapse
- .activate!(version = nil) ⇒ Object
- .available_versions ⇒ Object
- .gem_name ⇒ Object
- .gem_version ⇒ Object
Class Method Details
.activate!(version = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/openvox_runtime.rb', line 8 def self.activate!(version = nil) OpenVoxAgentRubygems.activate! specification = select_specification(version) raise Gem::LoadError, "Unable to find the #{GEM_NAME} gem#{version.nil? ? '' : " version #{version}"}" if specification.nil? if Gem::Specification.find_all_by_name(GEM_NAME).include?(specification) version.nil? || version.empty? ? gem(GEM_NAME) : gem(GEM_NAME, version) OpenVoxAgentRubygems.restore_paths! else # OpenVox agent packages may retain a puppet-<version>.gemspec filename. # RubyGems ignores that file for lookup by the declared `openvox` name, # so add its require paths directly after verifying the specification. specification.full_require_paths.reverse_each do |require_path| $LOAD_PATH.unshift(require_path) unless $LOAD_PATH.include?(require_path) end end require 'puppet' @runtime_specification = specification end |
.available_versions ⇒ Object
37 38 39 |
# File 'lib/openvox_runtime.rb', line 37 def self.available_versions available_specifications.map { |spec| spec.version.to_s }.uniq end |
.gem_name ⇒ Object
29 30 31 |
# File 'lib/openvox_runtime.rb', line 29 def self.gem_name @runtime_specification&.name || (Gem.loaded_specs.key?(GEM_NAME) ? GEM_NAME : 'unknown') end |
.gem_version ⇒ Object
33 34 35 |
# File 'lib/openvox_runtime.rb', line 33 def self.gem_version (@runtime_specification || Gem.loaded_specs[GEM_NAME])&.version&.to_s || 'Unknown' end |