Class: RubyToggleFile
- Inherits:
-
Object
- Object
- RubyToggleFile
- Defined in:
- lib/ruby_toggle_file.rb
Constant Summary collapse
- LIB_RE =
%r!/lib/(.+)\.rb$!- TEST_RE =
%r!/test/(.+/)?test_(.+)\.rb$!
Instance Method Summary collapse
- #implementation_file(test) ⇒ Object
- #ruby_toggle_file(file) ⇒ Object
- #test_file(implementation) ⇒ Object
Instance Method Details
#implementation_file(test) ⇒ Object
33 34 35 36 |
# File 'lib/ruby_toggle_file.rb', line 33 def implementation_file(test) m = TEST_RE.match(test) run_hooks_with_args_until_success %r/^implementation_file_/, test, m&&(m.pre_match+"/"), m&&m[1], m&&m[2] end |
#ruby_toggle_file(file) ⇒ Object
12 13 14 15 16 17 18 |
# 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 |
#test_file(implementation) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# 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 %r/^test_file_/, implementation, m&&(m.pre_match+"/"), dir, node end |