Skip to content

Instantly share code, notes, and snippets.

@mxcl
Created April 8, 2010 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mxcl/360525 to your computer and use it in GitHub Desktop.
Save mxcl/360525 to your computer and use it in GitHub Desktop.
Make your Xcode templates less rubbish
def inreplace path, before=nil, after=nil
[*path].each do |path|
f = File.open path, 'r'
s = f.read.gsub before, after
f.reopen(path, 'w').write s
f.close
end
end
require 'pathname'
BEFORE = "\
//
// .*
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
"
AFTER = "// ctime: ___DATE___"
Pathname.getwd.find do |pn|
next unless pn.file?
next if pn.realpath == Pathname.new(__FILE__).realpath
inreplace pn.to_s, Regexp.new(BEFORE), AFTER
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment