The problem with
gemspec arises when you need to extract something raw as a gem (for example, stand alone Rails app one day becomes Rails mountable engine) you have to change your usual dependency management workflow. Old good
bundle install is not enough anymore.
Let's say, you have a project with
Gemfile full of gems. What you gonna do if you need to reference this project in another project?
First of all, create
project.gemspec file. Look at the Bundler docs.
bundle gem my_gem
You have to reference your
gemspec inside the
Gemfile like this:
Every gem you had in the
Gemfile as a dependency should now reside inside the
gemspec file like this:
Gem::Specification.new do |s|
s.add_dependency "how-cute-and-adorable", "= 0.3.2"
bundle install command install all required gems before moving to the next step.
Every gem has to autoload his own dependencies by hand. Let's say, in your
lib directory you have
project.rb you have to add every single gem you have in dependencies. Be especially carefull if gem's name does not match to what you actually need to require: