Class: GitStats::GitData::Author

Inherits:
Object
  • Object
show all
Includes:
HashInitializable
Defined in:
lib/git_stats/git_data/author.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HashInitializable

#initialize

Instance Attribute Details

#emailObject (readonly)

Returns the value of attribute email


9
10
11
# File 'lib/git_stats/git_data/author.rb', line 9

def email
  @email
end

#nameObject (readonly)

Returns the value of attribute name


9
10
11
# File 'lib/git_stats/git_data/author.rb', line 9

def name
  @name
end

#repoObject (readonly)

Returns the value of attribute repo


9
10
11
# File 'lib/git_stats/git_data/author.rb', line 9

def repo
  @repo
end

Instance Method Details

#==(other) ⇒ Object


61
62
63
# File 'lib/git_stats/git_data/author.rb', line 61

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

#activityObject


49
50
51
# File 'lib/git_stats/git_data/author.rb', line 49

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

#changed_linesObject


15
16
17
# File 'lib/git_stats/git_data/author.rb', line 15

def changed_lines
  insertions + deletions
end

#commitsObject


11
12
13
# File 'lib/git_stats/git_data/author.rb', line 11

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

#commits_sum_by_dateObject


27
28
29
30
31
32
33
# File 'lib/git_stats/git_data/author.rb', line 27

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

#deletionsObject


23
24
25
# File 'lib/git_stats/git_data/author.rb', line 23

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

#dirnameObject


53
54
55
# File 'lib/git_stats/git_data/author.rb', line 53

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

#insertionsObject


19
20
21
# File 'lib/git_stats/git_data/author.rb', line 19

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

#short_statsObject


45
46
47
# File 'lib/git_stats/git_data/author.rb', line 45

def short_stats
  commits.map(&:short_stat)
end

#to_sObject


57
58
59
# File 'lib/git_stats/git_data/author.rb', line 57

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