module Ohai::Hints

Public Class Methods

hint?(name) click to toggle source
# File lib/ohai/hints.rb, line 28
def self.hint?(name)
  @hints ||= Hash.new
  return @hints[name] if @hints[name]

  Ohai::Config[:hints_path].each do |path|
    filename = File.join(path, "#{name}.json")
    if File.exist?(filename)
      begin
        json_parser = FFI_Yajl::Parser.new
        hash = json_parser.parse(File.read(filename))
        @hints[name] = hash || Hash.new # 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
    end
  end

  @hints[name]
end
refresh_hints() click to toggle source
# File lib/ohai/hints.rb, line 24
def self.refresh_hints
  @hints = Hash.new
end