Module: Ohai::Hints

Defined in:
lib/ohai/hints.rb

Class Method Summary collapse

Class Method Details

.hint?(name) ⇒ Boolean


28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# 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_hintsObject


24
25
26
# File 'lib/ohai/hints.rb', line 24

def self.refresh_hints
  @hints = Hash.new
end