parent
9c84d27193
commit
a261772292
@ -1,13 +1,19 @@
|
|||||||
#!/usr/bin/env ruby
|
#!/usr/bin/env ruby
|
||||||
|
|
||||||
require 'rexml/document'
|
require 'tempfile'
|
||||||
|
|
||||||
doc = REXML::Document.new(ARGF.read, ignore_whitespace_nodes: :all)
|
plist = ARGF.read
|
||||||
xpath = '//dict/key[text()="variablesdontexport"]/following-sibling::array'
|
Tempfile.create('info.plist') do |f|
|
||||||
vars = doc.elements[xpath].map(&:text)
|
f << plist
|
||||||
|
f.flush
|
||||||
|
|
||||||
vars.each do |var|
|
vars = `/usr/libexec/PlistBuddy -c "Print :variablesdontexport" #{f.path}`
|
||||||
doc.elements["//key[text()='#{var}']/following-sibling::string"].text = ''
|
vars = vars.split("\n")[1..-2].map(&:strip)
|
||||||
end
|
|
||||||
|
vars.each do |var|
|
||||||
|
`/usr/libexec/PlistBuddy -c "Set :variables:#{var} ''" #{f.path}`
|
||||||
|
end
|
||||||
|
|
||||||
doc.write
|
f.rewind
|
||||||
|
puts f.read
|
||||||
|
end
|
||||||
|
Loading…
Reference in new issue