-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.rb
executable file
·37 lines (32 loc) · 1.43 KB
/
build.rb
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
#!/usr/bin/env ruby
#
# Build a standalone, all-including jaws.js by combining all the files in src/-directory into one
#
File.open("jaws.js", "w") do |out|
files = ["core.js","input.js","assets.js","game_loop.js","rect.js","sprite.js","sprite_list.js","sprite_sheet.js","parallax.js","animation.js","viewport.js","tile_map.js", "collision_detection.js", "gfx.js"]
files.each { |file| out.write( File.read("src/#{file}") ) }
out.write(";window.addEventListener(\"load\", function() { if(jaws.onload) jaws.onload(); }, false);")
end
#
# Minify jaws.js into jaws-min.js using googles closure compiler
#
require 'net/http'
require 'uri'
def compress(js_code, compilation_level)
response = Net::HTTP.post_form(URI.parse('http://closure-compiler.appspot.com/compile'), {
'js_code' => js_code,
'compilation_level' => "#{compilation_level}",
'output_format' => 'text',
'output_info' => 'compiled_code'
# 'output_info' => 'errors'
})
response.body
end
js_code = File.read("jaws.js")
File.open("jaws-min.js", "w") { |out| out.write compress(js_code, "SIMPLE_OPTIMIZATIONS") } # option: ADVANCED_OPTIMIZATIONS
#
# Generate documentation into http://jawsjs.com/docs/
# -a documents All functions
#
`jsdoc -D='noGlobal:true' -D='title:JawsJS HTML5 game engine documentation' -t=/www/ippa/jawsjs.com/public/codeview -d=/www/ippa/jawsjs.com/public/docs src`
`cd /www/ippa/jawsjs.com/public/docs; zip jaws-docs.zip -x jaws-docs.zip -r .`