Move to grunt for building all distribution files.
* canonical version number of jasmine-core is now is package.json * `grunt buildDistribution` builds jasmine.js, jasmine-html.js, jasmine.css and outputs them to the dist dir * `grunt buildStandaloneDist` builds the example spec runner files and compresses them to dist/jasmine-VERSION.zip * `grunt compass` compiles jasmine.css * jasmine.Env handling of version is backwards compatible, but uses the version string directly (and nicely deprecated) * Ruby/thor tasks that did the above deleted
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
class JasmineDev < Thor
|
||||
|
||||
desc "build_distribution", "Build Jasmine js & css files"
|
||||
def build_distribution(directory = "./lib/jasmine-core")
|
||||
say JasmineDev.spacer
|
||||
|
||||
say "Building Jasmine distribution from source into #{directory}", :cyan
|
||||
|
||||
say 'Building JavaScript...', :yellow
|
||||
|
||||
inside directory do
|
||||
create_file "jasmine.js",
|
||||
concat_contents_of(jasmine_js_paths),
|
||||
:force => true
|
||||
create_file "jasmine-html.js",
|
||||
concat_contents_of(jasmine_html_js_paths),
|
||||
:force => true
|
||||
end
|
||||
|
||||
say 'Building CSS...', :yellow
|
||||
|
||||
run "compass compile", :capture => true
|
||||
|
||||
copy_file File.join("#{JasmineDev.project_root}", 'src', 'html', 'jasmine.css'),
|
||||
File.join(directory, 'jasmine.css')
|
||||
end
|
||||
|
||||
no_tasks do
|
||||
def jasmine_js_paths
|
||||
paths = JasmineDev::JASMINE_SOURCES[:core].collect do |f|
|
||||
File.join(JasmineDev.project_root, 'src', 'core', f)
|
||||
end
|
||||
|
||||
paths << File.join(JasmineDev.project_root, 'src', 'version.js')
|
||||
paths
|
||||
end
|
||||
|
||||
def jasmine_html_js_paths
|
||||
JasmineDev::JASMINE_SOURCES[:html].collect do |f|
|
||||
File.join(JasmineDev.project_root, 'src', 'html', f)
|
||||
end
|
||||
end
|
||||
|
||||
def concat_contents_of(paths)
|
||||
paths.inject("") do |string, path|
|
||||
string << File.read(path)
|
||||
string
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,50 +0,0 @@
|
||||
class JasmineDev < Thor
|
||||
include Thor::Actions
|
||||
|
||||
desc "build_standalone_distribution", "Build Jasmine standalone distribution"
|
||||
def build_standalone_distribution(download_dir = File.expand_path(File.join('.', 'pages', 'downloads')))
|
||||
invoke :build_distribution
|
||||
|
||||
say JasmineDev.spacer
|
||||
|
||||
say "Building standalone distribution...", :cyan
|
||||
|
||||
say "Staging files...", :yellow
|
||||
|
||||
lib_files.each do |f|
|
||||
copy_file f, File.join(standalone_temp_dir, 'lib', "jasmine-#{version_string}", f)
|
||||
end
|
||||
|
||||
['src', 'spec'].each do |dir|
|
||||
directory File.join('lib', 'jasmine-core', 'example', dir),
|
||||
File.join(standalone_temp_dir, dir)
|
||||
end
|
||||
|
||||
invoke :build_standalone_runner
|
||||
|
||||
say "Zipping distribution...", :yellow
|
||||
|
||||
inside standalone_temp_dir do
|
||||
run_with_output "zip -rq ../jasmine-standalone-#{version_string}.zip ."
|
||||
|
||||
say "Copying Zip file to downloads directory", :yellow
|
||||
run "mkdir -p #{download_dir}"
|
||||
run "cp ../jasmine-standalone-#{version_string}.zip #{download_dir}/"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
no_tasks do
|
||||
def standalone_temp_dir
|
||||
@standalone_temp_dir ||= File.join(Dir.tmpdir, 'jasmine_standalone', "jasmine-standalone-#{version_string}")
|
||||
end
|
||||
|
||||
def lib_files
|
||||
%w{ jasmine.js jasmine-html.js jasmine.css MIT.LICENSE }
|
||||
end
|
||||
|
||||
def example_path
|
||||
File.join('lib', "jasmine-#{version_string}")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,59 +0,0 @@
|
||||
class JasmineDev < Thor
|
||||
include Thor::Actions
|
||||
|
||||
desc "build_standalone_runner", "Build HTML spec runner for Jasmine standalone distribution"
|
||||
|
||||
def build_standalone_runner
|
||||
say JasmineDev.spacer
|
||||
|
||||
say "Building standalone runner HTML...", :cyan
|
||||
|
||||
create_file File.join(standalone_temp_dir, 'SpecRunner.html') do
|
||||
template = Tilt.new(File.join('spec', 'templates','runner.html.erb'))
|
||||
|
||||
scope = OpenStruct.new(:title => "Jasmine Spec Runner",
|
||||
:favicon => example_favicon,
|
||||
:jasmine_tags => example_jasmine_tags,
|
||||
:source_tags => example_source_tags,
|
||||
:spec_file_tags => example_spec_tags)
|
||||
template.render(scope)
|
||||
end
|
||||
end
|
||||
|
||||
no_tasks do
|
||||
def standalone_temp_dir
|
||||
@standalone_temp_dir ||= File.join(Dir.tmpdir, 'jasmine_standalone', "jasmine-standalone-#{version_string}")
|
||||
end
|
||||
|
||||
def example_path
|
||||
File.join('lib', "jasmine-#{version_string}")
|
||||
end
|
||||
|
||||
def example_favicon
|
||||
%Q{<link rel="shortcut icon" type="image/png" href="#{example_path}/jasmine_favicon.png">}
|
||||
end
|
||||
|
||||
def script_tags_for(files)
|
||||
srcs = (files.is_a?(String) ? [files] : files)
|
||||
srcs.inject([]) do |tags, file|
|
||||
tags << %Q{<script type="text/javascript" src="#{file}"></script>}
|
||||
tags
|
||||
end.join("\n ")
|
||||
end
|
||||
|
||||
def example_jasmine_tags
|
||||
tags = %Q{<link rel="stylesheet" type="text/css" href="#{example_path}/jasmine.css">}
|
||||
tags << "\n "
|
||||
tags << script_tags_for(["#{example_path}/jasmine.js", "#{example_path}/jasmine-html.js"])
|
||||
tags
|
||||
end
|
||||
|
||||
def example_source_tags
|
||||
script_tags_for ['src/Player.js', 'src/Song.js']
|
||||
end
|
||||
|
||||
def example_spec_tags
|
||||
script_tags_for ['spec/SpecHelper.js', 'spec/PlayerSpec.js']
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -5,7 +5,7 @@ class JasmineDev < Thor
|
||||
def execute_specs_in_node
|
||||
return unless node_installed?
|
||||
|
||||
invoke :build_distribution
|
||||
`grunt buildDistribution`
|
||||
invoke :count_specs
|
||||
|
||||
say JasmineDev.spacer
|
||||
@@ -20,7 +20,9 @@ class JasmineDev < Thor
|
||||
desc "execute_specs_in_browser", "Run all relevent specs in your default browser"
|
||||
|
||||
def execute_specs_in_browser
|
||||
invoke :build_distribution
|
||||
return unless node_installed?
|
||||
|
||||
`grunt buildDistribution`
|
||||
invoke :count_specs
|
||||
|
||||
say JasmineDev.spacer
|
||||
|
||||
@@ -8,9 +8,6 @@ class JasmineDev < Thor
|
||||
|
||||
return unless pages_submodule_installed?
|
||||
|
||||
invoke :write_version_files
|
||||
invoke :build_distribution
|
||||
invoke :build_standalone_distribution
|
||||
invoke :build_github_pages
|
||||
end
|
||||
end
|
||||
@@ -1,27 +0,0 @@
|
||||
class JasmineDev < Thor
|
||||
JASMINE_SOURCES = {
|
||||
:core => [
|
||||
"base.js",
|
||||
"util.js",
|
||||
"ExceptionFormatter.js",
|
||||
"ExpectationResult.js",
|
||||
"Env.js",
|
||||
"JsApiReporter.js",
|
||||
"Matchers.js",
|
||||
"PrettyPrinter.js",
|
||||
"QueueRunner.js",
|
||||
"Spec.js",
|
||||
"Suite.js",
|
||||
"Clock.js",
|
||||
"DelayedFunctionScheduler.js",
|
||||
"ReportDispatcher.js"
|
||||
],
|
||||
|
||||
:html => [
|
||||
"HtmlReporter.js",
|
||||
"HtmlSpecFilter.js",
|
||||
"ResultsNode.js",
|
||||
"QueryString.js"
|
||||
]
|
||||
}
|
||||
end
|
||||
@@ -1,62 +0,0 @@
|
||||
class JasmineDev < Thor
|
||||
|
||||
desc "write_version_files", "Write out version files"
|
||||
|
||||
def write_version_files
|
||||
say JasmineDev.spacer
|
||||
|
||||
say "Building version files", :cyan
|
||||
|
||||
scope = OpenStruct.new(:major => version_object["major"],
|
||||
:minor => version_object["minor"],
|
||||
:build => version_object["build"],
|
||||
:release_candidate => version_object["release_candidate"],
|
||||
:revision => Time.now.to_i)
|
||||
|
||||
js_template = Tilt.new(File.join(JasmineDev.project_root, 'src', 'templates', 'version.js.erb'))
|
||||
create_file File.join(JasmineDev.project_root, 'src', 'version.js'), :force => true do
|
||||
js_template.render(scope)
|
||||
end
|
||||
|
||||
rb_template = Tilt.new(File.join(JasmineDev.project_root, 'src', 'templates', 'version.rb.erb'))
|
||||
|
||||
create_file File.join(JasmineDev.project_root, 'lib', 'jasmine-core', 'version.rb'), :force => true do
|
||||
rb_template.render(scope)
|
||||
end
|
||||
end
|
||||
|
||||
desc "display_version", "Display version currently stored in source"
|
||||
|
||||
def display_version
|
||||
|
||||
say "Current version information from src/version.json", :cyan
|
||||
|
||||
say "Display version: "
|
||||
say "#{version_string}", :yellow
|
||||
|
||||
say "Version object: "
|
||||
say "#{version_object_old}", :yellow
|
||||
end
|
||||
|
||||
no_tasks do
|
||||
def version
|
||||
@version ||= File.read(File.join(JasmineDev.project_root, 'src', 'version.json'))
|
||||
end
|
||||
|
||||
def version_string
|
||||
display = "#{version_object['major']}.#{version_object['minor']}.#{version_object['build']}"
|
||||
display += ".rc#{version_object['release_candidate']}" if version_object['release_candidate']
|
||||
display
|
||||
end
|
||||
|
||||
def version_object
|
||||
@version_object ||= JSON.parse(version)
|
||||
end
|
||||
|
||||
def version_object_old
|
||||
version.gsub("\n", " ").
|
||||
gsub(/\s+/, " ").
|
||||
gsub(/\}\s+$/, "}")
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user