summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-05-17 15:08:25 -0700
committerTim Smith <tsmith@chef.io>2018-05-17 15:08:25 -0700
commit11ccdb8e42bce384c36b3357b71acb4898c966b2 (patch)
treedd09a41cce9e4b7836848150912085580f4b7c76
parentf633cff20aeeaaf4a32a6daa23cca649e9dd2745 (diff)
downloadohai-11ccdb8e42bce384c36b3357b71acb4898c966b2.tar.gz
Add yard to Hints module
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/ohai/hints.rb7
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]