Skip to content

Instantly share code, notes, and snippets.

@jimmac
Created December 13, 2012 14:41
Show Gist options
  • Save jimmac/4276778 to your computer and use it in GitHub Desktop.
Save jimmac/4276778 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require "rexml/document"
include REXML
def rebrand(fname, brand)
svg = Document.new(File.new(fname, 'r'))
temp =
svg.root.each_element("/svg/g/rect[@id='background']") do |e|
e.attributes["style"] = "fill:url(##{brand});"
puts e
end
temp_f = File.new(TEMP,'w+')
temp_f.puts svg
temp_f.close
end
TEMP = './tmp.svg'
Dir.glob("*svg") do |fname|
puts fname
rebrand(fname, "RHEL7")
system "inkscape --vacuum-defs -l ../getting-started/C/figures/#{fname} #{TEMP}"
File.delete(TEMP)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment