diff options
author | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-07-10 08:01:04 +0000 |
---|---|---|
committer | naruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-07-10 08:01:04 +0000 |
commit | a2e497d5ede45bd4f4a57f494027020d7bd1733b (patch) | |
tree | 9773233b59c71615a1b88fd5807b30d2e0f09345 /ext/json/lib/json/ext.rb | |
parent | a119b9d146fea877acc1e9ba5df0702163ce917a (diff) |
* ext/json: Merge json gem 1.5.4+ (f7f78896607b6f6226cd).
[Bug #4700]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32493 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/json/lib/json/ext.rb')
-rw-r--r-- | ext/json/lib/json/ext.rb | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/ext/json/lib/json/ext.rb b/ext/json/lib/json/ext.rb index a5e3148c57..1fbc3fd7d1 100644 --- a/ext/json/lib/json/ext.rb +++ b/ext/json/lib/json/ext.rb @@ -4,12 +4,25 @@ module JSON # This module holds all the modules/classes that implement JSON's # functionality as C extensions. module Ext - require 'json/ext/parser' - require 'json/ext/generator' + begin + if defined?(RUBY_ENGINE) == 'constant' and RUBY_ENGINE == 'ruby' and RUBY_VERSION =~ /\A1\.9\./ + require 'json/ext/1.9/parser' + require 'json/ext/1.9/generator' + elsif !defined?(RUBY_ENGINE) && RUBY_VERSION =~ /\A1\.8\./ + require 'json/ext/1.8/parser' + require 'json/ext/1.8/generator' + else + require 'json/ext/parser' + require 'json/ext/generator' + end + rescue LoadError + require 'json/ext/parser' + require 'json/ext/generator' + end $DEBUG and warn "Using Ext extension for JSON." JSON.parser = Parser JSON.generator = Generator end - JSON_LOADED = true unless const_defined?(:JSON_LOADED) + JSON_LOADED = true unless defined?(::JSON::JSON_LOADED) end |