Sha256: 4a70b38ec8907fd4a50f61c4f11d24ac446e99415ff3e68f26e5177042abf608

Contents?: true

Size: 1.12 KB

Versions: 7

Compression:

Stored size: 1.12 KB

Contents

# -*- encoding : utf-8 -*-
module GitStats
  module StatsView
    module Charts
      class AuthorsCharts
        def initialize(authors)
          @authors = authors
        end

        def commits_sum_by_author_by_date(limit = 4, authors = nil)
          Chart.new do |f|
            f.multi_date_chart(
                data: (authors || @authors.sort_by { |author| -author.commits.size }[0..limit]).map { |author| {name: author.name, data: author.commits_sum_by_date} },
                title: :lines_by_date.t,
                y_text: :lines.t
            )
          end
        end

        [:insertions, :deletions, :changed_lines].each do |method|
          define_method "#{method}_by_author_by_date" do |limit = 4, authors = nil|
            Chart.new do |f|
              f.multi_date_chart(
                  data: (authors || @authors.sort_by { |author| -author.send(method) }[0..limit]).map { |author| {name: author.name, data: author.send("#{method}_by_date")} },
                  title: :lines_by_date.t,
                  y_text: :lines.t
              )
            end
          end
        end

      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
git_stats-1.0.11 lib/git_stats/stats_view/charts/authors_charts.rb
git_stats-1.0.10 lib/git_stats/stats_view/charts/authors_charts.rb
git_stats-1.0.9 lib/git_stats/stats_view/charts/authors_charts.rb
git_stats-1.0.8 lib/git_stats/stats_view/charts/authors_charts.rb
git_stats-1.0.7 lib/git_stats/stats_view/charts/authors_charts.rb
git_stats-1.0.6 lib/git_stats/stats_view/charts/authors_charts.rb
git_stats-1.0.5 lib/git_stats/stats_view/charts/authors_charts.rb