class Git::Log

Git::Log parses output passed from Git#log and creates a hash with author as a key and email as value

Public Class Methods

new(log) click to toggle source

We are expecting output from “git log” command

# File lib/jekyll-git-authors/git.rb, line 5
def initialize(log)
  @log = log
end

Public Instance Methods

author_email() click to toggle source

Iterate through each line in the log filter out whitespace characters, split the line by semicolon assign the returned pair (i.e. author and email) to author and email variables then create hash with author as key and email as value and return it. Return from function if we have 5 authors

# File lib/jekyll-git-authors/git.rb, line 14
def author_email
  author_email = Hash.new
  @log.each_line do |line|
    author, mail = line.strip.split(';')

    author_email[author] = mail unless author_email.key?(author)

    return author_email if author_email.size == 5
  end
  author_email
end
to_s() click to toggle source

To ensure log will be text when we want

# File lib/jekyll-git-authors/git.rb, line 27
def to_s
  @log
end