Module: Sei::Printer
- Defined in:
- lib/sei/printer.rb
Class Method Summary collapse
Class Method Details
.jp(json_text) ⇒ Object
8 9 10 |
# File 'lib/sei/printer.rb', line 8 def self.jp(json_text) puts JSON.pretty_generate json_text end |
.xp(xml_text) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/sei/printer.rb', line 12 def self.xp(xml_text) xsl = <<~HEREDOC <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" encoding="UTF-8" indent="yes"/> <xsl:strip-space elements="*" <xsl:template match="/"> <xsl:copy-of select="."/> </xsl:template> </xsl:stylesheet> HEREDOC doc = Nokogiri::XML(xml_text) xslt = Nokogiri::XSLT(xsl) out = xslt.transform(doc) puts out.to_xml end |