This repository has been archived by the owner on Jan 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Configuration of Rack server moves into actual Jasmine config - Mapping of served files moved out of configuration - Simplify Rack application and run.html.erb template - Remove cruft: many fixtures no longer used. Jasmine Redirect (previously redirected run.html to /) removed. - Jasmine bootstrap moved out of runner template, into js file. - Add ability to customize jasmine/boot files. - Wrap Jasmine::Core calls in CoreConfiguration - Fix jasmine.yml (was missing spec_file, helper file defaults). - Regression: asset pipeline not supported after this refactor. - Break jasmine.yml processing out into a separate class.
- v3.99.0
- v3.10.0
- v3.9.2
- v3.9.1
- v3.9.0
- v3.8.1
- v3.8.0
- v3.7.0
- v3.6.0
- v3.5.1
- v3.5.0
- v3.4.0
- v3.3.0
- v3.2.0
- v3.1.0
- v3.0.0
- v2.99.0
- v2.9.0
- v2.8.0
- v2.7.0
- v2.6.0
- v2.5.2
- v2.5.1
- v2.5.0
- v2.4.0
- v2.3.1
- v2.3.0
- v2.2.0
- v2.1.0
- v2.0.3
- v2.0.2
- v2.0.1
- v2.0.0
- v2.0.0.rc5
- v2.0.0.rc4
- v2.0.0.rc3
- v2.0.0.rc2
- v1.3.2
- v1.3.1
- 1.3.1-rails-4-support
Davis W. Frank & Rajan Agaskar
committed
Nov 28, 2012
1 parent
d3c1bea
commit 76b7cde
Showing
36 changed files
with
877 additions
and
895 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,122 +1,56 @@ | ||
module Jasmine | ||
class Config | ||
attr_accessor :src_mapper | ||
|
||
require 'yaml' | ||
require 'erb' | ||
require 'json' | ||
|
||
def match_files(dir, patterns) | ||
dir = File.expand_path(dir) | ||
negative, positive = patterns.partition {|pattern| /^!/ =~ pattern} | ||
chosen, negated = [positive, negative].collect do |patterns| | ||
patterns.collect do |pattern| | ||
matches = Dir.glob(File.join(dir, pattern.gsub(/^!/,''))) | ||
matches.empty? && !(pattern =~ /\*|^\!/) ? pattern : matches.collect {|f| f.sub("#{dir}/", "")}.sort | ||
end.flatten.uniq | ||
end | ||
chosen - negated | ||
end | ||
|
||
def simple_config | ||
config = File.exist?(simple_config_file) ? YAML::load(ERB.new(File.read(simple_config_file)).result(binding)) : false | ||
config || {} | ||
end | ||
|
||
|
||
def spec_path | ||
"/__spec__" | ||
end | ||
|
||
def root_path | ||
"/__root__" | ||
end | ||
|
||
def js_files(spec_filter = nil) | ||
spec_files_to_include = spec_filter.nil? ? spec_files : match_files(spec_dir, [spec_filter]) | ||
src_files.collect {|f| "/" + f } + helpers.collect {|f| File.join(spec_path, f) } + spec_files_to_include.collect {|f| File.join(spec_path, f) } | ||
end | ||
|
||
def user_stylesheets | ||
stylesheets.collect {|f| "/" + f } | ||
end | ||
|
||
def spec_files_full_paths | ||
spec_files.collect {|spec_file| File.join(spec_dir, spec_file) } | ||
end | ||
|
||
def project_root | ||
Dir.pwd | ||
end | ||
|
||
def simple_config_file | ||
File.join(project_root, 'spec/javascripts/support/jasmine.yml') | ||
end | ||
|
||
def src_dir | ||
if simple_config['src_dir'] | ||
File.join(project_root, simple_config['src_dir']) | ||
else | ||
project_root | ||
end | ||
end | ||
|
||
def spec_dir | ||
if simple_config['spec_dir'] | ||
File.join(project_root, simple_config['spec_dir']) | ||
else | ||
File.join(project_root, 'spec/javascripts') | ||
end | ||
end | ||
|
||
def helpers | ||
if simple_config['helpers'] | ||
match_files(spec_dir, simple_config['helpers']) | ||
else | ||
match_files(spec_dir, ["helpers/**/*.js"]) | ||
end | ||
end | ||
|
||
def src_files | ||
return [] unless simple_config['src_files'] | ||
def self.configure(&block) | ||
block.call(self.config) | ||
end | ||
|
||
if self.src_mapper | ||
self.src_mapper.files(simple_config['src_files']) | ||
else | ||
match_files(src_dir, simple_config['src_files']) | ||
end | ||
end | ||
def self.initialize_config | ||
return if @config | ||
@config = Jasmine::Configuration.new | ||
core_config = Jasmine::CoreConfiguration.new | ||
|
||
@config.add_path_mapper(Jasmine::PathMapper) | ||
@config.jasmine_path = jasmine_path = "/__jasmine__" | ||
@config.src_path = src_path = "/" | ||
@config.spec_path = spec_path = "/__spec__" | ||
@config.boot_path = boot_path = "/__boot__" | ||
|
||
@config.jasmine_dir = core_config.path | ||
@config.boot_dir = core_config.boot_path | ||
@config.boot_files = lambda { core_config.boot_files } | ||
@config.jasmine_files = lambda { core_config.js_files } | ||
@config.jasmine_css_files = lambda { core_config.css_files } | ||
|
||
@config.add_rack_path(jasmine_path, lambda { Rack::File.new(config.jasmine_dir) }) | ||
@config.add_rack_path(boot_path, lambda { Rack::File.new(config.boot_dir) }) | ||
@config.add_rack_path(spec_path, lambda { Rack::File.new(config.spec_dir) }) | ||
@config.add_rack_path(src_path, lambda { | ||
Rack::Cascade.new([ | ||
Rack::URLMap.new('/' => Rack::File.new(config.src_dir)), | ||
Rack::Jasmine::Runner.new(Jasmine::Page.new(config)) | ||
]) | ||
}) | ||
|
||
@config.add_rack_app(Rack::Head) | ||
@config.add_rack_app(Rack::Jasmine::CacheControl) | ||
end | ||
|
||
def spec_files | ||
if simple_config['spec_files'] | ||
match_files(spec_dir, simple_config['spec_files']) | ||
else | ||
match_files(spec_dir, ["**/*[sS]pec.js"]) | ||
end | ||
end | ||
def self.config | ||
initialize_config | ||
@config | ||
end | ||
|
||
def stylesheets | ||
if simple_config['stylesheets'] | ||
match_files(src_dir, simple_config['stylesheets']) | ||
else | ||
[] | ||
def self.load_configuration_from_yaml(path = nil) | ||
path ||= File.join(Dir.pwd, 'spec', 'javascripts', 'support', 'jasmine.yml') | ||
if File.exist?(path) | ||
yaml_config = Jasmine::YamlConfigParser.new(path, Dir.pwd, Jasmine::PathExpander.method(:expand), YAML.method(:load_file)) | ||
Jasmine.configure do |config| | ||
config.src_files = lambda { yaml_config.src_files } | ||
config.spec_files = lambda { yaml_config.helpers + yaml_config.spec_files } | ||
config.css_files = lambda { yaml_config.css_files } | ||
config.src_dir = yaml_config.src_dir | ||
config.spec_dir = yaml_config.spec_dir | ||
end | ||
end | ||
|
||
def jasmine_host | ||
ENV["JASMINE_HOST"] || 'http://localhost' | ||
end | ||
|
||
def port | ||
@port ||= ENV["JASMINE_PORT"] || Jasmine.find_unused_port | ||
end | ||
|
||
def jasmine_stylesheets | ||
::Jasmine::Core.css_files.map {|f| "/__JASMINE_ROOT__/#{f}"} | ||
end | ||
|
||
def jasmine_javascripts | ||
::Jasmine::Core.js_files.map {|f| "/__JASMINE_ROOT__/#{f}" } | ||
end | ||
end | ||
|
||
end |
Oops, something went wrong.