Permalink
Browse files

more load path hackery in bin/ronn

  • Loading branch information...
rtomayko committed Mar 8, 2010
1 parent 5e8cf48 commit 1a8a85940171da780148d971e6794ab2d769f5a7
Showing with 20 additions and 4 deletions.
  1. +20 −4 bin/ronn
View
@@ -86,12 +86,28 @@ formats = ['roff'] if formats.empty?
formats.delete('html') if formats.include?('html_fragment')
pid = nil
+begin
+ require 'hpricot'
+ require 'rdiscount'
+rescue LoadError
+ if !defined?(Gem)
+ warn "warn: #{$!.to_s}. trying again with rubygems."
+ require 'rubygems'
+ retry
+ end
+end
+
begin
require 'ronn'
-rescue LoadError => boom
- raise unless boom.to_s.include?('ronn')
- $:.unshift File.dirname(__FILE__) + "../lib"
- require 'ronn'
+rescue LoadError
+ raise if $!.to_s !~ /ronn/
+ libdir = File.expand_path("../../lib", __FILE__).sub(/^#{Dir.pwd}/, '.')
+ if !$:.include?(libdir)
+ warn "warn: #{$!.to_s}. trying again with #{libdir} on load path."
+ $:.unshift libdir
+ retry
+ end
+ raise
end
wr = STDOUT

0 comments on commit 1a8a859

Please sign in to comment.