2009-09-05 06:04:48 +00:00
|
|
|
def jasmine_sources
|
2011-06-06 04:28:26 +00:00
|
|
|
sources = ["src/core/base.js", "src/core/util.js", "src/core/Env.js", "src/core/Reporter.js", "src/core/Block.js"]
|
|
|
|
sources += Dir.glob('src/core/*.js').reject { |f| f == 'src/core/base.js' || sources.include?(f) }.sort
|
2009-11-26 15:41:10 +00:00
|
|
|
sources
|
2009-09-05 06:04:48 +00:00
|
|
|
end
|
|
|
|
|
2010-06-25 00:33:46 +00:00
|
|
|
def jasmine_html_sources
|
|
|
|
["src/html/TrivialReporter.js"]
|
|
|
|
end
|
|
|
|
|
2010-06-25 00:15:06 +00:00
|
|
|
def jasmine_version
|
|
|
|
"#{version_hash['major']}.#{version_hash['minor']}.#{version_hash['build']}"
|
2009-09-05 06:04:48 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def version_hash
|
2010-06-25 00:15:06 +00:00
|
|
|
require 'json'
|
2011-06-06 04:28:26 +00:00
|
|
|
@version ||= JSON.parse(File.new("src/core/version.json").read);
|
2009-09-05 06:04:48 +00:00
|
|
|
end
|
|
|
|
|
2009-11-26 15:41:10 +00:00
|
|
|
|
2010-06-25 00:15:06 +00:00
|
|
|
def substitute_jasmine_version(filename)
|
|
|
|
contents = File.read(filename)
|
|
|
|
contents = contents.gsub(/##JASMINE_VERSION##/, (jasmine_version))
|
2010-07-28 01:47:12 +00:00
|
|
|
contents = contents.gsub(/[^\n]*REMOVE_THIS_LINE_FROM_BUILD[^\n]*/, '')
|
2010-06-25 00:15:06 +00:00
|
|
|
File.open(filename, 'w') { |f| f.write(contents) }
|
|
|
|
end
|
|
|
|
|
2011-03-09 02:38:46 +00:00
|
|
|
task :default => :spec
|
|
|
|
|
|
|
|
desc "Run spec suite: Browser, Node, JSHint"
|
2011-06-06 04:28:26 +00:00
|
|
|
task :spec => ["jasmine:build", "spec:node", "spec:browser"]
|
2011-03-09 02:38:46 +00:00
|
|
|
|
|
|
|
namespace :spec do
|
|
|
|
desc 'Run specs in Node.js'
|
|
|
|
task :node do
|
2011-05-06 22:34:42 +00:00
|
|
|
raise "Node is required to run all jasmine specs" unless system("node spec/node_suite.js")
|
2011-03-09 02:38:46 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
desc "Run specs in the default browser (MacOS only)"
|
|
|
|
task :browser do
|
|
|
|
system("open spec/runner.html")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-09-05 06:04:48 +00:00
|
|
|
namespace :jasmine do
|
2009-11-26 15:41:10 +00:00
|
|
|
|
|
|
|
desc 'Prepares for distribution'
|
2011-02-27 20:26:38 +00:00
|
|
|
task :dist => ['jasmine:build',
|
|
|
|
'jasmine:doc',
|
|
|
|
'jasmine:build_pages',
|
|
|
|
'jasmine:build_example_project',
|
|
|
|
'jasmine:fill_index_downloads']
|
2009-11-26 15:41:10 +00:00
|
|
|
|
2009-11-26 16:12:06 +00:00
|
|
|
desc 'Check jasmine sources for coding problems'
|
|
|
|
task :lint do
|
2011-03-08 06:30:43 +00:00
|
|
|
puts "Running JSHint via Node.js"
|
2011-02-26 23:07:59 +00:00
|
|
|
system("node jshint/run.js") || exit(1)
|
2009-11-26 16:12:06 +00:00
|
|
|
end
|
|
|
|
|
2011-03-08 06:30:43 +00:00
|
|
|
desc "Alias to JSHint"
|
|
|
|
task :hint => :lint
|
|
|
|
|
2009-09-05 06:04:48 +00:00
|
|
|
desc 'Builds lib/jasmine from source'
|
2010-04-19 22:57:23 +00:00
|
|
|
task :build => :lint do
|
2009-09-05 06:04:48 +00:00
|
|
|
puts 'Building Jasmine from source'
|
2009-12-17 01:27:06 +00:00
|
|
|
|
2009-08-28 05:15:50 +00:00
|
|
|
sources = jasmine_sources
|
|
|
|
version = version_hash
|
2009-11-26 15:41:10 +00:00
|
|
|
|
2010-06-25 00:33:46 +00:00
|
|
|
File.open("lib/jasmine.js", 'w') do |jasmine|
|
|
|
|
sources.each do |source_filename|
|
|
|
|
jasmine.puts(File.read(source_filename))
|
|
|
|
end
|
2009-11-26 15:41:10 +00:00
|
|
|
|
2010-06-25 00:33:46 +00:00
|
|
|
jasmine.puts %{
|
2009-08-21 05:16:14 +00:00
|
|
|
jasmine.version_= {
|
2010-08-26 20:11:54 +00:00
|
|
|
"major": #{version['major'].to_json},
|
|
|
|
"minor": #{version['minor'].to_json},
|
|
|
|
"build": #{version['build'].to_json},
|
2009-08-28 05:23:51 +00:00
|
|
|
"revision": #{Time.now.to_i}
|
2010-06-25 00:33:46 +00:00
|
|
|
};
|
2009-08-21 05:16:14 +00:00
|
|
|
}
|
2010-06-25 00:33:46 +00:00
|
|
|
end
|
2009-11-26 15:41:10 +00:00
|
|
|
|
2010-06-25 00:33:46 +00:00
|
|
|
File.open("lib/jasmine-html.js", 'w') do |jasmine_html|
|
|
|
|
jasmine_html_sources.each do |source_filename|
|
|
|
|
jasmine_html.puts(File.read(source_filename))
|
|
|
|
end
|
|
|
|
end
|
2010-06-23 18:31:38 +00:00
|
|
|
|
2010-06-25 00:33:46 +00:00
|
|
|
FileUtils.cp("src/html/jasmine.css", "lib/jasmine.css")
|
2009-08-28 05:15:50 +00:00
|
|
|
end
|
|
|
|
|
2011-02-27 18:36:13 +00:00
|
|
|
downloads_file = 'pages/download.html'
|
2010-06-26 00:35:08 +00:00
|
|
|
task :need_pages_submodule do
|
2010-11-09 18:10:40 +00:00
|
|
|
unless File.exist?(downloads_file)
|
2010-06-26 00:35:08 +00:00
|
|
|
raise "Jasmine pages submodule isn't present. Run git submodule update --init"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-02-27 20:26:38 +00:00
|
|
|
desc "Build the Github pages HTML"
|
|
|
|
task :build_pages => :need_pages_submodule do
|
|
|
|
Dir.chdir("pages") do
|
|
|
|
FileUtils.rm_r('pages_output') if File.exist?('pages_output')
|
|
|
|
Dir.chdir('pages_source') do
|
|
|
|
system("frank export ../pages_output")
|
|
|
|
end
|
|
|
|
puts "\nCopying Frank output to the root of the gh-pages branch\n\n"
|
|
|
|
system("cp -r pages_output/* .")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-08-28 05:15:50 +00:00
|
|
|
desc "Build jasmine documentation"
|
2010-06-26 00:35:08 +00:00
|
|
|
task :doc => :need_pages_submodule do
|
2009-09-05 06:04:48 +00:00
|
|
|
puts 'Creating Jasmine Documentation'
|
2009-08-28 05:15:50 +00:00
|
|
|
require 'rubygems'
|
|
|
|
require 'jsdoc_helper'
|
|
|
|
|
2010-06-26 00:35:08 +00:00
|
|
|
FileUtils.rm_r "pages/jsdoc", :force => true
|
2009-08-28 05:15:50 +00:00
|
|
|
|
2009-11-10 19:28:47 +00:00
|
|
|
JsdocHelper::Rake::Task.new(:lambda_jsdoc) do |t|
|
2010-06-25 00:33:46 +00:00
|
|
|
t[:files] = jasmine_sources << jasmine_html_sources
|
2009-11-10 22:32:29 +00:00
|
|
|
t[:options] = "-a"
|
2010-06-26 00:35:08 +00:00
|
|
|
t[:out] = "pages/jsdoc"
|
2010-09-22 21:13:53 +00:00
|
|
|
# JsdocHelper bug: template must be relative to the JsdocHelper gem, ick
|
|
|
|
t[:template] = File.join("../".*(100), Dir::getwd, "jsdoc-template")
|
2009-11-10 19:28:47 +00:00
|
|
|
end
|
2009-08-28 05:15:50 +00:00
|
|
|
Rake::Task[:lambda_jsdoc].invoke
|
2009-06-16 14:13:45 +00:00
|
|
|
end
|
2009-08-28 05:15:50 +00:00
|
|
|
|
2010-06-25 00:15:06 +00:00
|
|
|
desc "Build example project"
|
2010-06-26 00:35:08 +00:00
|
|
|
task :build_example_project => :need_pages_submodule do
|
2010-06-25 00:15:06 +00:00
|
|
|
require 'tmpdir'
|
|
|
|
|
|
|
|
temp_dir = File.join(Dir.tmpdir, 'jasmine-standalone-project')
|
|
|
|
puts "Building Example Project in #{temp_dir}"
|
2010-11-09 18:10:40 +00:00
|
|
|
FileUtils.rm_r temp_dir if File.exist?(temp_dir)
|
2010-06-25 00:15:06 +00:00
|
|
|
Dir.mkdir(temp_dir)
|
|
|
|
|
2010-06-25 22:16:43 +00:00
|
|
|
root = File.expand_path(File.dirname(__FILE__))
|
2010-06-25 00:15:06 +00:00
|
|
|
FileUtils.cp_r File.join(root, 'example/.'), File.join(temp_dir)
|
|
|
|
substitute_jasmine_version(File.join(temp_dir, "SpecRunner.html"))
|
|
|
|
|
|
|
|
lib_dir = File.join(temp_dir, "lib/jasmine-#{jasmine_version}")
|
|
|
|
FileUtils.mkdir_p(lib_dir)
|
2010-06-25 00:33:46 +00:00
|
|
|
{
|
|
|
|
"lib/jasmine.js" => "jasmine.js",
|
|
|
|
"lib/jasmine-html.js" => "jasmine-html.js",
|
2010-09-08 20:38:55 +00:00
|
|
|
"src/html/jasmine.css" => "jasmine.css",
|
|
|
|
"MIT.LICENSE" => "MIT.LICENSE"
|
2010-06-25 00:33:46 +00:00
|
|
|
}.each_pair do |src, dest|
|
|
|
|
FileUtils.cp(File.join(root, src), File.join(lib_dir, dest))
|
2010-06-25 00:15:06 +00:00
|
|
|
end
|
|
|
|
|
2010-06-26 00:35:08 +00:00
|
|
|
dist_dir = File.join(root, 'pages/downloads')
|
2010-06-25 17:07:08 +00:00
|
|
|
zip_file_name = File.join(dist_dir, "jasmine-standalone-#{jasmine_version}.zip")
|
|
|
|
puts "Zipping Example Project and moving to #{zip_file_name}"
|
2010-06-26 00:35:08 +00:00
|
|
|
FileUtils.mkdir(dist_dir) unless File.exist?(dist_dir)
|
|
|
|
if File.exist?(zip_file_name)
|
|
|
|
puts "WARNING!!! #{zip_file_name} already exists!"
|
|
|
|
FileUtils.rm(zip_file_name)
|
|
|
|
end
|
2010-06-25 17:07:08 +00:00
|
|
|
exec "cd #{temp_dir} && zip -r #{zip_file_name} . -x .[a-zA-Z0-9]*"
|
2010-06-25 00:15:06 +00:00
|
|
|
end
|
2010-06-26 00:35:08 +00:00
|
|
|
|
2011-05-06 22:34:42 +00:00
|
|
|
end
|