Skip to content

Instantly share code, notes, and snippets.

@MSch
Created November 22, 2010 18:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save MSch/710395 to your computer and use it in GitHub Desktop.
Save MSch/710395 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
gems = Gem.source_index.search(Gem::Dependency.new(//, Gem::Requirement.default))
gems.each do |gem|
puts "gem '#{gem.name}', '#{gem.version.to_s}'"
end
$ gem list
*** LOCAL GEMS ***
bundler (1.0.7)
rack (1.0.1)
rake (0.8.7)
sqlite3-ruby (1.3.2)
xml-simple (1.0.12)
$ gems2gemfile
gem 'bundler', '1.0.7'
gem 'rack', '1.0.1'
gem 'rake', '0.8.7'
gem 'sqlite3-ruby', '1.3.2'
gem 'xml-simple', '1.0.12'
>> Copy and paste into Gemfile
@MSch
Copy link
Author

MSch commented Nov 22, 2010

I had a simple problem. I just set up a legacy Rails 2.3 app and spent the whole afternoon hunting down dependencies. Since I used rvm, my gemset contained exactly the dependencies I needed. Now I wanted to turn that gemset into a Gemfile.

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