lib/wordnik/response.rb in wordnik-0.3.5 vs lib/wordnik/response.rb in wordnik-0.3.6

- old
+ new

@@ -1,10 +1,12 @@ module Wordnik class Response require 'active_model' require 'json' + require 'nokogiri' + require 'htmlentities' include ActiveModel::Validations include ActiveModel::Conversion extend ActiveModel::Naming attr_accessor :raw @@ -50,20 +52,20 @@ def pretty_body return unless body.present? case format when :json - JSON.pretty_generate(body).gsub(/\n/, '<br/>').html_safe + JSON.pretty_generate(body).gsub(/\n/, '<br/>') when :xml - xsl = Nokogiri::XSLT(File.open(Rails.root.join("config", "pretty_print.xsl"))) + xsl = Nokogiri::XSLT(File.open(File.join(File.dirname(__FILE__), "../../config/pretty_print.xsl"))) xml = Nokogiri(body) coder = HTMLEntities.new coder.encode(xsl.apply_to(xml).to_s) end end def pretty_headers - JSON.pretty_generate(headers).gsub(/\n/, '<br/>').html_safe + JSON.pretty_generate(headers).gsub(/\n/, '<br/>') end # It's an ActiveModel thing.. def persisted? false \ No newline at end of file