Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
53 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
module Tork | ||
# Loads all Ruby scripts found having the given name in (1) the directories | ||
# specified in the TORK_CONFIGS environment variable, (2) the subdirectories | ||
# specified in the given $TORK_CONFIGS search path, (2) the subdirectories | ||
# of lib/tork/config/, and (3) the user's .tork/ directory; in that order. | ||
# | ||
# @return [Array] paths of Ruby scripts that were loaded | ||
# | ||
def self.config name | ||
dirs = ENV['TORK_CONFIGS'].strip.split(/:+/).reject(&:empty?).uniq. | ||
def self.config name, search_path=ENV['TORK_CONFIGS'] | ||
dirs = search_path.to_s.strip.split(/:+/).reject(&:empty?).uniq. | ||
map {|dir| [dir, __FILE__.sub(/\.rb$/, "/#{dir}")] }.flatten | ||
|
||
Dir["{#{dirs.join(',')},.tork}/#{name}.rb"].each {|script| load script } | ||
end | ||
end | ||
|
||
ENV['TORK_CONFIGS'] ||= 'default'.freeze # ENV values come frozen by default | ||
Tork.config :config | ||
ENV['TORK_CONFIGS'] ||= String.new.freeze # ENV values come frozen by default | ||
Tork.config :config, '*' |
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 @@ | ||
ENV['TORK_CONFIGS'] += ':bundler' if Dir['Gemfile{,.lock}'].any? |
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 @@ | ||
ENV['TORK_CONFIGS'] += ':cucumber' if File.directory? 'features' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ENV['TORK_CONFIGS'] += ':devise' if File.exist? 'config/initializers/devise.rb' |
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 @@ | ||
ENV['TORK_CONFIGS'] += ':factory_girl' if Dir['{test,spec}/factories/'].any? |
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 @@ | ||
ENV['TORK_CONFIGS'] += ':rails' if Dir['script/{rails,console}'].any? |
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,4 @@ | ||
$tork_config_spec_glob = '**/{spec_*,*_spec}.rb' | ||
$tork_config_spec_grep = %r{.*(\bspec_[^/]+|[^/]+_spec)\.rb$} | ||
|
||
ENV['TORK_CONFIGS'] += ':spec' if Dir['spec/', $tork_config_spec_glob].any? |
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,17 +1,13 @@ | ||
Tork::Driver::REABSORB_FILE_GREPS.push 'spec/spec_helper.rb' | ||
Tork::Driver::REABSORB_FILE_GREPS.push /\bspec_helper\.rb$/ | ||
|
||
Tork::Driver::ALL_TEST_FILE_GLOBS.push 'spec/**/{spec_*,*_spec}.rb' | ||
Tork::Driver::ALL_TEST_FILE_GLOBS.push $tork_config_spec_glob | ||
|
||
Tork::Driver::TEST_FILE_GLOBBERS.update( | ||
# source files that correspond to test files | ||
%r{^lib/.*?([^/]+)\.rb$} => lambda do |matches| | ||
target = matches[1] | ||
"spec/**/{spec_#{target},#{target}_spec}.rb" | ||
%r{([^/]+)\.rb$} => lambda do |matches| | ||
$tork_config_spec_glob.gsub(/(?<=_)\*|\*(?=_)/, matches[1]) | ||
end, | ||
|
||
# the actual test files themselves | ||
%r{^spec/.+\.rb$} => lambda do |matches| | ||
target = matches[0] | ||
target if File.basename(target) =~ /^spec_|_spec\./ | ||
end | ||
$tork_config_spec_grep => lambda {|matches| matches[0] } | ||
) |
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,4 +1,5 @@ | ||
$LOAD_PATH.unshift 'spec' unless $LOAD_PATH.include? 'spec' | ||
$LOAD_PATH.unshift 'lib' unless $LOAD_PATH.include? 'lib' | ||
require 'spec_helper' if File.exist? 'spec/spec_helper.rb' | ||
require './spec_helper' if File.exist? 'spec_helper.rb' | ||
require 'rspec/autorun' if defined? RSpec |
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,10 @@ | ||
# people generally prefix or suffix their test file names with these labels | ||
# https://en.wikibooks.org/wiki/Ruby_Programming/Unit_testing#Naming_Conventions | ||
labels = %w[ test ts tc t ] | ||
labels_glob = '{' + labels.join(',') + '}' | ||
labels_grep = '(' + labels.join('|') + ')' | ||
|
||
$tork_config_test_glob = "**/{#{labels_glob}_*,*_#{labels_glob}}.rb" | ||
$tork_config_test_grep = %r{.*(\b#{labels_grep}_[^/]+|[^/]+_#{labels_grep})\.rb$} | ||
|
||
ENV['TORK_CONFIGS'] += ':test' if Dir['test/', $tork_config_test_glob].any? |
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,17 +1,13 @@ | ||
Tork::Driver::REABSORB_FILE_GREPS.push 'test/test_helper.rb' | ||
Tork::Driver::REABSORB_FILE_GREPS.push /\btest_helper\.rb$/ | ||
|
||
Tork::Driver::ALL_TEST_FILE_GLOBS.push 'test/**/{test_*,*_test}.rb' | ||
Tork::Driver::ALL_TEST_FILE_GLOBS.push $tork_config_test_glob | ||
|
||
Tork::Driver::TEST_FILE_GLOBBERS.update( | ||
# source files that correspond to test files | ||
%r{^lib/.*?([^/]+)\.rb$} => lambda do |matches| | ||
target = matches[1] | ||
"test/**/{test_#{target},#{target}_test}.rb" | ||
%r{([^/]+)\.rb$} => lambda do |matches| | ||
$tork_config_test_glob.gsub(/(?<=_)\*|\*(?=_)/, matches[1]) | ||
end, | ||
|
||
# the actual test files themselves | ||
%r{^test/.+\.rb$} => lambda do |matches| | ||
target = matches[0] | ||
target if File.basename(target) =~ /^test_|_test\./ | ||
end | ||
$tork_config_test_grep => lambda {|matches| matches[0] } | ||
) |
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,4 +1,5 @@ | ||
$LOAD_PATH.unshift 'test' unless $LOAD_PATH.include? 'test' | ||
$LOAD_PATH.unshift 'lib' unless $LOAD_PATH.include? 'lib' | ||
require 'test_helper' if File.exist? 'test/test_helper.rb' | ||
require './test_helper' if File.exist? 'test_helper.rb' | ||
require 'minitest/autorun' if defined? MiniTest |
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