问题
As explained here pry's plugin require pry- prefix. I have tried building using bundler:
bundle gem pry-name
but it messed up directory hierarchies(creating 2 instead of 1 directory):
create pry-name/pry-name.gemspec
create pry-name/lib/pry/name.rb
create pry-name/lib/pry/name/version.rb
In the gemspec it is using wrong directory structure:
require 'pry/name/version'
and in the same file it run this git command:
spec.files = `git ls-files`.split($/)
which gives, same as above, wrong structure of files
Is there way to tell bundler to recognize "-" as valid filename character not as "/"(directory separator)?
回答1:
bundle gem
works according to the Rubygems convention for naming gems, as described at http://guides.rubygems.org/name-your-gem/
Note that if you include gem 'pry-name'
in the Gemfile
of a project that uses Bundler.require
, it will use the convention there by default, too, and try to require 'pry/name'
.
The best workaround is to create a lib/pry-name.rb
file that just contains require 'pry/name'
. This keeps your directory structure consistent with the Rubygems & Bundler convention, allowing require 'pry/name'
to work, while also allowing require 'pry-name'
to work.
来源:https://stackoverflow.com/questions/19747814/building-pry-plugingem-with-bundler