Building pry plugin(gem) with bundler

瘦欲@ 提交于 2019-12-24 13:16:38

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!