forked from guard/guard-rspec
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request guard#75 from ashmoran/enable_multiple_guard_insta…
…nces Enable multiple guard instances
- Loading branch information
Showing
5 changed files
with
209 additions
and
182 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,69 +1,67 @@ | ||
module Guard | ||
class RSpec | ||
module Inspector | ||
class << self | ||
def excluded | ||
@excluded || [] | ||
end | ||
class Inspector | ||
def excluded | ||
@excluded || [] | ||
end | ||
|
||
def excluded=(glob) | ||
@excluded = Dir[glob.to_s] | ||
end | ||
def excluded=(glob) | ||
@excluded = Dir[glob.to_s] | ||
end | ||
|
||
def spec_paths | ||
@spec_paths || [] | ||
end | ||
def spec_paths | ||
@spec_paths || [] | ||
end | ||
|
||
def spec_paths=(path_array) | ||
@spec_paths = Array(path_array) | ||
end | ||
def spec_paths=(path_array) | ||
@spec_paths = Array(path_array) | ||
end | ||
|
||
def clean(paths) | ||
paths.uniq! | ||
paths.compact! | ||
clear_spec_files_list_after do | ||
paths = paths.select { |path| should_run_spec_file?(path) } | ||
end | ||
paths.reject { |p| included_in_other_path?(p, paths) } | ||
def clean(paths) | ||
paths.uniq! | ||
paths.compact! | ||
clear_spec_files_list_after do | ||
paths = paths.select { |path| should_run_spec_file?(path) } | ||
end | ||
paths.reject { |p| included_in_other_path?(p, paths) } | ||
end | ||
|
||
private | ||
|
||
def should_run_spec_file?(path) | ||
(spec_file?(path) || feature_file?(path) || spec_folder?(path)) && !excluded.include?(path) | ||
end | ||
private | ||
|
||
def spec_file?(path) | ||
spec_files.include?(path) | ||
end | ||
def should_run_spec_file?(path) | ||
(spec_file?(path) || feature_file?(path) || spec_folder?(path)) && !excluded.include?(path) | ||
end | ||
|
||
def feature_file?(path) | ||
feature_files.include?(path) | ||
end | ||
def spec_file?(path) | ||
spec_files.include?(path) | ||
end | ||
|
||
def spec_folder?(path) | ||
path.match(%r{^(#{spec_paths.join("|")})[^\.]*$}) | ||
# path.match(%r{^spec[^\.]*$}) | ||
end | ||
def feature_file?(path) | ||
feature_files.include?(path) | ||
end | ||
|
||
def spec_files | ||
@spec_files ||= spec_paths.collect { |path| Dir[File.join(path, "**", "*_spec.rb")] }.flatten | ||
end | ||
def spec_folder?(path) | ||
path.match(%r{^(#{spec_paths.join("|")})[^\.]*$}) | ||
# path.match(%r{^spec[^\.]*$}) | ||
end | ||
|
||
def feature_files | ||
@feature_files ||= spec_paths.collect { |path| Dir[File.join(path, "**", "*.feature")] }.flatten | ||
end | ||
def spec_files | ||
@spec_files ||= spec_paths.collect { |path| Dir[File.join(path, "**", "*_spec.rb")] }.flatten | ||
end | ||
|
||
def clear_spec_files_list_after | ||
yield | ||
@spec_files = nil | ||
end | ||
def feature_files | ||
@feature_files ||= spec_paths.collect { |path| Dir[File.join(path, "**", "*.feature")] }.flatten | ||
end | ||
|
||
def included_in_other_path?(path, paths) | ||
(paths - [path]).any? { |p| path.include?(p) && path.sub(p, '').include?('/') } | ||
end | ||
def clear_spec_files_list_after | ||
yield | ||
@spec_files = nil | ||
end | ||
|
||
def included_in_other_path?(path, paths) | ||
(paths - [path]).any? { |p| path.include?(p) && path.sub(p, '').include?('/') } | ||
end | ||
|
||
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
Oops, something went wrong.