Created
April 20, 2009 17:08
-
-
Save AlanQuatermain/98622 to your computer and use it in GitHub Desktop.
Xcode License Header Script
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
#!/usr/bin/ruby | |
require 'osx/cocoa' | |
require 'date' | |
OSX.require_framework "AddressBook" | |
filePath = "%%%{PBXFilePath}%%%" | |
fileName = File.basename(filePath) | |
projName = File.basename(File.dirname(filePath)) | |
def file_uses_hash_comments(path) | |
fileExt = File.extname(path) | |
%w{.rb .pl .sh .csh .zsh}.each do |ext| | |
return true if fileExt == ext | |
end | |
false | |
end | |
me = OSX::ABAddressBook.sharedAddressBook.me | |
myName = "#{me.send(:valueForProperty, 'firstName')} #{me.send(:valueForProperty, 'lastName')}" | |
date = DateTime.now | |
headText = %{%%%{PBXHeadText}%%%} | |
c_mode = false | |
unless headText =~ /(^#!)|(\n# )/ or file_uses_hash_comments(filePath) | |
c_mode = true | |
end | |
puts "/*" if c_mode | |
%{#{fileName} | |
#{projName} | |
Created by #{myName} on #{date.mday}/#{date.month}/#{date.year}. | |
Copyright (c) #{date.year} #{myName} | |
All rights reserved. | |
Redistribution and use in source and binary forms, with or without | |
modification, are permitted provided that the following conditions | |
are met: | |
Redistributions of source code must retain the above copyright notice, | |
this list of conditions and the following disclaimer. | |
Redistributions in binary form must reproduce the above copyright | |
notice, this list of conditions and the following disclaimer in the | |
documentation and/or other materials provided with the distribution. | |
Neither the name of the project's author nor the names of its | |
contributors may be used to endorse or promote products derived from | |
this software without specific prior written permission. | |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | |
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | |
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | |
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED | |
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | |
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF | |
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING | |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | |
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
}.each_line do |line| | |
if c_mode | |
puts " * #{line}" | |
else | |
puts "# #{line}" | |
end | |
end | |
puts " *\n */" if c_mode |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment