1、安装ruby
下载安装ruby,需要安装gcc(缺少gcc configure会提示 error: no acceptable C compiler found in $PATH)
进入官网http://www.ruby-lang.org/en/downloads/,根据自己的系统进行选择下载即可,在这里我选择的是2.5版本,
首先安装以下依赖包
yum install gcc
yum install openssl-devel -y
yum install zlib -y
tar xvf ruby-2.5.0.tar.gz
cd ruby-2.5.0
./configure --prefix=/usr/local/ruby
make && make install
检查版本顺便检验是否安装成功
[root@localhost ruby-2.5.0]# ruby -v
-bash: ruby: command not found
配置环境变量 vi /etc/profile
#set rubby
export PATH=$PATH:/usr/local/ruby/bin
使配置生效 source /etc/profile
再次检查ruby版本
[root@localhost ruby-2.5.0]# ruby -v
ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-linux]
2、使用gem安装git_stats
gem install git_stats
更换国内镜像源,并删除原来镜像
gem source --add https://gems.ruby-china.com
gem source -r https://rubygems.org/
gem source -l
[root@localhost ruby-2.5.0]# gem source --add https://gems.ruby-china.com
https://gems.ruby-china.com added to sources
[root@localhost ruby-2.5.0]# gem source -r https://rubygems.org/
[root@localhost ruby-2.5.0]# gem source -l
*** CURRENT SOURCES ***
https://gems.ruby-china.com
更新源 gem update
检查是否成功
git_stats
[root@localhost ruby-2.5.0]# git_stats
Commands:
git_stats generate # Generates the statistics of a repository
git_stats help [COMMAND] # Describe available commands or one specific command
3、使用
切换到git项目目录
git_stats generate -o stats --language zh_tw
执行成功后生成stats目录,可配置nginx连接访问,或者本地访问
docker run --name some-nginx -p 8001:80 -v $PWD/stats:/usr/share/nginx/html:ro -d nginx
IP+8001 即可访问
4、简体中文
4.1备份 /usr/local/ruby/lib/ruby/gems/2.5.0/gems/git_stats-1.0.17/locales 目录
MV /usr/local/ruby/lib/ruby/gems/2.5.0/gems/git_stats-1.0.17/locales /usr/local/ruby/lib/ruby/gems/2.5.0/gems/git_stats-1.0.17/locales-bak
4.2 下载源代码
git clone https://github.com/tomgi/git_stats.git
源代码中的locales 放到/usr/local/ruby/lib/ruby/gems/2.5.0/gems/git_stats-1.0.17/config 目录
进入locales/config目录,备份zh_tw.yml 修改zh.yml名称为zh_tw.yml
mv zh_tw.yml zh_tw.yml+bak
cp zh.yml zh_tw.yml
再次去项目目录下执行
git_stats generate -o stats --language zh_tw