forked from brianleroux/xui
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Rakefile
57 lines (47 loc) · 1.27 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
require 'erb'
LIBPATH = File.expand_path(File.dirname(__FILE__)) + File::SEPARATOR
task :default do
write
min
test
end
# - helpers
# writes out an uncompiled version of xui
def write
puts 'writing the full source into lib/xui.js'
path = "#{ LIBPATH }src#{ File::SEPARATOR }js#{ File::SEPARATOR }xui.js"
final = "#{ LIBPATH }lib#{ File::SEPARATOR }xui.js"
html = ERB.new(open(path).read).result
open(final,'w'){|f| f.puts( html )}
end
# the sub libraries used by xui
def libs_to_build
%w(dom event style fx xhr)
end
# used within src/js/xui.js erb call
def build_sub_libraries
s = ""
libs_to_build.each do |lib|
s << import("#{ LIBPATH }src#{ File::SEPARATOR }js#{ File::SEPARATOR }lib#{ File::SEPARATOR }#{ lib }.js")
end
s
end
# helper for build_sub_libaries
def import(lib)
s = ""
r = ""
open(lib) { |f| s << "\n#{f.read}\n\n" }
s.each_line {|l| r << " #{l}"}
r
end
# TODO add yahoo min
def min
puts 'minifying js'
min_file = "#{ LIBPATH }lib#{ File::SEPARATOR }xui-min.js"
doc_file = "#{ LIBPATH }lib#{ File::SEPARATOR }xui.js"
sh "java -jar #{LIBPATH}/util/yuicompressor-2.3.6.jar --nomunge --charset UTF-8 -o #{min_file} #{doc_file}"
end
def test
puts 'running automated test suite'
sh "open file://#{ LIBPATH }/spec/index.html"
end