Created
July 11, 2014 11:03
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
comment