Parent

Files

RubyToggleFile

Constants

LIB_RE
TEST_RE
RAILS_MVC2TESTNAME
RAILS_TESTNAME2MVC

Public Instance Methods

exist(file) click to toggle source

private

    # File lib/ruby_toggle_file.rb, line 39
39:   def exist(file)
40:     file if File.exist? file
41:   end
implementation_file(test) click to toggle source
    # File lib/ruby_toggle_file.rb, line 33
33:   def implementation_file(test)
34:     m = TEST_RE.match(test)
35:     run_hooks_with_args_until_success /^implementation_file_/, test, m&&(m.pre_match+"/"), m&&m[1], m&&m[2]
36:   end
implementation_file_00_rails(test, basedir, dir, node) click to toggle source
    # File lib/ruby_toggle_file.rb, line 75
75:   def implementation_file_00_rails(test, basedir, dir, node)
76:     if m = %test/(unit|functional)/(.+)_test.rb$!.match(test)
77:       "%sapp/%s/%s.rb" % [ m.pre_match, RAILS_TESTNAME2MVC[m[1]], m[2] ]
78:     end
79:   end
implementation_file_10_no_match(test, basename, dir, node) click to toggle source
    # File lib/ruby_toggle_file.rb, line 81
81:   def implementation_file_10_no_match(test, basename, dir, node)
82:     if dir == nil and node == nil and test =~ %/test_(.+)\.rb$!
83:       test.sub("/test_", "/")
84:     end
85:   end
implementation_file_20(test, basedir, dir, node) click to toggle source
    # File lib/ruby_toggle_file.rb, line 87
87:   def implementation_file_20(test, basedir, dir, node)
88:     exist("#{basedir}lib/#{dir}#{node}.rb")
89:   end
implementation_file_30_flat(test, basedir, dir, node) click to toggle source
    # File lib/ruby_toggle_file.rb, line 91
91:   def implementation_file_30_flat(test, basedir, dir, node)
92:     Dir[ "#{basedir}lib/**/#{node}.rb" ].first
93:   end
implementation_file_99_default(test, basedir, dir, node) click to toggle source
    # File lib/ruby_toggle_file.rb, line 95
95:   def implementation_file_99_default(test, basedir, dir, node)
96:     "#{basedir}lib/#{dir}#{node}.rb"
97:   end
ruby_toggle_file(file) click to toggle source
    # File lib/ruby_toggle_file.rb, line 12
12:   def ruby_toggle_file(file)
13:     if File.basename(file) =~ /(?:^test_|_test\.rb$)/
14:       implementation_file(file)
15:     else
16:       test_file(file)
17:     end
18:   end
test_file(implementation) click to toggle source
    # File lib/ruby_toggle_file.rb, line 23
23:   def test_file(implementation)
24:     if m = LIB_RE.match(implementation)
25:       dir, node = File.split m[1]
26:       dir = (dir == '.') ? nil : dir+"/"
27:     else
28:       dir = node = nil
29:     end
30:     run_hooks_with_args_until_success /^test_file_/, implementation, m&&(m.pre_match+"/"), dir, node
31:   end
test_file_00_rails(implementation, basedir, dir, node) click to toggle source
    # File lib/ruby_toggle_file.rb, line 45
45:   def test_file_00_rails(implementation, basedir, dir, node) # rails
46:     if m = %app/(models|controllers)/(.+)\.rb$!.match(implementation)
47:       "%stest/%s/%s_test.rb" % [ m.pre_match, RAILS_MVC2TESTNAME[m[1]], m[2] ]
48:     end
49:   end
test_file_05_rails_lib(implementation, basedir, dir, node) click to toggle source
    # File lib/ruby_toggle_file.rb, line 51
51:   def test_file_05_rails_lib(implementation, basedir, dir, node)
52:     if basedir and File.directory?( File.join(basedir, "app") )
53:       "#{basedir}test/unit/test_#{node}.rb"
54:     end
55:   end
test_file_10_no_match(implementation, basedir, dir, node) click to toggle source
    # File lib/ruby_toggle_file.rb, line 57
57:   def test_file_10_no_match(implementation, basedir, dir, node)
58:     if [basedir, dir, node].all?{|x| x.nil?}
59:       "#{File.dirname(implementation)}/test_#{File.basename(implementation)}"
60:     end
61:   end
test_file_20_simple(implementation, basedir, dir, node) click to toggle source
    # File lib/ruby_toggle_file.rb, line 63
63:   def test_file_20_simple(implementation, basedir, dir, node) # test/test_NODE.rb
64:     exist "#{basedir}test/test_#{node}.rb"
65:   end
test_file_30_flat(implementation, basedir, dir, node) click to toggle source
    # File lib/ruby_toggle_file.rb, line 67
67:   def test_file_30_flat(implementation, basedir, dir, node) # lib/XXX/NODE.rb -> test/test_NODE.rb
68:     exist "#{basedir}test/test_#{node}.rb" if dir
69:   end
test_file_99_autotest_default(implementation, basedir, dir, node) click to toggle source
    # File lib/ruby_toggle_file.rb, line 71
71:   def test_file_99_autotest_default(implementation, basedir, dir, node) # lib/XXX/NODE.rb -> test/XXX/test_NODE.rb
72:     "#{basedir}test/#{dir}test_#{node}.rb"
73:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.