From b8836adf6757f91d91996b8dc2d496aad31fbc52 Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Mon, 9 Sep 2013 00:56:53 +1000 Subject: [PATCH] only require binding_of_caller if the right version is installed --- ext/mkrf_conf.rb | 2 ++ lib/better_errors.rb | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ext/mkrf_conf.rb b/ext/mkrf_conf.rb index 50adfca2..86f66a9d 100644 --- a/ext/mkrf_conf.rb +++ b/ext/mkrf_conf.rb @@ -3,6 +3,8 @@ gem = Gem::DependencyInstaller.new if ["rbx", "ruby"].include?(RUBY_ENGINE) + # This MUST match the version specified in lib/better_errors.rb, or else + # weird shit will happen. if Gem::Dependency.new("binding_of_caller", "0.7.2").matching_specs.empty? gem.install "binding_of_caller", "0.7.2" end diff --git a/lib/better_errors.rb b/lib/better_errors.rb index 8f3a9b20..7347edc0 100644 --- a/lib/better_errors.rb +++ b/lib/better_errors.rb @@ -134,10 +134,11 @@ def self.default_editor BetterErrors.editor = default_editor end -begin +if Gem::Dependency.new("binding_of_caller", "0.7.2").matching_specs.any? + gem "binding_of_caller", "0.7.2" require "binding_of_caller" BetterErrors.binding_of_caller_available = true -rescue LoadError => e +else BetterErrors.binding_of_caller_available = false end