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

factory

Constructor Details

#initializeOhaiGenerator

Load required modules for ohai generator



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

def initialize
  Huck::must_load 'ohai/system'
end

Instance Method Details

#generateObject

Generate data using ohai

Returns

A hash of hints as returned by ohai



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

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.
  data = JSON.load ohai.json_pretty_print

  Huck::serialize data, :format => @config['format']
end