chef-server-slice/app/helpers/nodes_helper.rb
# Recursively build a tree of lists.
Recursively build a tree of lists.
Recursively build a tree of lists .
def build_tree(node)
        list = "<dl>"
        list << "\n<!-- Beginning of Node Tree -->"
        walk = lambda do |key,value|
          case value
            when Hash, Array
              list << "\n<!-- Beginning of Enumerable obj -->"
              list << "\n<dt>#{key}</dt>"
              list << "<dd>"
              list << "\t<dl>\n"
              value.each(&walk)
              list << "\t</dl>\n"
              list << "</dd>"
              list << "\n<!-- End of Enumerable obj -->"
            else
              list << "\n<dt>#{key}</dt>"
              list << "<dd>#{value}</dd>"
          end
        end
        node.attribute.sort{ |a,b| a[0] <=> b[0] }.each(&walk)
        list << "</dl>"
      end
def build_tree ( node ) list = "<dl>" list << "\n<!-- Beginning of Node Tree -->" walk = lambda do | key , value | case value when Hash , Array list << "\n<!-- Beginning of Enumerable obj -->" list << "\n<dt>#{key}</dt>" list << "<dd>" list << "\t<dl>\n" value . each ( & walk ) list << "\t</dl>\n" list << "</dd>" list << "\n<!-- End of Enumerable obj -->" else list << "\n<dt>#{key}</dt>" list << "<dd>#{value}</dd>" end end node . attribute . sort { | a , b | a [ 0 ] <=> b [ 0 ] } . each ( & walk ) list << "</dl>" end
Recursively build a tree of lists.
Recursively build a tree of lists .
node
<not_specific>