This commit is contained in:
Davis W. Frank
2011-06-20 08:46:37 -07:00
32 changed files with 16189 additions and 141 deletions

View File

@@ -2,10 +2,10 @@ desc "Build core jasmine.js"
task :build_dist => [:lint, :write_version_file] do
puts 'Building Jasmine distribution from source'.cyan
concat_into('lib/jasmine.js') { core_sources + version_source_file }
concat_into('lib/jasmine-html.js') { html_sources }
concat_into('lib/jasmine-core/jasmine.js') { core_sources + version_source_file }
concat_into('lib/jasmine-core/jasmine-html.js') { html_sources }
FileUtils.cp('src/html/jasmine.css', 'lib/jasmine.css')
FileUtils.cp('src/html/jasmine.css', 'lib/jasmine-core/jasmine.css')
end
def concat_into(output_file, &block)
@@ -18,7 +18,7 @@ def concat_into(output_file, &block)
end
desc 'Check jasmine sources for coding problems'
task :lint do
task :lint => :require_node do
puts "Running JSHint via Node.js".cyan
system("node jshint/run.js") || exit(1)
end
@@ -30,7 +30,7 @@ task :write_version_file do
scope = OpenStruct.new(:major => version_hash["major"],
:minor => version_hash["minor"],
:build => version_hash["build"],
:rc => version_hash["rc"],
:release_candidate => version_hash["release_candidate"],
:revision => Time.now.to_i)
File.open('src/version.js', 'w+') do |f|
@@ -41,4 +41,4 @@ end
def version_source_file
Dir.glob('src/version.js')
end
end

View File

@@ -1,14 +1,14 @@
require 'ostruct'
desc "build the browser spec for Jasmine core based on current tree"
#build the browser spec for Jasmine core based on current tree
task :build_runner_html do
template = Tilt.new('spec/templates/runner.html.erb')
File.open('spec/runner.html', 'w+') do |f|
scope = OpenStruct.new(:title => "Jasmine Spec Runner: Jasmine Core",
:favicon => favicon,
:jasmine_tags => core_jasmine_tags,
:source_tags => other_source_file_tags,
:jasmine_tags => jasmine_tags,
:source_tags => source_tags,
:spec_file_tags => spec_file_tags)
f << template.render(scope)
end
@@ -20,10 +20,10 @@ def favicon
HTML
end
def core_jasmine_tags
tags = %Q{<link href="../lib/jasmine.css" rel="stylesheet"/>}
def jasmine_tags
tags = %Q{<link href="../lib/jasmine-core/jasmine.css" rel="stylesheet"/>}
tags << "\n "
tags << script_tags_for("../lib/jasmine.js")
tags << script_tags_for("../lib/jasmine-core/jasmine.js")
tags << "\n "
tags << undefined_catch
tags
@@ -38,7 +38,7 @@ def undefined_catch
HTML
end
def other_source_file_tags
def source_tags
other_files = html_sources + console_sources
script_tags_for other_files.collect { |f| "../#{f}" }
end

View File

@@ -1,45 +1,45 @@
require 'json'
def core_sources
first_sources = JSON.parse(File.read('src/SourcesList.json')).collect { |f| "src/core/#{f}" }
first_sources = JSON.parse(File.read('./src/SourcesList.json')).collect { |f| "./src/core/#{f}" }
remaining_sources = Dir.glob('src/core/*.js').reject { |f| first_sources.include?(f) }.sort
remaining_sources = Dir.glob('./src/core/*.js').reject { |f| first_sources.include?(f) }.sort
first_sources + remaining_sources
end
def html_sources
Dir.glob('src/html/*.js')
Dir.glob('./src/html/*.js')
end
def console_sources
Dir.glob('src/console/*.js')
Dir.glob('./src/console/*.js')
end
def core_specfiles
Dir.glob('spec/core/*.js')
Dir.glob('./spec/core/*.js')
end
def html_specfiles
Dir.glob('spec/html/*.js')
Dir.glob('./spec/html/*.js')
end
def console_specfiles
Dir.glob('spec/console/*.js')
Dir.glob('./spec/console/*.js')
end
def version_string
version = "#{version_hash['major']}.#{version_hash['minor']}.#{version_hash['build']}"
version += ".rc#{version_hash['rc']}" if version_hash['rc']
version += ".rc#{version_hash['release_candidate']}" if version_hash['release_candidate']
version
end
def version_hash
@version ||= JSON.parse(File.new("src/version.json").read);
@version ||= JSON.parse(File.new("./src/version.json").read);
end
def script_tags_for(files)
script_tag = Tilt::new('spec/templates/script_tag.html.erb')
script_tag = Tilt::new('./spec/templates/script_tag.html.erb')
srcs = (files.is_a?(String) ? [files] : files)
srcs.inject([]) do |tags, f|
@@ -47,4 +47,4 @@ def script_tags_for(files)
tags << script_tag.render(scope)
tags
end.join("\n ")
end
end

View File

@@ -15,7 +15,7 @@ task "spec:browser" => [:count_specs, :build_runner_html] do
system("open spec/runner.html")
end
desc "Count number of specs in Jasmine core"
#Count number of specs in Jasmine core
task :count_specs do
core_specs_count = count_specs_in(Dir.glob('spec/core/*.js'))
console_spec_count = count_specs_in(Dir.glob('spec/console/*.js'))

View File

@@ -14,15 +14,16 @@ task :standalone => [:require_pages_submodule, :build_spec_runner_html] do
FileUtils.mkdir_p(temp_dir)
root = File.expand_path(File.join(File.dirname(__FILE__), '..'))
FileUtils.cp_r File.join(root, 'example/.'), File.join(temp_dir)
FileUtils.mkdir_p(File.join(root, "example"))
FileUtils.cp_r(File.join(root, 'example/.'), File.join(temp_dir))
lib_dir = File.join(temp_dir, "lib/jasmine-#{version_string}")
FileUtils.mkdir_p(lib_dir)
{
"images/jasmine_favicon.png" => "jasmine_favicon.png",
"lib/jasmine.js" => "jasmine.js",
"lib/jasmine-html.js" => "jasmine-html.js",
"src/html/jasmine.css" => "jasmine.css",
"lib/jasmine-core/jasmine.js" => "jasmine.js",
"lib/jasmine-core/jasmine-html.js" => "jasmine-html.js",
"lib/jasmine-core/jasmine.css" => "jasmine.css",
"MIT.LICENSE" => "MIT.LICENSE"
}.each_pair do |src, dest|
FileUtils.cp(File.join(root, src), File.join(lib_dir, dest))
@@ -35,11 +36,11 @@ task :standalone => [:require_pages_submodule, :build_spec_runner_html] do
exec "cd #{zip_root} && zip #{zip_file_name} -r . -x .[a-zA-Z0-9]*"
end
desc "Build SpecRunner.html for standalone dist example project"
#Build SpecRunner.html for standalone dist example project
task :build_spec_runner_html do
template = Tilt.new('spec/templates/runner.html.erb')
File.open('example/SpecRunner.html', 'w+') do |f|
File.open('lib/jasmine-core/example/SpecRunner.html', 'w+') do |f|
scope = OpenStruct.new(:title => "Jasmine Spec Runner",
:favicon => example_favicon,
:jasmine_tags => example_jasmine_tags,
@@ -81,4 +82,4 @@ task :protect_current_dist_zip do
zip_file_name = File.join(dist_dir, "jasmine-standalone-#{version_string}.zip")
raise "STOPPED: #{zip_file_name} already exists" if File.exist?(zip_file_name)
end
end

5
tasks/version.rb Normal file
View File

@@ -0,0 +1,5 @@
task :version do
require 'pp'
pp version_hash
pp version_string
end