From 0e18a4141e446cf64d272f06bd19125ee631b4f1 Mon Sep 17 00:00:00 2001 From: ccocchi Date: Wed, 14 Nov 2012 15:13:59 +0100 Subject: [PATCH] Use nokogiri on JRuby --- Gemfile | 9 ++++++++- lib/rabl-rails.rb | 7 ++++++- test/renderers/plist_renderer_test.rb | 3 --- test/test_helper.rb | 9 +++++++++ 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index caef18e..83f8e54 100644 --- a/Gemfile +++ b/Gemfile @@ -3,9 +3,16 @@ source "http://rubygems.org" gemspec gem 'oj' -gem 'libxml-ruby' gem 'plist' +platforms :ruby do + gem 'libxml-ruby' +end + +platforms :jruby do + gem 'nokogiri' +end + group :test do gem 'rspec-mocks' end diff --git a/lib/rabl-rails.rb b/lib/rabl-rails.rb index 3c2ed94..2f2b4f3 100644 --- a/lib/rabl-rails.rb +++ b/lib/rabl-rails.rb @@ -76,7 +76,12 @@ module RablRails def self.load_default_engines! self.json_engine = MultiJson.default_engine - self.xml_engine = 'LibXML' if defined?(LibXML) 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 diff --git a/test/renderers/plist_renderer_test.rb b/test/renderers/plist_renderer_test.rb index 5b17165..df268ca 100644 --- a/test/renderers/plist_renderer_test.rb +++ b/test/renderers/plist_renderer_test.rb @@ -1,7 +1,4 @@ require 'test_helper' -require 'plist' - -RablRails.plist_engine = Plist::Emit class TestPlistRenderer < ActiveSupport::TestCase INDENT_REGEXP = /\n(\s)*/ diff --git a/test/test_helper.rb b/test/test_helper.rb index 7468f73..25ef975 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -22,6 +22,15 @@ class <