-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Rakefile
83 lines (71 loc) · 2.68 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
75
76
77
78
79
80
81
82
83
LIBPATH = File.expand_path(File.dirname(__FILE__)) + File::SEPARATOR
#
# builds and tests
#
desc 'writes lib/phonegap.js and lib/phonegap-min.js and runs docs'
task :default do
build
doc
end
task :doc do
doc
end
def doc
puts 'writing the full interface source for documentation into tmp/phonegap.js'
final = "#{ LIBPATH }tmp#{ File::SEPARATOR }phonegap.js"
js = ""
interfaces_to_build.each do |lib|
js << import("#{ LIBPATH }javascripts#{ File::SEPARATOR }#{ lib }.js")
end
FileUtils.mkdir_p "#{ LIBPATH }tmp"
open(final,'w'){|f| f.puts( js )}
sh "java -jar util#{ File::SEPARATOR }jsdoc-toolkit#{ File::SEPARATOR }jsrun.jar util#{ File::SEPARATOR }jsdoc-toolkit#{ File::SEPARATOR }app#{ File::SEPARATOR }run.js -a -d=javascripts/docs -t=util#{ File::SEPARATOR }jsdoc-toolkit#{ File::SEPARATOR }templates#{ File::SEPARATOR }jsdoc tmp#{ File::SEPARATOR }phonegap.js"
end
def build
puts 'writing the full JS file to lib/phonegap.js'
platforms_to_build.each do |platform|
final = "#{ LIBPATH }lib#{ File::SEPARATOR }#{ platform }#{ File::SEPARATOR }phonegap.js"
js = ""
interfaces_to_build.each do |interface|
js << import("#{ LIBPATH }javascripts#{ File::SEPARATOR }#{ interface }.js")
begin
js << import("#{ LIBPATH }javascripts#{ File::SEPARATOR }#{ platform }#{ File::SEPARATOR }#{ interface }.js")
rescue
end
end
FileUtils.mkdir_p "#{ LIBPATH }lib#{ File::SEPARATOR }#{ platform }"
open(final,'w'){|f| f.puts( js )}
end
min
end
# the sub libraries used by xui
def interfaces_to_build
%w(device acceleration accelerometer media camera contact uicontrols debugconsole file geolocation map notification orientation position sms telephony)
end
# the sub libraries used by xui
def platforms_to_build
%w(android blackberry iphone)
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
# creates lib/xui-min.js (tho not obfuscates)
def min
puts 'minifying js'
platforms_to_build.each do |platform|
min_file = "#{ LIBPATH }lib#{ File::SEPARATOR }#{ platform }#{ File::SEPARATOR }phonegap-min.js"
doc_file = "#{ LIBPATH }lib#{ File::SEPARATOR }#{ platform }#{ File::SEPARATOR }phonegap.js"
sh "java -jar #{LIBPATH}#{ File::SEPARATOR }util#{ File::SEPARATOR }yuicompressor-2.4.2.jar --charset UTF-8 -o #{min_file} #{doc_file}"
end
end
# opens up the specs
def spec
puts 'running automated test suite'
#sh "open -a WebKit file:https://#{ LIBPATH }/spec/index.html"
#sh "open -a '/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone Simulator.app' file:https://#{ LIBPATH }/spec/index.html"
end