Module: Ohai

Defined in:
lib/ohai/version.rb,
lib/ohai/log.rb,
lib/ohai/hints.rb,
lib/ohai/config.rb,
lib/ohai/loader.rb,
lib/ohai/runner.rb,
lib/ohai/system.rb,
lib/ohai/mixin/os.rb,
lib/ohai/exception.rb,
lib/ohai/common/dmi.rb,
lib/ohai/dsl/plugin.rb,
lib/ohai/util/win32.rb,
lib/ohai/mixin/which.rb,
lib/ohai/provides_map.rb,
lib/ohai/plugin_config.rb,
lib/ohai/util/ip_helper.rb,
lib/ohai/mixin/shell_out.rb,
lib/ohai/train_transport.rb,
lib/ohai/mixin/do_metadata.rb,
lib/ohai/mixin/http_helper.rb,
lib/ohai/mixin/json_helper.rb,
lib/ohai/mixin/ec2_metadata.rb,
lib/ohai/mixin/gce_metadata.rb,
lib/ohai/mixin/oci_metadata.rb,
lib/ohai/mixin/train_helpers.rb,
lib/ohai/mixin/azure_metadata.rb,
lib/ohai/mixin/network_helper.rb,
lib/ohai/dsl/plugin/versionvii.rb,
lib/ohai/mixin/constant_helper.rb,
lib/ohai/mixin/alibaba_metadata.rb,
lib/ohai/mixin/seconds_to_human.rb,
lib/ohai/mixin/chef_utils_wiring.rb,
lib/ohai/mixin/scaleway_metadata.rb

Overview

Author

Adam Jacob (<[email protected]>)

Copyright

Copyright © Chef Software Inc.

License

Apache License, Version 2.0

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Defined Under Namespace

Modules: Common, DSL, Exceptions, Hints, Mixin, NamedPlugin, Util Classes: Application, Config, Loader, Log, PluginConfig, ProvidesMap, Runner, System, TrainTransport

Constant Summary collapse

OHAI_ROOT =
File.expand_path(__dir__)
VERSION =
"18.1.3"

Class Method Summary collapse

Class Method Details

.abs_path(abs_path) ⇒ Object

Extracted abs_path to support testability: This method gets overridden at test time, to force the shell to check ohai/spec/unit/path/original/absolute/path/to/exe



80
81
82
# File 'lib/ohai/dsl/plugin.rb', line 80

def self.abs_path( abs_path )
  abs_path
end

.configObject

Shortcut for Ohai::Config.ohai



48
49
50
# File 'lib/ohai/config.rb', line 48

def self.config
  Config.ohai
end

.dev_nullString

Cross platform /dev/null to support testability

Returns:



69
70
71
72
73
74
75
# File 'lib/ohai/dsl/plugin.rb', line 69

def self.dev_null
  if RUBY_PLATFORM.match?(/mswin|mingw|windows/)
    "NUL"
  else
    "/dev/null"
  end
end

.plugin(name, &block) ⇒ Object

Parameters:

Raises:



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/ohai/dsl/plugin.rb', line 49

def self.plugin(name, &block)
  raise Ohai::Exceptions::InvalidPluginName, "#{name} is not a valid plugin name. A valid plugin name is a symbol which begins with a capital letter and contains no underscores" unless NamedPlugin.valid_name?(name)

  plugin = nil

  # avoid already initialized constant warnings if already defined
  if NamedPlugin.strict_const_defined?(name)
    plugin = NamedPlugin.const_get(name)
    plugin.class_eval(&block)
  else
    klass = Class.new(DSL::Plugin::VersionVII, &block)
    plugin = NamedPlugin.const_set(name, klass)
  end

  plugin
end