Class: Twigg::CommitSetDecorator

Inherits:
Decorator show all
Includes:
Util
Defined in:
lib/twigg/commit_set_decorator.rb

Instance Method Summary collapse

Methods included from Util

inflections

Methods inherited from Decorator

#initialize, #method_missing

Constructor Details

This class inherits a constructor from Twigg::Decorator

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Twigg::Decorator

Instance Method Details

#breakdown(html: true) ⇒ Object

Returns a per-repo breakdown (repo names, commit counts) of commits in the decorated Twigg::CommitSet.

Returns HTML output by default, or plain-text when ‘html` is `false`.



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/twigg/commit_set_decorator.rb', line 9

def breakdown(html: true)
  commit_set.count_by_repo.map do |data|
    if html && (link = data[:repo].link)
      name = %{<a href="#{link}">#{data[:repo].name}</a>}
    else
      name = data[:repo].name
    end

    if html
      "<i>#{name}:</i> <b>#{number_with_delimiter data[:count]}</b>"
    else
      "#{name}: #{number_with_delimiter data[:count]}"
    end
  end.join(', ')
end