-
Notifications
You must be signed in to change notification settings - Fork 13
/
RakeFile
66 lines (53 loc) · 1.47 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
58
59
60
61
62
63
64
65
66
require 'rake'
require 'rubygems'
require 'zip/zip'
require 'fileutils'
ROOT = File.dirname(__FILE__)
SRC = ROOT + '/src'
DIST = ROOT + '/dist'
TEST = ROOT + '/test'
def file_list(dir, *files)
files.collect { |f| dir + "/#{f}" }
end
def get_version_string
File.open(SRC + "/lowpro.js") do |f|
f.read.match(/LowPro\.Version\s?=\s?'([^']+)'/)
end
return $1
end
DOC = ROOT + '/doc'
LP_VERSION = get_version_string
SOURCE_LIST = file_list SRC, 'lowpro.js', 'dom.js', 'domready.js', 'behavior.js', 'core_behaviors.js'
DIST_LIST = file_list DIST, 'lowpro.js', 'README', 'LICENSE'
task :default => :dist
desc 'Package Low Pro for distribution.'
task :dist => :build do
puts 'Packaging distribution...'
FileUtils.cp Dir[DOC + '/**/*'], DIST
Zip::ZipFile.open(DIST + "/lowpro.zip", Zip::ZipFile::CREATE) do |zip|
DIST_LIST.each do |f|
zip.get_output_stream(File.basename(f)) { |o| o << File.open(f).read } if File.exists? f
end
end
end
desc 'Delete all files from dist.'
task :clean do
puts 'Cleaning dist...'
FileUtils.rm Dir[DIST + '/**/*']
end
desc 'Compiles JS into a single file.'
task :build => :clean do
puts 'Building script...'
File.open(DIST + '/lowpro.js', 'w') do |lowpro|
SOURCE_LIST.each do |src|
File.open(src) do |f|
lowpro << f.read
lowpro << "\n\n"
end
end
end
end
desc 'Copies a built version of LowPro to test dir.'
task :dist_to_test => :build do
FileUtils.cp [DIST + '/lowpro.js'], TEST
end