Sha256: 3ddbba7b86ba6cd8ff5124c62f965974b4763cae0f51b099c163f332132942e7
Contents?: true
Size: 814 Bytes
Versions: 2
Compression:
Stored size: 814 Bytes
Contents
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.2 | spec/support/vectory_helper.rb |
vectory-0.4.1 | spec/support/vectory_helper.rb |