Sha256: 224562894ee77e8fe0f477fe35fccaec94933239ef34f3f272e28cc2190db4c7
Contents?: true
Size: 837 Bytes
Versions: 2
Compression:
Stored size: 837 Bytes
Contents
require "htmlentities" require "nokogiri" require "tmpdir" module Vectory module Helper def with_tmp_dir(&block) Dir.mktmpdir(nil, Vectory.root_path.join("tmp/"), &block) end def in_tmp_dir(&block) Dir.mktmpdir(nil, Vectory.root_path.join("tmp/")) do |dir| Dir.chdir(dir, &block) end end def xmlpp(xml) xsl = <<~XSL <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> XSL Nokogiri::XSLT(xsl).transform(Nokogiri::XML(xml, &:noblanks)) .to_xml(indent: 2, encoding: "UTF-8") end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vectory-0.4.0 | spec/support/vectory_helper.rb |
vectory-0.3.0 | spec/support/vectory_helper.rb |