Skip to content

Instantly share code, notes, and snippets.

@mwmitchell
Created June 16, 2009 16:01
Show Gist options
  • Save mwmitchell/130755 to your computer and use it in GitHub Desktop.
Save mwmitchell/130755 to your computer and use it in GitHub Desktop.
# source objects
[
{:id=>1, :path=>'a::poems::one::1'},
{:id=>2, :path=>'a::poems::one::2'},
{:id=>3, :path=>'a::poems::one::3'},
{:id=>4, :path=>'a::poems::one::4'},
{:id=>5, :path=>'a::poems::two::1'},
{:id=>6, :path=>'a::poems::two::2'},
{:id=>7, :path=>'a::poems::two::3'},
{:id=>8, :path=>'a::poems::two::4'}
]
# composite output
[
{:label=>'a', :children=>[
{:label=>'poems', :children=>[
{:label=>'one', :children=>[
{:label=>'1', :id=>1},
{:label=>'2', :id=>2},
{:label=>'3', :id=>3},
{:label=>'4', :id=>4}
]},
{:label=>'two', :children=>[
{:label=>'1', :id=>5},
{:label=>'2', :id=>6},
{:label=>'3', :id=>7},
{:label=>'4', :id=>8}
]}
]}
]}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment