Created
April 8, 2010 20:52
-
-
Save mxcl/360525 to your computer and use it in GitHub Desktop.
Make your Xcode templates less rubbish
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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