private
# File lib/ruby_toggle_file.rb, line 39 def exist(file) file if File.exist? file end
# File lib/ruby_toggle_file.rb, line 33 def implementation_file(test) m = TEST_RE.match(test) run_hooks_with_args_until_success /^implementation_file_/, test, m&&(m.pre_match+"/"), m&&m[1], m&&m[2] end
# File lib/ruby_toggle_file.rb, line 75 def implementation_file_00_rails(test, basedir, dir, node) if m = %rtest/(unit|functional)/(.+)_test.rb$!.match(test) "%sapp/%s/%s.rb" % [ m.pre_match, RAILS_TESTNAME2MVC[m[1]], m[2] ] end end
# File lib/ruby_toggle_file.rb, line 81 def implementation_file_10_no_match(test, basename, dir, node) if dir == nil and node == nil and test =~ %r/test_(.+)\.rb$! test.sub("/test_", "/") end end
# File lib/ruby_toggle_file.rb, line 87 def implementation_file_20(test, basedir, dir, node) exist("#{basedir}lib/#{dir}#{node}.rb") end
# File lib/ruby_toggle_file.rb, line 91 def implementation_file_30_flat(test, basedir, dir, node) Dir[ "#{basedir}lib/**/#{node}.rb" ].first end
# File lib/ruby_toggle_file.rb, line 95 def implementation_file_99_default(test, basedir, dir, node) "#{basedir}lib/#{dir}#{node}.rb" end
# File lib/ruby_toggle_file.rb, line 12 def ruby_toggle_file(file) if File.basename(file) =~ /(?:^test_|_test\.rb$)/ implementation_file(file) else test_file(file) end end
# File lib/ruby_toggle_file.rb, line 23 def test_file(implementation) if m = LIB_RE.match(implementation) dir, node = File.split m[1] dir = (dir == '.') ? nil : dir+"/" else dir = node = nil end run_hooks_with_args_until_success /^test_file_/, implementation, m&&(m.pre_match+"/"), dir, node end
# File lib/ruby_toggle_file.rb, line 45 def test_file_00_rails(implementation, basedir, dir, node) # rails if m = %rapp/(models|controllers)/(.+)\.rb$!.match(implementation) "%stest/%s/%s_test.rb" % [ m.pre_match, RAILS_MVC2TESTNAME[m[1]], m[2] ] end end
# File lib/ruby_toggle_file.rb, line 51 def test_file_05_rails_lib(implementation, basedir, dir, node) if basedir and File.directory?( File.join(basedir, "app") ) "#{basedir}test/unit/test_#{node}.rb" end end
# File lib/ruby_toggle_file.rb, line 57 def test_file_10_no_match(implementation, basedir, dir, node) if [basedir, dir, node].all?{|x| x.nil?} "#{File.dirname(implementation)}/test_#{File.basename(implementation)}" end end
# File lib/ruby_toggle_file.rb, line 63 def test_file_20_simple(implementation, basedir, dir, node) # test/test_NODE.rb exist "#{basedir}test/test_#{node}.rb" end
# File lib/ruby_toggle_file.rb, line 67 def test_file_30_flat(implementation, basedir, dir, node) # lib/XXX/NODE.rb -> test/test_NODE.rb exist "#{basedir}test/test_#{node}.rb" if dir end
# File lib/ruby_toggle_file.rb, line 71 def test_file_99_autotest_default(implementation, basedir, dir, node) # lib/XXX/NODE.rb -> test/XXX/test_NODE.rb "#{basedir}test/#{dir}test_#{node}.rb" end