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() 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