forked from majetiv/zergsupport
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrelease_sources.rb
37 lines (29 loc) · 1.15 KB
/
release_sources.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env ruby
#
# release_sources.m
# ZergSupport
#
# Created by Victor Costan on 1/28/09.
# Copyright Zergling.Net. Licensed under the MIT license.
#
# Enforces some source code formatting rules for ZergSupport.
Dir.glob('**/*').each do |file|
next unless /\.m$/ =~ file or /\.h$/ =~ file # Only Objective C code.
next if /^ZergSupport\/TestSupport\/GTM\// =~ file # Skip GTM code.
next if /^ZergSupport\/TestSupport\/OCMock\// =~ file # Skip OCMock code.
contents = File.read file
# eat whitespace at the end of lines
contents.gsub! /[ \t]+$/, ""
# tabs are 2 spaces
contents.gsub! "\t", " "
# force -(type)method instead of - (type) method
contents.gsub! /\-\s*\(([^(]*)\)\s*(\w)/, "-(\\1)\\2"
contents.gsub! /\+\s*\(([^(]*)\)\s*(\w)/, "+(\\1)\\2"
# force methodName:(type)argument instead of methodName: (type)argument
contents.gsub! /(\w+)\:[ \t]*\(/, "\\1:("
# license
contents.gsub! '__MyCompanyName__', 'Zergling.Net'
contents.gsub! /^\/\/ Copyright.*Zergling\.Net\. .*.$/,
"// Copyright Zergling.Net. Licensed under the MIT license."
File.open(file, 'w') { |f| f.write contents }
end