lib/loquacious/configuration/help.rb in loquacious-1.3.1 vs lib/loquacious/configuration/help.rb in loquacious-1.4.0

- old
+ new

@@ -17,10 +17,11 @@ :io => $stdout, :name_leader => ' - '.freeze, :name_length => 0, :name_value_sep => ' => '.freeze, :desc_leader => ' '.freeze, + :nesting_nodes => true, :colorize => false, :colors => { :name => :white, :value => :cyan, :description => :green, @@ -39,10 +40,13 @@ # :name_leader String appearing before the attribute name # :name_length Maximum length for an attribute name # :name_value_sep String separating the attribute name from the value # :desc_leader String appearing before the description # :io The IO object where help will be written + # :nesting_nodes Flag to enable or disable output of nesting nodes + # (this does not affect display of attributes + # contained by the nesting nodes) # :colorize Flag to colorize the output or not # :colors Hash of colors for the name, value, description # :name Name color # :value Value color # :description Description color @@ -57,10 +61,11 @@ ::Loquacious::Configuration.for(config) @io = opts[:io] @name_length = Integer(opts[:name_length]) @desc_leader = opts[:desc_leader] + @nesting_nodes = opts[:nesting_nodes] @colorize = opts[:colorize] @colors = opts[:colors] unless @name_length > 0 Iterator.new(@config).each do |node| @@ -104,10 +109,19 @@ # def colorize? @colorize end + # Returns +true+ if the help instance is configured to show nesting + # configuration nodes when iterating over the attributes. This only + # prevents the nesting node name from being displayed. The attributes + # nested under the node are still displayed regardless of this setting. + # + def show_nesting_nodes? + @nesting_nodes + end + # call-seq: # show_attribute( name = nil, opts = {} ) # # Use this method to show the description for a single attribute or for # all the attributes if no _name_ is given. The options allow you to @@ -128,9 +142,10 @@ show_description = opts[:descriptions] show_value = opts[:values] Iterator.new(@config).each do |node| next unless rgxp =~ node.name + next if !show_nesting_nodes? and node.config? print_node(node, show_description, show_value) end end alias :show :show_attribute