Skip to content

Instantly share code, notes, and snippets.

@myabc
Created March 11, 2012 14:37
Show Gist options
  • Save myabc/2016633 to your computer and use it in GitHub Desktop.
Save myabc/2016633 to your computer and use it in GitHub Desktop.
namespace :bundle do
def with_gemfile(gemfile)
old_gemfile = ENV['BUNDLE_GEMFILE']
ENV['BUNDLE_GEMFILE'] = gemfile
yield
ENV['BUNDLE_GEMFILE'] = old_gemfile
end
task :install do
`bundle install`
end
desc 'Create or update Gemfile.local, to work against locally checked out repos'
task :local_gemfile do
gemfile = File.read('Gemfile')
gemfile.gsub!(/git: ["']git@github\.com:payango\/([\w-]+)\.git["']/, 'path: \'../\1\'')
File.open('Gemfile.local', 'w') { |file| file.write(gemfile) }
end
desc 'Run bundle install with Gemfile.local'
task local_install: :local_gemfile do
with_gemfile('Gemfile.local') do
`bundle install`
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment