Class: Huck::Generators::OhaiGenerator

Inherits:
Huck::Generator show all
Defined in:
lib/huck/generators/ohai.rb

Overview

Ohai provider for generating consumeable data

Instance Attribute Summary

Attributes inherited from Huck::Generator

#config

Instance Method Summary collapse

Methods inherited from Huck::Generator

#dump, factory

Constructor Details

#initializeOhaiGenerator

Load required modules for ohai generator



9
10
11
# File 'lib/huck/generators/ohai.rb', line 9

def initialize
  require 'ohai/system'
end

Instance Method Details

#generateObject

This method generates the data and returns it as a hash

Returns

A hash of hints as returned by ohai



17
18
19
20
21
22
23
24
25
# File 'lib/huck/generators/ohai.rb', line 17

def generate
  ohai = Ohai::System.new
  ohai.all_plugins

  # Need to load the JSON output, since ohai emits a 'mash' object map
  # instead of normal hashes, making serialization ugly in some cases
  # like YAML where canonical objects (eg. !ruby/mash) is emitted.
  JSON.load ohai.json_pretty_print
end