<commit_before># Methods added to this helper will be available to all templates in the application.
module ApplicationHelper

  # display a summary of a model instance, using the partial in <plural_class>/_summary.html.haml
  def summarize(instance)
    raise "Cannot summarize an empty object" unless instance
    klass = instance.class.name.underscore
    render :partial => "#{klass.pluralize}/summary", :locals => { klass.to_sym => instance }
  end

  # the minimal linked description of a model instance
  def brief(instance)
    raise "Cannot give a brief version of an empty object" unless instance
    link_to(instance.respond_to?(:name) ? instance.name : instance.to_s, instance)
  end
  
  # a readable list of brief versions of the provided model instances
  def list(*instances)
    return '' if instances.blank?
    instances.flatten.collect {|i| brief(i) }.join(", ")
  end
  
  def display_tree(tree)
    return '' if tree.blank?
    content_tag(:ul) do
      tree.inject('') do |buffer, node|
        if buffer.is_a?(Array)
          buffer << display_tree(node)
        else
          buffer << content_tag(:li, brief(node))
        end
        buffer
      end
    end
  end
end

__END__

[ x, y, z ]

[ x, [ a, b ], y, z, [ w ]]
<commit_msg>removing __END__ commentary in application helper<commit_after># Methods added to this helper will be available to all templates in the application.
module ApplicationHelper

  # display a summary of a model instance, using the partial in <plural_class>/_summary.html.haml
  def summarize(instance)
    raise "Cannot summarize an empty object" unless instance
    klass = instance.class.name.underscore
    render :partial => "#{klass.pluralize}/summary", :locals => { klass.to_sym => instance }
  end

  # the minimal linked description of a model instance
  def brief(instance)
    raise "Cannot give a brief version of an empty object" unless instance
    link_to(instance.respond_to?(:name) ? instance.name : instance.to_s, instance)
  end
  
  # a readable list of brief versions of the provided model instances
  def list(*instances)
    return '' if instances.blank?
    instances.flatten.collect {|i| brief(i) }.join(", ")
  end
  
  def display_tree(tree)
    return '' if tree.blank?
    content_tag(:ul) do
      tree.inject('') do |buffer, node|
        if buffer.is_a?(Array)
          buffer << display_tree(node)
        else
          buffer << content_tag(:li, brief(node))
        end
        buffer
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.09453530115676106, 'fraction_numerical': 0.0, 'mean_word_length': 3.125, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5916149', 'n_tokens_mistral': 734, 'n_tokens_neox': 730, 'n_words': 261}