Is there a way to require a ruby gem safely so as to not raise an exception if the gem is not found?
I am looking a solution close to this:
if require 'hirb'
# do some hirb related stuff
else
# do other stuff
end
I want this to make sure no unnecessary gems are failing my deploys to production.
It would probably be done like this:
begin
require 'hirb'
rescue LoadError => e
puts "could not find hirb"
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With