class Twigg::Commit

Attributes

author[R]
body[R]
commit[R]
date[R]
repo[R]
stat[R]
subject[R]

Public Class Methods

new(options) click to toggle source
# File lib/twigg/commit.rb, line 5
def initialize(options)
  raise ArgumentError unless @repo    = options[:repo]
  raise ArgumentError unless @commit  = options[:commit]
  raise ArgumentError unless @subject = options[:subject]
  raise ArgumentError unless @body    = options[:body]
  raise ArgumentError unless @author  = options[:author]
  raise ArgumentError unless @date    = options[:date]
  raise ArgumentError unless @stat    = options[:stat]
end

Public Instance Methods

author_names() click to toggle source
# File lib/twigg/commit.rb, line 21
def author_names
  @author.split(/\+|&|,|\band\b/).map(&:strip)
end
eql?(other) click to toggle source
# File lib/twigg/commit.rb, line 25
def eql?(other)
  other.is_a?(Commit)         &&
    other.repo    == @repo    &&
    other.commit  == @commit  &&
    other.subject == @subject &&
    other.body    == @body    &&
    other.author  == @author  &&
    other.date    == @date    &&
    other.stat    == @stat
end
filtered_commit_message() click to toggle source
# File lib/twigg/commit.rb, line 36
def filtered_commit_message
  @filtered_commit_message ||= @body.reject do |line|
    line =~ /^[a-z-]+: /i # filter out Change-Id:, Signed-off-by: etc
  end.concat([@subject]).join("\n").chomp
end
flesch_reading_ease() click to toggle source
# File lib/twigg/commit.rb, line 42
def flesch_reading_ease
  @flesch_reading_ease ||= Flesch.new(filtered_commit_message).reading_ease
end
inspect() click to toggle source
# File lib/twigg/commit.rb, line 51
def inspect
  "repo: #{@repo.name}\n" +
    "commit: #{@commit}\n" +
    "subject: #{@subject}\n" +
    "author: #{@author}\n" +
    "stat: +#{@stat[:additions]}, -#{@stat[:deletions]}"
end
russianness() click to toggle source

Return the length of the commit message in lines.

# File lib/twigg/commit.rb, line 47
def russianness
  filtered_commit_message.lines.count
end