Sha256: 2a2b724de1a408cba5f9abe0a3f205e96edf252ccf5853c2da69b46268956268

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

require 'plist'
#require 'ox'
#require 'rexml/document'
#require 'nokogiri'

class RewritePlistFile
  class NullLogger
    def debug(s)
    end
  end
  def self.with_prefix(prefix, original, logger=NullLogger.new)
    v = Plist::parse_xml(original)
    files = v['files']
    v['files'] = files.map{|i|File.join(prefix, i)}
    v.to_plist(true, :sort => false)
  end
#  def self.with_prefix(prefix, original, log=NullLogger.new)
#    doc = REXML::Document.new(original, :attribute_quote => :quote)
#    array_element = REXML::XPath.first(doc, "//key[text()='files']/following-sibling::array")
#    if array_element
#      array_element.elements.each do |s|
#        s.text = File.join(prefix, s.text)
#      end
#      res = StringIO.new
#      formatter = REXML::Formatters::Pretty.new(2)
#      formatter.compact = true
#      formatter.write(doc, res)
#      return res.string
#    end
#    return original
#   end
#  def self.with_prefix(prefix, original, log=NullLogger.new)
#    doc = Nokogiri::XML(original)
#    log.debug("ORIGINAL") if log
#    log.debug(doc.to_xml) if log
#    array_element = doc.xpath("//key[text()='files']/following-sibling::array/string")
#    array_element.each do |e|
#      e.content = File.join(prefix, e.content)
#    end
#    log.debug("TRANSFORMED") if log
#    log.debug(doc.to_xml) if log
#    return doc.to_xml()
#  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gcc-to-clang-analyzer-0.0.13 lib/gcc_to_clang_analyzer/rewrite_plist_file.rb