summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-09-16 21:06:45 -0700
committerTim Smith <tsmith@chef.io>2018-09-16 21:06:45 -0700
commitb6fc8cf60711705e98b0222602adf855b8c56025 (patch)
treee36566104d62f40295c60c7d7724f6ce3e6f8e1e
parent6ede9657643cd397d858e32c61f01271af4bb9b3 (diff)
downloadohai-yard.tar.gz
Add additional yard commentsyard
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/ohai/dsl/plugin.rb3
-rw-r--r--lib/ohai/hints.rb2
-rw-r--r--lib/ohai/loader.rb11
-rw-r--r--lib/ohai/log.rb2
-rw-r--r--lib/ohai/system.rb8
5 files changed, 24 insertions, 2 deletions
diff --git a/lib/ohai/dsl/plugin.rb b/lib/ohai/dsl/plugin.rb
index f7ed9286..b102edc0 100644
--- a/lib/ohai/dsl/plugin.rb
+++ b/lib/ohai/dsl/plugin.rb
@@ -43,6 +43,7 @@ module Ohai
end
end
+ # @param name [String]
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)
@@ -61,6 +62,8 @@ module Ohai
end
# Cross platform /dev/null to support testability
+ #
+ # @return [String]
def self.dev_null
if RUBY_PLATFORM =~ /mswin|mingw|windows/
"NUL"
diff --git a/lib/ohai/hints.rb b/lib/ohai/hints.rb
index a3501ea0..fd568aa6 100644
--- a/lib/ohai/hints.rb
+++ b/lib/ohai/hints.rb
@@ -26,7 +26,7 @@ module Ohai
@hints = {}
end
- # parse the JSON conents of a hint file. Return an empty hash if the file has
+ # parse the JSON contents of a hint file. Return an empty hash if the file has
# no JSON content
# @param filename [String] the hint file path
def self.parse_hint_file(filename)
diff --git a/lib/ohai/loader.rb b/lib/ohai/loader.rb
index 4efa16c2..72da2163 100644
--- a/lib/ohai/loader.rb
+++ b/lib/ohai/loader.rb
@@ -62,12 +62,18 @@ module Ohai
# Searches all plugin paths and returns an Array of PluginFile objects
# representing each plugin file.
+ #
+ # @param dir [Array, String] directory/directories to load plugins from
+ # @return [Array<Ohai::Loader::PluginFile>]
def plugin_files_by_dir(dir = Ohai.config[:plugin_path])
Array(dir).inject([]) do |plugin_files, plugin_path|
plugin_files + PluginFile.find_all_in(plugin_path)
end
end
+ # loads all plugin classes
+ #
+ # @return [Array<String>]
def load_all
plugin_files_by_dir.each do |plugin_file|
load_plugin_class(plugin_file.path, plugin_file.plugin_root)
@@ -76,6 +82,8 @@ module Ohai
collect_v7_plugins
end
+ # load additional plugins classes from a given directory
+ # @param from [String] path to a directory with additional plugins to load
def load_additional(from)
from = [ Ohai.config[:plugin_path], from].flatten
plugin_files_by_dir(from).collect do |plugin_file|
@@ -88,6 +96,9 @@ module Ohai
# Load a specified file as an ohai plugin and creates an instance of it.
# Not used by ohai itself, but can be used to load a plugin for testing
# purposes.
+ #
+ # @param plugin_path [String]
+ # @param plugin_dir_path [String]
def load_plugin(plugin_path, plugin_dir_path = nil)
plugin_class = load_plugin_class(plugin_path, plugin_dir_path)
return nil unless plugin_class.kind_of?(Class)
diff --git a/lib/ohai/log.rb b/lib/ohai/log.rb
index 667caf3c..91a8c78e 100644
--- a/lib/ohai/log.rb
+++ b/lib/ohai/log.rb
@@ -22,7 +22,7 @@ module Ohai
class Log
extend Mixlib::Log
- # this class loading initalization is so that we don't lose early logger
+ # this class loading initialization is so that we don't lose early logger
# messages when run from the CLI?
init(STDERR)
level = :info # rubocop:disable Lint/UselessAssignment
diff --git a/lib/ohai/system.rb b/lib/ohai/system.rb
index 7d5d973e..22ba8620 100644
--- a/lib/ohai/system.rb
+++ b/lib/ohai/system.rb
@@ -53,6 +53,10 @@ module Ohai
reset_system
end
+ # clears the current collected data, clears the provides map for plugins,
+ # refreshes hints, and reconfigures ohai. In short this gets Ohai into a first run state
+ #
+ # @return [void]
def reset_system
@data = Mash.new
@provides_map = ProvidesMap.new
@@ -73,6 +77,10 @@ module Ohai
@data[key]
end
+ # resets the system and loads then runs the plugins
+ #
+ # @param [Array<String>] attribute_filter
+ # @return [void]
def all_plugins(attribute_filter = nil)
# Reset the system when all_plugins is called since this function
# can be run multiple times in order to pick up any changes in the