Class: Babygitter::RepoAnalyzer::Author

Inherits:
Object
  • Object
show all
Includes:
DateTimeArrays
Defined in:
lib/babygitter/repo_analyzer/author.rb

Overview

An Author contains the basic informtion for an author of a Branch in a git repository

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from DateTimeArrays

#create_52_week_map, #create_active_date_array

Constructor Details

#initialize(commits) ⇒ Author

Returns a new instance of Author.



10
11
12
13
14
15
16
# File 'lib/babygitter/repo_analyzer/author.rb', line 10

def initialize(commits)
  @name = commits.first.author.name
  @commits = commits
  @total_committed = commits.size
  @began = commits.last
  @latest_commit = commits.first
end

Instance Attribute Details

#beganObject

Returns the value of attribute began.



8
9
10
# File 'lib/babygitter/repo_analyzer/author.rb', line 8

def began
  @began
end

#commitsObject

Returns the value of attribute commits.



8
9
10
# File 'lib/babygitter/repo_analyzer/author.rb', line 8

def commits
  @commits
end

#latest_commitObject

Returns the value of attribute latest_commit.



8
9
10
# File 'lib/babygitter/repo_analyzer/author.rb', line 8

def latest_commit
  @latest_commit
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/babygitter/repo_analyzer/author.rb', line 8

def name
  @name
end

#total_committedObject

Returns the value of attribute total_committed.



8
9
10
# File 'lib/babygitter/repo_analyzer/author.rb', line 8

def total_committed
  @total_committed
end

Instance Method Details

#create_bar_data_pointsObject

Inserts the commits into the correct array for use in gruff graph

  • creates the variable week_map through the method create_52_week_map

  • creates an array of 52 zeros

  • using the index of where the commit can be found in week map it adds 1 to number found in at that index in plot_array

TODO put this in it’s own module?



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/babygitter/repo_analyzer/author.rb', line 23

def create_bar_data_points 
  week_map = create_52_week_map
  points_array = Array.new(52, 0)
  for commit in @commits
    unless week_map.index(commit.date.strftime("%U %Y")) == nil
      index = week_map.index(commit.date.strftime("%U %Y"))
      points_array[index] +=1
    end
  end
  points_array
end

#inspectObject



35
36
37
# File 'lib/babygitter/repo_analyzer/author.rb', line 35

def inspect
    %Q{#<Babygitter::Author #{@name}>}
end