Ruby Gemspec Dependency: Is Possible Have a Git Branch Dependency

Ruby Gemspec Dependency: Is possible have a git branch dependency?

This is not possible, and likely never will be because it would be rather heavy-handed for RubyGems to allow gem developers to require that users have a specific version control system installed to access a gem. Gems should be self-contained with a minimal number of dependencies so that people can use them in as wide an array of application as possible.

If you want to do this for your own internal projects, my suggestion would be to use Bundler which supports this quite well.

How do i use a dependency from github in my gemspec?

As stated in the gem specification, the list of gems that you provide through add_dependency will be used to make sure those are already installed in the system during the installation process (i.e gem install), hence a git option wouldn't make sense since this doesn't trigger any additional installation of any dependencies (like Bundler does).

In summary: it's not possible to do what you're trying to do within a .gemspec

Getting dependencies of git repo without .gemspec with bundler

You can't. How would bundler know the dependencies when .gemspec is where the dependencies are supposed to be found.

If you look at the heckle Rakefile you will see:

dependency 'ruby_parser', '~> 2.3.1'
dependency 'ruby2ruby', '~> 1.3.0'
dependency 'ZenTest', '~> 4.7.0'

You just have to add those manually to your Gemfile:

gem 'ruby_parser', '~> 2.3.1'
gem 'ruby2ruby', '~> 1.3.0'
gem 'ZenTest', '~> 4.7.0'

how to add gem dependency with :path and :branch

You definitely want to use Bundler then. You would put exactly what you have into the Gemfile file. Go checkout the link to Bundler I left below.

-- older info --

For jeweler you would add something like this:

gem.add_dependency 'authlogic', '> 1.0', '<= 2.0'

But you might be better off using Bundler. It's not just for rails: http://gembundler.com/



Related Topics



Leave a reply



Submit