Skip to content

Instantly share code, notes, and snippets.

@kisoku
Created September 4, 2009 01:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kisoku/180666 to your computer and use it in GitHub Desktop.
Save kisoku/180666 to your computer and use it in GitHub Desktop.
$ ruby bin/ohai network//interfaces//em0//addresses//10.25.10.5
{
"broadcast": "10.25.10.255",
"netmask": "255.255.255.0",
"family": "inet"
}
diff --git a/lib/ohai/system.rb b/lib/ohai/system.rb
index 5bc1393..4d48d74 100644
--- a/lib/ohai/system.rb
+++ b/lib/ohai/system.rb
@@ -201,7 +201,12 @@ module Ohai
end
def attributes_print(a)
- JSON.pretty_generate(@data[a])
+ if a =~ /\/\/+/
+ path = a.split("//").inject(@data) {|memo, curr| memo[curr.to_sym]}
+ JSON.pretty_generate(path)
+ else
+ JSON.pretty_generate(@data[a])
+ end
end
# Create an Ohai::System from JSON
def self.json_create(o)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment