Skip to content

Instantly share code, notes, and snippets.

@wr0ngway
Created July 11, 2014 11:03
Show Gist options
  • Save wr0ngway/d2746d23f0d74aa6b7dc to your computer and use it in GitHub Desktop.
Save wr0ngway/d2746d23f0d74aa6b7dc to your computer and use it in GitHub Desktop.
Wrapper to bundle that lets one temporarily point to local directories for gems (works better with rubymine than bundle local)
#!/usr/bin/env ruby
require 'rubygems'
require 'bundler'
raise "Pass in local gems like: LOCAL_GEMS=foo,bar bundle ..." unless ENV['LOCAL_GEMS']
LOCAL_GEMS = ENV['LOCAL_GEMS'].split(',')
class Bundler::Dsl
alias orig_eval_gemfile eval_gemfile
def eval_gemfile(gemfile, contents = nil)
@bl_gemfile = gemfile
orig_eval_gemfile(gemfile, contents)
end
alias orig_gem gem
def gem(name, *args)
if LOCAL_GEMS.include?(name)
path = File.expand_path("../../#{name}", @bl_gemfile)
if File.exist?(path)
if args.last.is_a?(Hash)
opts = args.pop
else
opts = {}
end
opts.delete(:git)
opts[:path] = path
args << opts
else
$stderr.puts "No local gem for #{name}"
end
end
orig_gem(name, *args)
end
end
load Gem.bin_path('bundler', 'bundle')
@townie
Copy link

townie commented Dec 16, 2014

comment test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment