Jasmine core files should be available to other gems

This commit is contained in:
ragaskar
2011-04-29 22:41:18 -04:00
parent 48c8d2cc1f
commit 995cdd6e3b
16 changed files with 133518 additions and 81 deletions

View File

@@ -1,6 +1,3 @@
source :rubygems source :rubygems
gem "json_pure", "~>1.4.3" gemspec
gem "frank"
gem "ragaskar-jsdoc_helper"
gem "rake", "0.8.7"

View File

@@ -1,37 +1,26 @@
require 'json' require 'bundler'
Bundler::GemHelper.install_tasks
def jasmine_sources def sources
first_sources = JSON.parse(File.read('src/SourcesList.json')).collect {|f| "src/core/#{f}"} dependencies = JSON.parse(File.read('src/SourcesList.json')).collect {|f| "src/core/#{f}"}
dependencies + Dir.glob('src/core/*.js').reject {|f| dependencies.include?(f)}.sort
sources = first_sources
sources += Dir.glob('src/core/*.js').reject {|f| first_sources.include?(f)}.sort
sources
end end
def jasmine_html_sources def html_sources
["src/html/TrivialReporter.js"] ["./src/html/TrivialReporter.js"]
end
def jasmine_version
"#{version_hash['major']}.#{version_hash['minor']}.#{version_hash['build']}"
end end
def version_hash def version_hash
require 'json' @version ||= JSON.parse(File.new("src/core/version.json").read)
@version ||= JSON.parse(File.new("src/core/version.json").read);
end end
def substitute_version(filename)
def substitute_jasmine_version(filename)
contents = File.read(filename) contents = File.read(filename)
contents = contents.gsub(/##JASMINE_VERSION##/, (jasmine_version)) contents = contents.gsub(/##JASMINE_VERSION##/, (jasmine_version))
contents = contents.gsub(/[^\n]*REMOVE_THIS_LINE_FROM_BUILD[^\n]*/, '') contents = contents.gsub(/[^\n]*REMOVE_THIS_LINE_FROM_BUILD[^\n]*/, '')
File.open(filename, 'w') { |f| f.write(contents) } File.open(filename, 'w') { |f| f.write(contents) }
end end
require 'bundler'
Bundler::GemHelper.install_tasks
task :default => :spec task :default => :spec
desc "Run spec suite: Browser, Node, JSHint" desc "Run spec suite: Browser, Node, JSHint"
@@ -53,10 +42,10 @@ namespace :jasmine do
desc 'Prepares for distribution' desc 'Prepares for distribution'
task :dist => ['jasmine:build', task :dist => ['jasmine:build',
'jasmine:doc', 'jasmine:doc',
'jasmine:build_pages', 'jasmine:build_pages',
'jasmine:build_example_project', 'jasmine:build_example_project',
'jasmine:fill_index_downloads'] 'jasmine:fill_index_downloads']
desc 'Check jasmine sources for coding problems' desc 'Check jasmine sources for coding problems'
task :lint do task :lint do
@@ -71,10 +60,9 @@ namespace :jasmine do
task :build => :lint do task :build => :lint do
puts 'Building Jasmine from source' puts 'Building Jasmine from source'
sources = jasmine_sources version = Jasmine::Core::VERSION_HASH
version = version_hash
File.open("lib/jasmine.js", 'w') do |jasmine| File.open("./lib/jasmine-core/jasmine.js", 'w') do |jasmine|
sources.each do |source_filename| sources.each do |source_filename|
jasmine.puts(File.read(source_filename)) jasmine.puts(File.read(source_filename))
end end
@@ -86,16 +74,16 @@ jasmine.version_= {
"build": #{version['build'].to_json}, "build": #{version['build'].to_json},
"revision": #{Time.now.to_i} "revision": #{Time.now.to_i}
}; };
} }
end end
File.open("lib/jasmine-html.js", 'w') do |jasmine_html| File.open("./lib/jasmine-core/jasmine-html.js", 'w') do |jasmine_html|
jasmine_html_sources.each do |source_filename| html_sources.each do |source_filename|
jasmine_html.puts(File.read(source_filename)) jasmine_html.puts(File.read(source_filename))
end end
end end
FileUtils.cp("src/html/jasmine.css", "lib/jasmine.css") FileUtils.cp("./src/html/jasmine.css", "lib/jasmine-core/jasmine.css")
end end
downloads_file = 'pages/download.html' downloads_file = 'pages/download.html'
@@ -126,7 +114,7 @@ jasmine.version_= {
FileUtils.rm_r "pages/jsdoc", :force => true FileUtils.rm_r "pages/jsdoc", :force => true
JsdocHelper::Rake::Task.new(:lambda_jsdoc) do |t| JsdocHelper::Rake::Task.new(:lambda_jsdoc) do |t|
t[:files] = jasmine_sources << jasmine_html_sources t[:files] = jasmine_sources << html_sources
t[:options] = "-a" t[:options] = "-a"
t[:out] = "pages/jsdoc" t[:out] = "pages/jsdoc"
# JsdocHelper bug: template must be relative to the JsdocHelper gem, ick # JsdocHelper bug: template must be relative to the JsdocHelper gem, ick
@@ -146,15 +134,15 @@ jasmine.version_= {
root = File.expand_path(File.dirname(__FILE__)) root = File.expand_path(File.dirname(__FILE__))
FileUtils.cp_r File.join(root, 'example/.'), File.join(temp_dir) FileUtils.cp_r File.join(root, 'example/.'), File.join(temp_dir)
substitute_jasmine_version(File.join(temp_dir, "SpecRunner.html")) substitute_version(File.join(temp_dir, "SpecRunner.html"))
lib_dir = File.join(temp_dir, "lib/jasmine-#{jasmine_version}") lib_dir = File.join(temp_dir, "lib/jasmine-#{jasmine_version}")
FileUtils.mkdir_p(lib_dir) FileUtils.mkdir_p(lib_dir)
{ {
"lib/jasmine.js" => "jasmine.js", "lib/jasmine.js" => "jasmine.js",
"lib/jasmine-html.js" => "jasmine-html.js", "lib/jasmine-html.js" => "jasmine-html.js",
"src/html/jasmine.css" => "jasmine.css", "src/html/jasmine.css" => "jasmine.css",
"MIT.LICENSE" => "MIT.LICENSE" "MIT.LICENSE" => "MIT.LICENSE"
}.each_pair do |src, dest| }.each_pair do |src, dest|
FileUtils.cp(File.join(root, src), File.join(lib_dir, dest)) FileUtils.cp(File.join(root, src), File.join(lib_dir, dest))
end end

View File

@@ -1,21 +0,0 @@
# Project-specific configuration for CruiseControl.rb
Project.configure do |project|
# Send email notifications about broken and fixed builds to email1@your.site, email2@your.site (default: send to nobody)
# project.email_notifier.emails = ['email1@your.site', 'email2@your.site']
# Set email 'from' field to john@doe.com:
# project.email_notifier.from = 'john@doe.com'
# Build the project by invoking rake task 'custom'
project.rake_task = 'jasmine:test:ci:saucelabs'
# Build the project by invoking shell script "build_my_app.sh". Keep in mind that when the script is invoked,
# current working directory is <em>[cruise&nbsp;data]</em>/projects/your_project/work, so if you do not keep build_my_app.sh
# in version control, it should be '../build_my_app.sh' instead
#project.build_command = 'cp ../saucelabs.yml .'
# Ping Subversion for new revisions every 5 minutes (default: 30 seconds)
# project.scheduler.polling_interval = 5.minutes
end

View File

@@ -3,19 +3,20 @@ $:.push File.expand_path("../lib", __FILE__)
require "jasmine-core/version" require "jasmine-core/version"
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = "jasmine-core" s.name = "jasmine-core"
s.version = Jasmine::Core::VERSION s.version = Jasmine::Core::VERSION
s.platform = Gem::Platform::RUBY s.platform = Gem::Platform::RUBY
s.authors = ["TODO: Write your name"] s.authors = ["Rajan Agaskar", "Davis Frank", "Christian Williams"]
s.email = ["TODO: Write your email address"] s.summary = %q{JavaScript BDD framework}
s.homepage = "" s.description = %q{Test your JavaScript without any framework dependencies, in any environment, and with a nice descriptive syntax.}
s.summary = %q{TODO: Write a gem summary} s.email = %q{jasmine-js@googlegroups.com}
s.description = %q{TODO: Write a gem description} s.homepage = "http://pivotal.github.com/jasmine"
s.rubyforge_project = "jasmine-core" s.rubyforge_project = "jasmine-core"
s.files = `git ls-files`.split("\n") s.files = Dir.glob("./lib/**/*")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"] s.require_paths = ["lib"]
s.add_development_dependency "json_pure", ">= 1.4.3"
s.add_development_dependency "frank"
s.add_development_dependency "ragaskar-jsdoc_helper"
end end

View File

@@ -1,5 +1,17 @@
module Jasmine module Jasmine
module Core module Core
# Your code goes here... class << self
def path
File.join(File.dirname(__FILE__), "jasmine-core")
end
def js_files
(["jasmine.js"] + Dir.glob(File.join(path, "*.js"))).map { |f| File.basename(f) }.uniq
end
def css_files
Dir.glob(File.join(path, "*.css")).map { |f| File.basename(f) }
end
end
end end
end end

View File

@@ -991,7 +991,7 @@ jasmine.Block = function(env, func, spec) {
this.spec = spec; this.spec = spec;
}; };
jasmine.Block.prototype.execute = function(onComplete) { jasmine.Block.prototype.execute = function(onComplete) {
try { try {
this.func.apply(this.spec); this.func.apply(this.spec);
} catch (e) { } catch (e) {
@@ -1031,7 +1031,7 @@ jasmine.JsApiReporter.prototype.summarize_ = function(suiteOrSpec) {
type: isSuite ? 'suite' : 'spec', type: isSuite ? 'suite' : 'spec',
children: [] children: []
}; };
if (isSuite) { if (isSuite) {
var children = suiteOrSpec.children(); var children = suiteOrSpec.children();
for (var i = 0; i < children.length; i++) { for (var i = 0; i < children.length; i++) {
@@ -1647,7 +1647,7 @@ jasmine.PrettyPrinter.prototype.format = function(value) {
jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) { jasmine.PrettyPrinter.prototype.iterateObject = function(obj, fn) {
for (var property in obj) { for (var property in obj) {
if (property == '__Jasmine_been_here_before__') continue; if (property == '__Jasmine_been_here_before__') continue;
fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) !== jasmine.undefined && fn(property, obj.__lookupGetter__ ? (obj.__lookupGetter__(property) !== jasmine.undefined &&
obj.__lookupGetter__(property) !== null) : false); obj.__lookupGetter__(property) !== null) : false);
} }
}; };
@@ -1750,7 +1750,7 @@ jasmine.Queue.prototype.next_ = function() {
while (goAgain) { while (goAgain) {
goAgain = false; goAgain = false;
if (self.index < self.blocks.length && !this.abort) { if (self.index < self.blocks.length && !this.abort) {
var calledSynchronously = true; var calledSynchronously = true;
var completedSynchronously = false; var completedSynchronously = false;
@@ -1788,7 +1788,7 @@ jasmine.Queue.prototype.next_ = function() {
if (completedSynchronously) { if (completedSynchronously) {
onComplete(); onComplete();
} }
} else { } else {
self.running = false; self.running = false;
if (self.onComplete) { if (self.onComplete) {
@@ -2470,3 +2470,4 @@ jasmine.version_= {
"build": 0, "build": 0,
"revision": 1307546962 "revision": 1307546962
}; };

View File

@@ -1,5 +1,7 @@
module Jasmine module Jasmine
module Core module Core
VERSION = "0.0.1" require 'json'
VERSION_HASH = JSON.parse(File.new(File.join(File.dirname(__FILE__), "..", "..", "src/version.json")).read);
VERSION = "#{VERSION_HASH['major']}.#{VERSION_HASH['minor']}.#{VERSION_HASH['build']}"
end end
end end

133457
tags Normal file

File diff suppressed because one or more lines are too long