Sha256: d07796851da76ac4e63c46a6549ea8b3383b46e2c791e2710a440f119da4a71c

Contents?: true

Size: 1.31 KB

Versions: 18

Compression:

Stored size: 1.31 KB

Contents

# -*- encoding : utf-8 -*-
require 'git_stats/hash_initializable'

module GitStats
  module GitData
    class Author
      include HashInitializable

      attr_reader :repo, :name, :email

      def commits
        @commits ||= repo.commits.select { |commit| commit.author == self }
      end

      def changed_lines
        insertions + deletions
      end

      def insertions
        short_stats.map(&:insertions).sum
      end

      def deletions
        short_stats.map(&:deletions).sum
      end

      def commits_sum_by_date
        sum = 0
        commits.map { |commit|
          sum += 1
          [commit.date, sum]
        }
      end

      [:insertions, :deletions, :changed_lines].each do |method|
        define_method "#{method}_by_date" do
          sum = 0
          commits.map { |commit|
            sum += commit.short_stat.send(method)
            [commit.date, sum]
          }
        end
      end

      def short_stats
        commits.map(&:short_stat)
      end

      def activity
        @activity ||= Activity.new(commits)
      end

      def dirname
        @name.underscore.split.join '_'
      end

      def to_s
        "#{self.class} #@name <#@email>"
      end

      def ==(other)
        [self.repo, self.name, self.email] == [other.repo, other.name, other.email]
      end

    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
git_stats-1.0.17 lib/git_stats/git_data/author.rb
git_stats-1.0.16 lib/git_stats/git_data/author.rb
git_stats-1.0.15 lib/git_stats/git_data/author.rb
git_stats-1.0.14 lib/git_stats/git_data/author.rb
git_stats-1.0.13 lib/git_stats/git_data/author.rb
git_stats-1.0.12 lib/git_stats/git_data/author.rb
git_stats-1.0.11 lib/git_stats/git_data/author.rb
git_stats-1.0.10 lib/git_stats/git_data/author.rb
git_stats-1.0.9 lib/git_stats/git_data/author.rb
git_stats-1.0.8 lib/git_stats/git_data/author.rb
git_stats-1.0.7 lib/git_stats/git_data/author.rb
git_stats-1.0.6 lib/git_stats/git_data/author.rb
git_stats-1.0.5 lib/git_stats/git_data/author.rb
git_stats-1.0.4 lib/git_stats/git_data/author.rb
git_stats-1.0.3 lib/git_stats/git_data/author.rb
git_stats-1.0.2 lib/git_stats/git_data/author.rb
git_stats-1.0.1 lib/git_stats/git_data/author.rb
git_stats-1.0.0 lib/git_stats/git_data/author.rb