0.0
No commit activity in last 3 years
No release in over 3 years
A hack for using shorthand like `:github => 'ambethia/recaptcha'` instead of a full git repository URI in your Gemfiles
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Development

>= 0

Runtime

 Project Readme

bundler-github

Use shorthand instead of full Github repository URIs in your Gemfile.

Oh, yes... syntactic sugars!

Installation

gem install bundler-github

Note: Currently, this gem must always be installed after Bundler. If you update or re-install Bundler, you'll need to re-install this gem. See the caveat below for details.

Usage

In your Gemfile you can now replace:

gem 'recaptcha', git: 'https://github.com/ambethia/recaptcha.git'

with:

gem 'recaptcha', github: 'ambethia/recaptcha'

But wait! That sugar only gets sweeter! If the repository's name is the same as the gem's name (and it usally is), you can leave out the repo name and just include the repository owner.

gem 'recaptcha', github: 'ambethia'

How you like them apples!?

One inconvenience I haven't figured a work around for is that you'll need to explicitly require bundler/github before you require bundler/setup. In a Rails app you might change your boot.rb (oh, the humanity!) from:

require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])

to look like:

if File.exists?(ENV['BUNDLE_GEMFILE'])
  require 'bundler/github'
  require 'bundler/setup'
end

However, you don't need to require bundler-github from your Gemfile, it's already loaded by the time your application's Gemfile is read anyways.

Private Repositories

By default HTTP transport is used, but you can switch to an authenticated url scheme (ssh) by prepending a : to the account name, like:

gem 'has_secrets', github: ':ambethia'

Other notes on usage

  • bundler-github just catches and replaces the :github option with :git after expanding the URI, other options, like :branch, :ref, etc. will be left untouched. Also, any gems that just use :git don't altered either.
  • I may favor the Ruby 1.9 syntaxes in my examples, but the gem does not. It was developed for and tested against 1.8.7 and 1.9.x.

Caveat emptor!

You coveteth my ice cream bar...

I have no idea if this is going to work for you, in your environment. It's beta-quality software, and as such should not be considered production ready.

The only way I could find to hook in and add the :github option was to make my own bundle command which replaces the executable generated by Rubygems in your $PATH. The new command includes our patch then loads Bunder's original bundle command. For a hack, I think it's pretty elegant.

The unique way bundler is used makes it challenging to extend without any kind of plugin API. If you can suggest a better way to hook it without needing to modify the original gem, I'd love to hear it.

Copyright

Copyright © 2011 Jason L Perry. See MIT-LICENSE for the rights reserved.