public
Description: IRC Client for OSX
Homepage: http://limechat.net/mac/
Clone URL: git://github.com/psychs/limechat.git
Click here to lend your support to: limechat and make a donation at www.pledgie.com !
psychs (author)
Thu Nov 05 19:30:48 -0800 2009
commit  dac8e5c8c114fc553060ae5a30aef4825a0d32d2
tree    6413df2af3d596a9596cb2f3f32cb03c21e3c906
parent  a721184095848e76b46c32b70023483d9d08c32a
limechat / Rakefile
100644 243 lines (198 sloc) 4.749 kb
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
require 'pathname'
require 'fileutils'
require 'time'
require 'erb'
require 'rake/testtask'
require 'pp'
 
APP_SHORT_NAME = defined?(MACRUBY_VERSION) ? 'MRLimeChat' : 'LimeChat'
APP_NAME = APP_SHORT_NAME + '.app'
ROOT_PATH = Pathname.new(__FILE__).dirname
APP_BUILD_PATH = ROOT_PATH + 'build/Release' + APP_NAME
DOC_PATH = ROOT_PATH + 'doc'
PACKAGES_PATH = ROOT_PATH + 'Packages'
APPCAST_TEMPLATE_PATH = ROOT_PATH + 'etc/appcast_template.rxml'
WEB_PATH = ROOT_PATH + 'web'
APPCAST_PATH = WEB_PATH + 'limechat_appcast.xml'
TMP_PATH = Pathname.new("/tmp/#{APP_SHORT_NAME}_build_image")
 
 
task :default => :build
 
task :clean do |t|
  sh "rm -rf build"
end
 
task :build do |t|
  build('10.5')
end
 
task :package => [:package_app] do |t|
end
 
task :package_app => :clean do |t|
  sdk = '10.5'
  build(sdk)
  package
end
 
task :package_source do |t|
  package_source
end
 
task :appcast do |t|
  package_fname = "#{APP_SHORT_NAME}_#{app_version}.tbz"
package_path = PACKAGES_PATH + package_fname
stat = File.stat(package_path)
 
  version = app_version
fsize = stat.size
ftime = stat.mtime.rfc2822
  updates = parse_commit_log
  
  APPCAST_PATH.rmtree
  e = ERB.new(File.open(APPCAST_TEMPLATE_PATH).read, nil, '-')
  s = e.result(binding)
  File.open(APPCAST_PATH, 'w') do |f|
    f.write(s)
  end
  
  sh "mate #{WEB_PATH}"
end
 
Rake::TestTask.new do |t|
  t.test_files = FileList['test/**/*_test.rb']
end
 
 
def build(sdk)
  sh "xcodebuild -project #{APP_SHORT_NAME}.xcodeproj -target #{APP_SHORT_NAME} -configuration Release -sdk macosx#{sdk} build"
end
 
def embed_framework(sdk)
  sh %Q|/usr/bin/ruby -r etc/package_builder -e "PackageBuilder.build('#{APP_BUILD_PATH}', '#{sdk}')"|
end
 
def package
package_path = PACKAGES_PATH + "#{APP_SHORT_NAME}_#{app_version}.tbz"
package_path.rmtree
TMP_PATH.rmtree
TMP_PATH.mkpath
APP_BUILD_PATH.cptree(TMP_PATH)
DOC_PATH.cptree(TMP_PATH)
rmglob(TMP_PATH + '**/ChangeLog.txt')
rmglob(TMP_PATH + '**/.DS_Store')
Dir.chdir(TMP_PATH) do
sh "tar jcf #{package_path} *"
end
TMP_PATH.rmtree
end
 
def package_source
source_package_path = PACKAGES_PATH + "#{APP_SHORT_NAME}_#{app_version}_src.tbz"
source_package_path.rmtree
TMP_PATH.rmtree
ROOT_PATH.cptree(TMP_PATH)
rmglob(TMP_PATH + 'build')
rmglob(TMP_PATH + 'etc')
rmglob(TMP_PATH + 'Packages')
rmglob(TMP_PATH + 'script')
rmglob(TMP_PATH + 'web')
rmglob(TMP_PATH + '*.tmproj')
rmglob(TMP_PATH + 'MRLimeChat.xcodeproj')
rmglob(TMP_PATH + 'LimeChat.xcodeproj/*.mode1*')
rmglob(TMP_PATH + 'LimeChat.xcodeproj/*.pbxuser')
rmglob(TMP_PATH + '**/*.tm_build_errors')
rmglob(TMP_PATH + '**/.gitignore')
rmglob(TMP_PATH + '**/.DS_Store')
rmglob(TMP_PATH + '**/*~.nib')
rmglob(TMP_PATH + '**/._*')
Dir.chdir(TMP_PATH) do
sh "tar jcf #{source_package_path} *"
end
TMP_PATH.rmtree
end
 
 
class CommitLog
attr_accessor :hash, :merge, :author, :date
attr_reader :lines
def initialize
@lines = []
end
def add_line(line)
@lines << line
end
def release_version
ary = @lines.select {|e| e =~ /^released (\d+\.\d+)$/i }
if ary
$1
else
nil
end
end
def one_line
s = ''
@lines.each do |e|
s << e
s << ' '
end
s.chop
end
def inspect
"<CommitLog #{hash[0...6]} #{author} #{date}>"
end
end
 
 
def parse_commit_log
updates = []
commit = nil
log = `git log`
log.each_line do |s|
s.chomp!
if s =~ /^commit\s+/
if commit
updates << commit
end
commit = CommitLog.new
commit.hash = $~.post_match
elsif s =~ /^Author:\s*/
commit.author = $~.post_match
elsif s =~ /^Date:\s*/
commit.date = $~.post_match
elsif s =~ /^Merge:\s*/
commit.merge = $~.post_match
elsif s =~ /^\s*$/
;
elsif s =~ /^\s+/
commit.add_line($~.post_match)
end
end
updates << commit
ver = app_version
first = 0
last = 0
updates.each_with_index do |e,i|
rel = e.release_version
if rel
if rel == ver
first = i + 1
else
last = i
break
end
end
end
updates = updates[first...last]
updates.map {|e| e.one_line }
end
 
 
module Util
def app_version
file = ROOT_PATH + 'Info.plist'
file.open do |f|
next_line = false
while s = f.gets
if next_line
next_line = false
if s =~ /<string>(.+)<\/string>/
return $1
end
elsif s =~ /<key>CFBundleShortVersionString<\/key>/
next_line = true
end
end
end
nil
end
 
def rmglob(path)
FileUtils.rm_rf(Dir.glob(path.to_s))
end
end
include Util
 
class Pathname
  def rmtree
    FileUtils.rm_rf(to_s)
  end
  
  def cptree(to)
    FileUtils.cp_r(to_s, to.to_s)
  end
end