Use nokogiri on JRuby

This commit is contained in:
ccocchi 2012-11-14 15:13:59 +01:00
parent 8b1e88d4ff
commit 0e18a4141e
4 changed files with 23 additions and 5 deletions

View File

@ -3,9 +3,16 @@ source "http://rubygems.org"
gemspec gemspec
gem 'oj' gem 'oj'
gem 'libxml-ruby'
gem 'plist' gem 'plist'
platforms :ruby do
gem 'libxml-ruby'
end
platforms :jruby do
gem 'nokogiri'
end
group :test do group :test do
gem 'rspec-mocks' gem 'rspec-mocks'
end end

View File

@ -76,7 +76,12 @@ module RablRails
def self.load_default_engines! def self.load_default_engines!
self.json_engine = MultiJson.default_engine self.json_engine = MultiJson.default_engine
self.xml_engine = 'LibXML' if defined?(LibXML)
self.plist_engine = Plist::Emit if defined?(Plist) self.plist_engine = Plist::Emit if defined?(Plist)
if defined?(LibXML)
self.xml_engine = 'LibXML'
elsif defined?(Nokogiri)
self.xml_engine = 'Nokogiri'
end
end end
end end

View File

@ -1,7 +1,4 @@
require 'test_helper' require 'test_helper'
require 'plist'
RablRails.plist_engine = Plist::Emit
class TestPlistRenderer < ActiveSupport::TestCase class TestPlistRenderer < ActiveSupport::TestCase
INDENT_REGEXP = /\n(\s)*/ INDENT_REGEXP = /\n(\s)*/

View File

@ -22,6 +22,15 @@ class <<Singleton
end end
require 'rabl-rails' require 'rabl-rails'
require 'plist'
if RUBY_ENGINE == 'ruby'
require 'libxml'
else
require 'nokogiri'
end
RablRails.load_default_engines!
module ActiveSupport module ActiveSupport
class TestCase class TestCase