-
Notifications
You must be signed in to change notification settings - Fork 16
/
RakeFile
74 lines (60 loc) · 2.04 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
67
68
69
70
71
72
73
74
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 + "/vanadium-jquery.js") do |f|
f.read.match(/Vanadium\.Version\s?=\s?'([^']+)'/)
end
return $1
end
DOC = ROOT + '/doc'
LP_VERSION = get_version_string
SOURCE_LIST = file_list SRC, 'vanadium-jquery.js', 'vanadium-hashmap.js', 'vanadium-container.js', 'vanadium-form.js', 'vanadium-base.js', 'vanadium-utils.js', 'vanadium-dom.js', 'vanadium-element.js', 'vanadium-instance.js', 'vanadium-types.js', 'vanadium-init.js'
DIST_LIST = file_list DIST, 'vanadium.js', 'README', 'LICENSE'
task :default => :dist
desc 'Package Vanadium for distribution.'
task :dist => :minify do
puts 'Packaging distribution...'
FileUtils.cp Dir[DOC + '/**/*'], DIST
FileUtils.cp 'README', DIST
#Zip::ZipFile.open(DIST + "/vanadium.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...'
license = File.new(DOC + '/LICENSE').read
File.open(DIST + '/vanadium.js', 'w') do |vanadium|
vanadium << "/*\n" << license << "\n*/\n"
SOURCE_LIST.each do |src|
File.open(src) do |f|
vanadium << "\n\n//-------------------- #{File.basename(src)} -----------------------------\n\n"
vanadium << f.read.sub("/*\n"+license+"\n */", '')
end
end
end
end
desc 'Minifies using yuicompressor'
task :minify => :build do
sh "java -jar tools/yuicompressor-2.4.2.jar -o dist/vanadium-min.js dist/vanadium.js"
end
desc 'Copies a built version of Vanadium to test dir.'
task :dist_to_test => :build do
FileUtils.cp [DIST + '/vanadium.js'], TEST
end