Skip to content

Instantly share code, notes, and snippets.

@kwstannard
Created August 18, 2014 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kwstannard/68a3163549138dfac319 to your computer and use it in GitHub Desktop.
Save kwstannard/68a3163549138dfac319 to your computer and use it in GitHub Desktop.
squiggly all your versions
gemfile=File.read("Gemfile")
unversioned = gemfile.scan(/(?<!#)\s+(gem|custom_require) ['"]([\w-]+)['"](?!,.*(\d+\.\d+\.\d+))/)
lockfile = File.read("Gemfile.lock")
puts unversioned.inspect
unversioned.each do |lead, name|
version = lockfile.scan(/#{name} \(((\d+\.?)+)\)/).first.first
gemfile.gsub! /#{lead} ['"]#{name}['"]/, "\\0, '~> #{version}'"
end
puts gemfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment