Sha256: 5f5ec925ba999e70e020bfc432ab74f4a0139ac641741569b2cf4c07b4ecb556

Contents?: true

Size: 1.27 KB

Versions: 2

Compression:

Stored size: 1.27 KB

Contents

#!/usr/bin/env ruby

require 'bundler/setup'
require 'trollop'

options = Trollop::options do
  opt :patch, 'Generate patch.', short: 'p'
  opt :ruby_version, 'Parser Ruby version (18, 19, 20, 21)', default: 'current'
  opt :max_count, 'Limit the number of commits to output.', type: :integer, short: 'n'
  opt :stop_at_latest_introduction_of_method, 'Stop at lastest introduction of method.', default: true
end

case ruby_version = options[:ruby_version]
when 'current'
  require 'parser/current'
when '18', '19', '20', '21'
  require 'parser/ruby18'
  require 'parser/ruby19'
  require 'parser/ruby20'
  require 'parser/ruby21'
  Parser::CurrentRuby = Parser.const_get("Ruby#{ruby_version}")
else
  raise "Ruby version not supported: #{ruby_version}"
end

require 'method_log'
require 'method_log/repository'
require 'method_log/api'

repository = MethodLog::Repository.new(Dir.pwd)
api = MethodLog::API.new(repository)
api.diffs(ARGV[0], options).each do |method_commit, method_diff|
  puts "commit #{method_commit.sha}"
  puts "Author: #{method_commit.author[:name]} <#{method_commit.author[:email]}>"
  puts "Date:   #{method_commit.author[:time].strftime('%a %b %-e %T %Y %z')}"
  puts
  puts method_commit.message
  puts
  if options[:patch]
    puts method_diff.to_s(:color)
    puts
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
method_log-0.0.7 bin/method_log
method_log-0.0.6 bin/method_log