Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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