builder/extra/cluster-home/samples/bin/CLI_API.rb
def show_structure(hash, indent = 0)
        line_prefix = ''
        indent.times { line_prefix += ' ' }
        hash.each { |k,v|
            nested = false
            key_suffix = ''
            closing = ''
            if v.is_a? Hash 
                nested = true
                key_suffix= ' {' if ENV["SHOW_BRACES"]
                closing='}'  if ENV["SHOW_BRACES"]
            end
            if v.is_a? Array
                nested = true
                key_suffix= ' ['
                closing = ']'
            end
            if indent == 0 or nested or ENV["ALL_FIELDS"]
                puts "#{line_prefix} #{k}#{key_suffix}"
            end
            if nested
                show_structure(v, indent+2)
                puts " #{line_prefix}#{closing}" if ENV["SHOW_BRACES"]
            end
        }
    end
#
# prints the outline of a hash structure
#
# If environment variable ALL_FIELDS is set, then it prints all fields,
# otherwise it only prints the fields at the top leven and the ones that have nested contents
#
# IF the environment variable SHOW_BRACES is set, then it also prints braces (or brackets) 
# around the inner structure
#
prints the outline of a hash structure
If environment variable ALL_FIELDS is set, then it prints all fields,
otherwise it only prints the fields at the top leven and the ones that have nested contents

IF the environment variable SHOW_BRACES is set, then it also prints braces (or brackets)
around the inner structure
prints the outline of a hash structure If environment variable ALL_FIELDS is set then it prints all fields otherwise it only prints the fields at the top leven and the ones that have nested contents IF the environment variable SHOW_BRACES is set then it also prints braces ( or brackets ) around the inner structure
def show_structure(hash, indent = 0)
        line_prefix = ''
        indent.times { line_prefix += ' ' }
        hash.each { |k,v|
            nested = false
            key_suffix = ''
            closing = ''
            if v.is_a? Hash 
                nested = true
                key_suffix= ' {' if ENV["SHOW_BRACES"]
                closing='}'  if ENV["SHOW_BRACES"]
            end
            if v.is_a? Array
                nested = true
                key_suffix= ' ['
                closing = ']'
            end
            if indent == 0 or nested or ENV["ALL_FIELDS"]
                puts "#{line_prefix} #{k}#{key_suffix}"
            end
            if nested
                show_structure(v, indent+2)
                puts " #{line_prefix}#{closing}" if ENV["SHOW_BRACES"]
            end
        }
    end
def show_structure ( hash , indent = 0 ) line_prefix = '' indent . times { line_prefix += ' ' } hash . each { | k , v | nested = false key_suffix = '' closing = '' if v . is_a? Hash nested = true key_suffix = ' {' if ENV [ "SHOW_BRACES" ] closing = '}' if ENV [ "SHOW_BRACES" ] end if v . is_a? Array nested = true key_suffix = ' [' closing = ']' end if indent == 0 or nested or ENV [ "ALL_FIELDS" ] puts "#{line_prefix} #{k}#{key_suffix}" end if nested show_structure ( v , indent + 2 ) puts " #{line_prefix}#{closing}" if ENV [ "SHOW_BRACES" ] end } end
prints the outline of a hash structure
If environment variable ALL_FIELDS is set, then it prints all fields,
otherwise it only prints the fields at the top leven and the ones that have nested contents
prints the outline of a hash structure If environment variable ALL_FIELDS is set then it prints all fields otherwise it only prints the fields at the top leven and the ones that have nested contents
hash
indent