开发宝石时如何使用'调试器'和'撬'? (红宝石) [英] How to use 'debugger' and 'pry' when developing a gem? (Ruby)
问题描述
来源:rubygems
$ b我开发一个gem,并且我的Gemfile如下所示: $ b gemspec
group:development,:test do
gempry
gemdebugger
gemrake
end
但是,我不希望人们必须安装 pry
和 debugger
运行测试时,但我也希望能够在我的测试中要求它们(因为我正在运行带有前缀的测试包exec
,如果它们不在Gemfile中,我无法在我的加载路径中获取它们)。我怎么做到这一点?
另外,何时将gemspec中用于开发的gem以及何时将它们放入Gemfile?我真的不知道其中的区别。
您可以将gemspec添加为开发依赖项,如下所示:
Gem :: Specification.new do | s |
#...
s.add_development_dependency'pry'
s.add_development_dependency'debugger'
s.add_development_dependency'rake'
end
这些只会在安装gem时安装,而不是在安装gem时安装。
I'm developing a gem, and my Gemfile looks like this:
source :rubygems
gemspec
group :development, :test do
gem "pry"
gem "debugger"
gem "rake"
end
However, I don't want people to have to install pry
and debugger
when running tests, but I also want to be able to require them in my tests (because I'm running tests prefixed with bundle exec
, and I cannot get it them in my load path if they're not in the Gemfile). How do I achieve this?
Also, when to put gems that I use for development in the gemspec, and when to put them in the Gemfile? I really don't know the difference.
You can add gems to your gemspec as a development dependency, like this:
Gem::Specification.new do |s|
# ...
s.add_development_dependency 'pry'
s.add_development_dependency 'debugger'
s.add_development_dependency 'rake'
end
These will only be installed when working on the gem and not when installing the gem itself.
这篇关于开发宝石时如何使用'调试器'和'撬'? (红宝石)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!