Skip to content

Instantly share code, notes, and snippets.

@jeffweiss
Last active December 16, 2015 16:29
Show Gist options
  • Save jeffweiss/5463825 to your computer and use it in GitHub Desktop.
Save jeffweiss/5463825 to your computer and use it in GitHub Desktop.
If bundler had a `fetch` command
require 'bundler'
require 'rubygems'
require 'rubygems/gem_runner'
require 'fileutils'
without = [:development, :test]
runner = Gem::GemRunner.new
definition = Bundler::Definition.build('Gemfile', 'Gemfile.lock', nil)
resolver = definition.resolve
lazy_specs = resolver.for(definition.dependencies.reject {|d| (d.groups - without).empty?}, [], false, true).to_a.uniq
FileUtils.mkdir_p 'vendor/cache'
FileUtils.cd 'vendor/cache'
lazy_specs.each do |spec|
runner.run ['fetch', spec.name, '-v', spec.version.to_s]
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment