From d3631840865ca4ce79d3e7acd33d137e6befef09 Mon Sep 17 00:00:00 2001 From: Jason Garber Date: Tue, 17 Mar 2009 03:38:25 -0400 Subject: [PATCH] Added a NotCompiledError to give a friendlier message when people just unpack RedCloth into their projects. [#131 state:resolved] --- CHANGELOG | 2 ++ lib/redcloth.rb | 10 +++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 043a2aa2..f99bf150 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,7 @@ === Edge +* Added a NotCompiledError to give a friendlier message when people just unpack RedCloth into their projects. [Jason Garber] + * Added a pure-ruby version of the parser for times when you can't compile the C or Java extensions. You should avoid using it if at all possible because it is 32 times slower (and has some other problems, too)! [Jason Garber] * Ignore spaces and tabs on blank lines between blocks. #120 [Jason Garber] diff --git a/lib/redcloth.rb b/lib/redcloth.rb index d4421039..fc224fc5 100644 --- a/lib/redcloth.rb +++ b/lib/redcloth.rb @@ -7,7 +7,15 @@ # appears to be fixed in Edge Rails [51e4106]. Object.send(:remove_const, :RedCloth) if Object.const_defined?(:RedCloth) && RedCloth.is_a?(Class) -require 'redcloth_scan' +module RedCloth + class NotCompiledError < LoadError; end +end + +begin + require 'redcloth_scan' +rescue LoadError + raise RedCloth::NotCompiledError, "RedCloth is extremely fast but must be compiled first. Installing the RedCloth gem is the easiest method." +end require 'redcloth/version' require 'redcloth/textile_doc' require 'redcloth/formatters/base'