Rugged gem has a way to do it.
require 'rugged'
repo = Rugged::Repository.new('git-project-dir')
walker = Rugged::Walker.new(repo)
walker.sorting(Rugged::SORT_TOPO | Rugged::SORT_REVERSE)
walker.push(repo.head.target)
walker.count { |c| c.author[:email] == "<user_email>" }
=> 52
Without using any gem, a shell command from your git repo directory can get you the total number of commits for an user:
`git shortlog -s -n --all| grep <user> | cut -f1`