Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master
Fetching contributors…

Cannot retrieve contributors at this time

75 lines (60 sloc) 2.084 kB
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
Jump to Line
Something went wrong with that request. Please try again.