Module: Gem

Defined in:
lib/gem_patching.rb

Class Method Summary collapse

Class Method Details

.patching(gem_name, targeted_gem_version, &block) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/gem_patching.rb', line 4

def self.patching(gem_name, targeted_gem_version, &block)
 return unless active_gem = Gem.loaded_specs[gem_name]
 if active_gem.version.to_s != targeted_gem_version
   raise "Attempt to apply patch targeting version '#{targeted_gem_version}' of '#{gem_name}', but active version is '#{active_gem.version}'"
 else
   yield if block_given?
 end
end