Class: Fauxhai::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/fauxhai/runner.rb,
lib/fauxhai/runner/default.rb,
lib/fauxhai/runner/windows.rb

Defined Under Namespace

Modules: Default, Windows

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Runner

Returns a new instance of Runner.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/fauxhai/runner.rb', line 6

def initialize(args)
  @system = Ohai::System.new
  @system.all_plugins

  case @system.data["platform"]
  when "windows", :windows
    require_relative "runner/windows"
    singleton_class.send :include, ::Fauxhai::Runner::Windows
  else
    require_relative "runner/default"
    singleton_class.send :include, ::Fauxhai::Runner::Default
  end

  result = @system.data.dup.delete_if { |k, v| !whitelist_attributes.include?(k) }.merge(
    "languages" => languages,
    "counters" => counters,
    "current_user" => current_user,
    "domain" => domain,
    "hostname" => hostname,
    "machinename" => hostname,
    "fqdn" => fqdn,
    "ipaddress" => ipaddress,
    "keys" => keys,
    "macaddress" => macaddress,
    "network" => network,
    "uptime" => uptime,
    "uptime_seconds" => uptime_seconds,
    "idle" => uptime,
    "idletime_seconds" => uptime_seconds,
    "cpu" => cpu,
    "memory" => memory,
    "virtualization" => virtualization,
    "time" => time
  )

  require "json" unless defined?(JSON)
  puts JSON.pretty_generate(result.sort.to_h)
end