#!/usr/bin/env ruby require 'yaml' require 'fileutils' require 'getoptlong' opts = GetoptLong.new( [ '--colors', '-c', GetoptLong::NO_ARGUMENT ] ) colors = false opts.each do |opt, arg| case opt when '--colors' colors = true end end data = YAML.load_file(ARGV.shift || 'spec/javascripts/support/jasmine.yml') gem_dir = File.expand_path('../..', __FILE__) puts "Running Jasmine specs..." files = [ 'file://' + File.join(gem_dir, 'jasmine/lib/jasmine.js'), 'file://' + File.join(gem_dir, 'jasmine/lib/jasmine-html.js'), 'file://' + File.join(gem_dir, 'jasmine/lib/jasmine.css') ] DEFAULTS = { 'spec_files' => [ '**/*[sS]pec.js' ], 'helpers' => [ 'helpers/**/*.js' ], 'spec_dir' => 'spec/javascripts' } files += [ [ 'src_files', 'src_dir' ], [ 'stylesheets', 'src_dir' ], [ 'helpers', 'spec_dir' ], [ 'spec_files', 'spec_dir' ] ].collect do |searches, root| data[searches] ||= DEFAULTS[searches] data[root] ||= DEFAULTS[root] if data[searches] data[searches].collect do |search| path = search path = File.join(data[root], path) if data[root] Dir[path] end end end files = files.flatten.compact.collect { |file| case File.extname(file) when '.js' %{} when '.css' %{} end } output = <<-HTML