Last active
August 29, 2015 14:23
-
-
Save maxim/1b88e10527b282022510 to your computer and use it in GitHub Desktop.
Pin your monkey patches to certain gem version in rails
This file contains hidden or 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
| # in an early initializer | |
| def PinMonkeypatch!(gem_name, expected_version) | |
| if gem_spec = Gem.loaded_specs[gem_name] | |
| actual_version = gem_spec.version.to_s | |
| if actual_version != expected_version | |
| raise "Monkeypatch for #{gem_name} requires version "\ | |
| "#{expected_version}, but current version is #{actual_version}" | |
| end | |
| else | |
| raise "Monkeypatch failed for #{gem_name}, gem not found" | |
| end | |
| end | |
| # in monkeypatching initializer, e.g. config/initializers/patch_actionview_19967.rb | |
| PinMonkeypatch! 'actionview', '4.1.11' | |
| module ActionView::Helpers::TranslationHelper | |
| … | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment