Question

Ok, as @tim-moore asked, I will post it in new question.

Ok, so I wanted to make gem using bundle. Pry extension gem require that gem start with pry- as mentioned here. I used:

bundle gem pry-name

but it messed up my file structure

create  pry-name/pry-name.gemspec
create  pry-name/lib/pry/name.rb
create  pry-name/lib/pry/name/version.rb

As you can see it created lib/pry directory. I know it's gem's style to created such structure but now I pry cannot load this gem automatically

One solution from my question was:

create pry-name.rb that contain only require 'pry/name'

After I have done this, and build gem, I started pry: This message appear:

require 'pry-name' # Failed, saying: Pry is not a module

As for my guesses:

I'm creating commands writing something like this:

Pry::Commands.create_command "name-of-command" do 
  # my code goes here
end

and, as ruby find Pry::Commands. it want require it from lib directory not from Pry gem.

What does this error mean. Why it doesn't work. How make it work keeping in mind gem and pry requirements(pry gem starts with pry- and gem will create another directory(ies) when someone use - for example: gem pry-name will make pry/name)

Was it helpful?

Solution

Everywhere in your newly-created gem where it has module Pry, change it to: class Pry. Since Pry is already defined (as a class), you cannot redefine/reopen it as a module.

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