Created
September 4, 2009 01:19
-
-
Save kisoku/180666 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ ruby bin/ohai network//interfaces//em0//addresses//10.25.10.5 | |
{ | |
"broadcast": "10.25.10.255", | |
"netmask": "255.255.255.0", | |
"family": "inet" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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