我有一个gem,nanoc,我想调试。
其命令行nanoc
执行以下脚本(在/.rvm/gems/ruby-1.9.2-p290/bin中)
#!/usr/bin/env ruby
#
# This file was generated by RubyGems.
#
# The application 'nanoc' is installed as part of a gem, and
# this file is here to facilitate running it.
#
require 'rubygems'
version = ">= 0"
if ARGV.first
str = ARGV.first
str = str.dup.force_encoding("BINARY") if str.respond_to? :force_encoding
if str =~ /\A_(.*)_\z/
version = $1
ARGV.shift
end
end
gem 'nanoc', version
load Gem.bin_path('nanoc', 'nanoc', version)
它本身在最后一行加载解析为(/.rvm/gems/ruby-1.9.2-p290/gems/nanoc-3.6.2/bin)
#!/usr/bin/env ruby
# encoding: utf-8
# Try loading bundler if it's possible
begin
require 'bundler/setup'
rescue LoadError
# no problem
end
# Add lib to load path
$LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
# Load nanoc
require 'nanoc'
require 'nanoc/cli'
# Run base
Nanoc::CLI.run(ARGV)
调试这些脚本的最少侵入性选项是什么? 如果我只是撬开第一个文件,ARGV将是文件名本身..
我是否必须修改文件才能运行调试器?
答案 0 :(得分:2)
或者,您可以只分叉git repo,然后克隆它并使用它的bundle运行gem并以这种方式进行调试:
https://github.com/nanoc/nanoc
克隆存储库,添加调试代码,然后运行bundle exec bin/nanoc
,这样就可以保持本地安装的副本清洁。一旦弄清楚出了什么问题,你就可以构建一个新的gem,安装它,提交代码,然后发出pull请求来为每个人修复它。