forked from negativecode/vines
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
57 lines (47 loc) · 1.7 KB
/
Rakefile
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
# encoding: UTF-8
require 'rake'
require 'rake/clean'
require 'rake/testtask'
ignore = File.read('web/lib/javascripts/.gitignore')
.split("\n").map {|f| "web/lib/javascripts/#{f}" }
CLOBBER.include('pkg', 'web/chat/javascripts', *ignore)
directory 'pkg'
desc 'Build distributable packages'
task :build => [:assets, :pkg] do
system 'gem build vines.gemspec && mv vines-*.gem pkg/'
end
Rake::TestTask.new(:test) do |test|
test.libs << 'test'
test.libs << 'test/storage'
test.pattern = 'test/**/*_test.rb'
test.warning = false
end
desc 'Compile and minimize web assets'
task :assets do
require 'coffee-script'
require 'uglifier'
# combine and compile library coffeescripts
File.open('web/lib/javascripts/base.js', 'w') do |basejs|
assets = %w[layout button contact filter session transfer router navbar notification login logout]
coffee = assets.inject('') do |sum, name|
sum + File.read("web/lib/coffeescripts/#{name}.coffee")
end
js = %w[jquery jquery.cookie raphael icons strophe].inject('') do |sum, name|
sum + File.read("web/lib/javascripts/#{name}.js")
end
compiled = js + CoffeeScript.compile(coffee)
compressed = Uglifier.compile(compiled)
basejs.write(compressed)
end
# combine and compile chat application's coffeescripts
Dir.mkdir('web/chat/javascripts') unless File.exists?('web/chat/javascripts')
File.open('web/chat/javascripts/app.js', 'w') do |appjs|
coffee = %w[chat init].inject('') do |sum, name|
sum + File.read("web/chat/coffeescripts/#{name}.coffee")
end
compiled = CoffeeScript.compile(coffee)
compressed = Uglifier.compile(compiled)
appjs.write(compressed)
end
end
task :default => [:clobber, :test, :build]