From 5132081975810afade4d783e68731b06d7f37665 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Fri, 30 Jul 2010 16:05:51 -0300 Subject: [PATCH] AS gem doesn't depend on nokogiri so shows a nicer error if users haven't installed --- activesupport/lib/active_support/xml_mini/nokogiri.rb | 7 ++++++- activesupport/lib/active_support/xml_mini/nokogirisax.rb | 9 +++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/activesupport/lib/active_support/xml_mini/nokogiri.rb b/activesupport/lib/active_support/xml_mini/nokogiri.rb index eb61a7fc22c9d..e03a74425755d 100644 --- a/activesupport/lib/active_support/xml_mini/nokogiri.rb +++ b/activesupport/lib/active_support/xml_mini/nokogiri.rb @@ -1,4 +1,9 @@ -require 'nokogiri' +begin + require 'nokogiri' +rescue LoadError => e + $stderr.puts "You don't have nokogiri installed in your application. Please add it to your Gemfile and run bundle install" + raise e +end require 'active_support/core_ext/object/blank' # = XmlMini Nokogiri implementation diff --git a/activesupport/lib/active_support/xml_mini/nokogirisax.rb b/activesupport/lib/active_support/xml_mini/nokogirisax.rb index 8af7b5e565e51..38c8685390c18 100644 --- a/activesupport/lib/active_support/xml_mini/nokogirisax.rb +++ b/activesupport/lib/active_support/xml_mini/nokogirisax.rb @@ -1,4 +1,9 @@ -require 'nokogiri' +begin + require 'nokogiri' +rescue LoadError => e + $stderr.puts "You don't have nokogiri installed in your application. Please add it to your Gemfile and run bundle install" + raise e +end require 'active_support/core_ext/object/blank' # = XmlMini Nokogiri implementation using a SAX-based parser @@ -80,4 +85,4 @@ def parse(data) end end end -end \ No newline at end of file +end