Sha256: 67c567b75f8021a18c2c260fc486da40d73f8d087ef8e2a689bc8035db07538a

Contents?: true

Size: 672 Bytes

Versions: 1

Compression:

Stored size: 672 Bytes

Contents

require 'rewritepclint/version'
#require 'nokogiri'

module Rewritepclint
#  def self.with(prefix: prefix, content: content)
#    doc = Nokogiri::XML(content)
#    files = doc.xpath("//file")
#    files.each do |f|
#      f.content = File.join(prefix, f.content).gsub("\\", "/")
#    end
#    return doc.to_xml()
#  end
  def self.with(prefix: prefix, content: content)
    match = content.match(Regexp.new(".*(<.xml.*</doc>.).*", Regexp::MULTILINE))
    new_content = match[1]
    new_content = new_content.gsub(Regexp.new("<file>(.*?)</file>")) do |match|
      new_filename = $1.gsub("\\", "/")
      "<file>#{File.join(prefix, new_filename)}</file>"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rewritepclint-0.0.2 lib/rewritepclint.rb