module Ohai::Hints
Public Class Methods
hint?(name)
click to toggle source
# File lib/ohai/hints.rb, line 38 def self.hint?(name) @hints ||= {} return @hints[name] if @hints[name] Ohai.config[:hints_path].each do |path| filename = File.join(path, "#{name}.json") next unless File.exist?(filename) Ohai::Log.debug("Found hint #{name}.json at #{filename}") @hints[name] = parse_hint_file(filename) end Ohai::Log.debug("Did not find hint #{name}.json in the hint path(s): #{Ohai.config[:hints_path].join(', ')} ") unless @hints.key?(name) @hints[name] end
parse_hint_file(filename)
click to toggle source
# File lib/ohai/hints.rb, line 28 def self.parse_hint_file(filename) json_parser = FFI_Yajl::Parser.new hash = json_parser.parse(File.read(filename)) hash || {} # hint # should exist because the file did, even if it didn't # contain anything rescue FFI_Yajl::ParseError => e Ohai::Log.error("Could not parse hint file at #{filename}: #{e.message}") end
refresh_hints()
click to toggle source
# File lib/ohai/hints.rb, line 24 def self.refresh_hints @hints = {} end