Created
January 1, 2015 18:39
-
-
Save lime/b31297a882d432869008 to your computer and use it in GitHub Desktop.
Add current version as a minimum version to gems without version constraints in Gemfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
file_name = 'Gemfile' | |
text = File.read(file_name) | |
new_contents = text.gsub(/^\s*gem ['"]([\w_\-]+)['"]$/) do | |
original = Regexp.last_match[0] | |
gem_name = Regexp.last_match[1] | |
current_version = Gem.loaded_specs[gem_name].version.to_s | |
"#{original}, '>= #{current_version}'" | |
end | |
File.open(file_name, 'w') do |file| | |
file.puts new_contents | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment