From b6fc8cf60711705e98b0222602adf855b8c56025 Mon Sep 17 00:00:00 2001 From: Tim Smith Date: Sun, 16 Sep 2018 21:06:45 -0700 Subject: Add additional yard comments Signed-off-by: Tim Smith --- lib/ohai/dsl/plugin.rb | 3 +++ lib/ohai/hints.rb | 2 +- lib/ohai/loader.rb | 11 +++++++++++ lib/ohai/log.rb | 2 +- lib/ohai/system.rb | 8 ++++++++ 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] 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] 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] 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 -- cgit v1.2.1