diff options
author | Tim Smith <tsmith@chef.io> | 2018-05-17 15:08:25 -0700 |
---|---|---|
committer | Tim Smith <tsmith@chef.io> | 2018-05-17 15:08:25 -0700 |
commit | 11ccdb8e42bce384c36b3357b71acb4898c966b2 (patch) | |
tree | dd09a41cce9e4b7836848150912085580f4b7c76 | |
parent | f633cff20aeeaaf4a32a6daa23cca649e9dd2745 (diff) | |
download | ohai-11ccdb8e42bce384c36b3357b71acb4898c966b2.tar.gz |
Add yard to Hints module
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | lib/ohai/hints.rb | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/ohai/hints.rb b/lib/ohai/hints.rb index bfe77f69..7a32c7d5 100644 --- a/lib/ohai/hints.rb +++ b/lib/ohai/hints.rb @@ -21,10 +21,13 @@ require "ffi_yajl" module Ohai module Hints + # clear out any known hints in the @hints variable def self.refresh_hints @hints = {} end + # parse the JSON conents of a hint file + # @param filename [String] the hint file path def self.parse_hint_file(filename) json_parser = FFI_Yajl::Parser.new hash = json_parser.parse(File.read(filename)) @@ -35,6 +38,10 @@ module Ohai Ohai::Log.error("Could not parse hint file at #{filename}: #{e.message}") end + # retrieve hint contents given a hint name. Looks up in @hints variable first. Attempts + # to load from file in config's :hints_path if not already cached. Saves the contents + # to the hash if the file was successfully parsed + # @param name [String] the name of the hint (not the path) def self.hint?(name) @hints ||= {} return @hints[name] if @hints[name] |