Skip to content

Instantly share code, notes, and snippets.

@KengoTODA
Created March 24, 2012 12:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KengoTODA/2181575 to your computer and use it in GitHub Desktop.
Save KengoTODA/2181575 to your computer and use it in GitHub Desktop.
Rakefile for enchant.js programming
require 'net/https'
require 'uri'
require 'rake/packagetask'
require 'rake/clean'
task :default => "index.html"
PACKAGE_NAME = 'MyGame'
PACKAGE_VERSION = '1.0.0'
OPTIMIZE_DIR = './optimize'
CLEAN.include(FileList[OPTIMIZE_DIR])
def download(path)
uri = URI.parse("https://raw.github.com/" + path)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Get.new(uri.request_uri)
http.request(request).body
end
file "index.html" => ["game.js"] do |t|
File.open(t.name, 'w') {|f|
f << download("eller86/press-start/master/template/index.html")
}
end
file "game.js" => ["enchant.js", "require.js", "order.js"] do |t|
File.open(t.name, 'w') {|f|
f << download("eller86/press-start/master/template/game.js")
}
end
file "enchant.js" do |t|
File.open(t.name, 'w') {|f|
f << download("wise9/enchant.js/master/enchant.js")
}
end
file "require.js" do |t|
File.open(t.name, 'w') {|f|
f << download("jrburke/requirejs/master/require.js")
}
end
file "order.js" do |t|
File.open(t.name, 'w') {|f|
f << download("jrburke/requirejs/master/order.js")
}
end
file "build_profile.js" do |t|
File.open(t.name, 'w') {|f|
f << download('eller86/press-start/master/template/build_profile.js')
}
end
directory OPTIMIZE_DIR
task 'optimize' => [OPTIMIZE_DIR, 'index.html', 'build_profile.js'] do
sh 'r.js -o build_profile.js'
end
# please execute this task in 'optimize' directory
Rake::PackageTask.new(PACKAGE_NAME, PACKAGE_VERSION) do |p|
p.package_dir = './pkg'
p.package_files.include('./**/*')
p.need_zip = true
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment