Browse files

Fix RbConfig / Config warning in Ruby 1.9.3.

"Config" is deprecated in Ruby 1.9.3, in favor of "RbConfig". This
patch uses whichever is available, preventing Ruby 1.9.3 from printing
a deprecation warning when redcloth is loaded.
  • Loading branch information...
1 parent 693ee37 commit 3f58b37ad03e90b69a76827156390fdf89802b3e @purcell purcell committed Nov 6, 2011
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/redcloth.rb
View
5 lib/redcloth.rb
@@ -7,7 +7,8 @@
require 'rbconfig'
begin
- prefix = Config::CONFIG['arch'] =~ /mswin|mingw/ ? "#{Config::CONFIG['MAJOR']}.#{Config::CONFIG['MINOR']}/" : ''
+ conf = Object.const_get(defined?(RbConfig) ? :RbConfig : :Config)::CONFIG
+ prefix = conf['arch'] =~ /mswin|mingw/ ? "#{conf['MAJOR']}.#{conf['MINOR']}/" : ''
lib = "#{prefix}redcloth_scan"
require lib
rescue LoadError => e
@@ -41,4 +42,4 @@ def self.include(*args)
require 'redcloth/erb_extension'
include ERB::Util
rescue LoadError
-end
+end

0 comments on commit 3f58b37

Please sign in to comment.