class Macblame::Main

Public Instance Methods

run_app() click to toggle source
# File lib/macblame.rb, line 5
def run_app
        if ARGV.length == 0
                print_general_message
        else
                ARGV.each do |name|
                        macblame(name)
                end
        end
end

Private Instance Methods

macblame(file_name) click to toggle source
# File lib/macblame.rb, line 16
def macblame(file_name)
         contributor = {}
         output = open("| git blame "+file_name)
         feed = output.read()
         lines = feed.split("\n")
         loc = lines.length
         lines.each do |line|
                 tokens = line.split("(")
                 name = tokens[1].split(" ")[0]
                 if contributor[name].nil?
                         contributor[name] = 1
                 else
                         contributor[name] += 1
                 end
         end
         sorted_hash = contributor.sort.sort do |a,b|
                 b[1] <=> a[1]
         end
         print "for file #{file_name}.. \n"
         sorted_hash.each do |i|
                 if i[0] == "Not"
                         print_info("not yet committed",i[1],loc)
                 else
                         print_info(i[0],i[1],loc)
                 end
         end
         puts "* "*25
 end
print_general_message() click to toggle source
print_info(name,loc,commits) click to toggle source