Question

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)?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top