Created
March 3, 2012 21:48
-
-
Save dmacvicar/1968448 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def expand_keys(key, value) | |
if File.dirname(key) != "/" | |
return expand_keys(File.dirname(key), { File.basename(key) => value }) | |
else | |
return {File.dirname(key) => { File.basename(key) => value }} | |
end | |
end | |
data = { | |
"unpacked" => { | |
".files" => { | |
"mime" => "text/plain", | |
"sha256" => "uzgc7EfJR9tYpyNn4r8FSWfNahxPdsJBG7Gs9rhlQiY" | |
}, | |
".ldig-unpack.pid" => { | |
"mime" => "text/plain", | |
"sha256" => "3oBDw7Sl4mtSlot8006M5tuKen+fq7ihmnPOhzYmlEw" | |
}, | |
".origin" => { | |
"mime" => "text/plain", | |
"sha256" => "EkLHkyBEpI6hQlsz7pdLXjKSvH0RBgpXfaHSniN+rRw" | |
}, | |
"_service" => { | |
"mime" => "application/xml", | |
"sha256" => "0S_tvzccZNdH7EA9cWZ6VKOaVCiy5dxnjz61efbKhsk" | |
} | |
} | |
} | |
final = data["unpacked"].map do |k, v| | |
expand_keys(File.expand_path(k), v) | |
end | |
require 'pp' | |
pp final |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment