Created
May 13, 2016 09:04
-
-
Save ritxi/0280a652cdafbc7c06c70b661b3f1ada to your computer and use it in GitHub Desktop.
Custom Gemfile dependencies injection
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
--color | |
--require spec_helper | |
--require ~/.unbundled_require | |
--format Fuubar |
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
def unbundled_require(gem, options = {}) | |
if defined?(::Bundler) | |
spec_path = Dir.glob("#{Gem.dir}/specifications/#{gem}-*.gemspec").last | |
if spec_path.nil? | |
warn "Couldn't find #{gem}" | |
return | |
end | |
spec = Gem::Specification.load spec_path | |
spec.activate | |
end | |
begin | |
require options[:require] || gem | |
yield if block_given? | |
rescue Exception => err | |
warn "Couldn't load #{gem}: #{err}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment