This repository has been archived by the owner on Jan 16, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Files, locals for RunnerConfig, Config renamed
- Loading branch information
Showing
11 changed files
with
382 additions
and
211 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,109 @@ | ||
module Jasmine | ||
class RunnerConfig | ||
def initialize(user_config) | ||
@user_config = user_config | ||
class Config | ||
require 'yaml' | ||
require 'erb' | ||
|
||
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 css_files | ||
@user_config.jasmine_stylesheets + @user_config.user_stylesheets | ||
def simple_config | ||
config = File.exist?(simple_config_file) ? YAML::load(ERB.new(File.read(simple_config_file)).result(binding)) : false | ||
config || {} | ||
end | ||
|
||
def jasmine_files | ||
@user_config.jasmine_javascripts | ||
|
||
def spec_path | ||
"/__spec__" | ||
end | ||
|
||
def js_files | ||
@user_config.js_files | ||
def root_path | ||
"/__root__" | ||
end | ||
|
||
def spec_files | ||
@user_config.spec_files | ||
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 | ||
@user_config.spec_files_full_paths | ||
spec_files.collect {|spec_file| File.join(spec_dir, spec_file) } | ||
end | ||
|
||
def spec_path | ||
@user_config.spec_path | ||
def project_root | ||
Dir.pwd | ||
end | ||
|
||
def spec_dir | ||
@user_config.spec_dir | ||
def simple_config_file | ||
File.join(project_root, 'spec/javascripts/support/jasmine.yml') | ||
end | ||
|
||
def src_dir | ||
@user_config.src_dir | ||
if simple_config['src_dir'] | ||
File.join(project_root, simple_config['src_dir']) | ||
else | ||
project_root | ||
end | ||
end | ||
|
||
def project_root | ||
@user_config.project_root | ||
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 root_path | ||
@user_config.root_path | ||
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 | ||
if simple_config['src_files'] | ||
match_files(src_dir, simple_config['src_files']) | ||
else | ||
[] | ||
end | ||
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 stylesheets | ||
if simple_config['stylesheets'] | ||
match_files(src_dir, simple_config['stylesheets']) | ||
else | ||
[] | ||
end | ||
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 |
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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
module Jasmine | ||
class RunnerConfig | ||
def initialize(config) | ||
@config = config | ||
end | ||
|
||
def css_files | ||
@config.jasmine_stylesheets + @config.user_stylesheets | ||
end | ||
|
||
def jasmine_files | ||
@config.jasmine_javascripts | ||
end | ||
|
||
def js_files | ||
@config.js_files | ||
end | ||
|
||
def spec_files | ||
@config.spec_files | ||
end | ||
|
||
def spec_files_full_paths | ||
@config.spec_files_full_paths | ||
end | ||
|
||
def spec_path | ||
@config.spec_path | ||
end | ||
|
||
def spec_dir | ||
@config.spec_dir | ||
end | ||
|
||
def src_dir | ||
@config.src_dir | ||
end | ||
|
||
def project_root | ||
@config.project_root | ||
end | ||
|
||
def root_path | ||
@config.root_path | ||
end | ||
end | ||
end |
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 was deleted.
Oops, something went wrong.
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
Oops, something went wrong.