ruby-changes:25964
From: drbrain <ko1@a...>
Date: Fri, 30 Nov 2012 10:44:10 +0900 (JST)
Subject: [ruby-changes:25964] drbrain:r38021 (trunk): * lib/rdoc/ri/driver.rb: Relaxed matching for pages to be more
drbrain 2012-11-30 10:39:03 +0900 (Fri, 30 Nov 2012) New Revision: 38021 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=38021 Log: * lib/rdoc/ri/driver.rb: Relaxed matching for pages to be more user-friendly. * test/rdoc/test_rdoc_ri_driver.rb: Test for above. Modified files: trunk/ChangeLog trunk/lib/rdoc/ri/driver.rb trunk/test/rdoc/test_rdoc_ri_driver.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 38020) +++ ChangeLog (revision 38021) @@ -1,3 +1,9 @@ +Fri Nov 30 10:38:54 2012 Eric Hodel <drbrain@s...> + + * lib/rdoc/ri/driver.rb: Relaxed matching for pages to be more + user-friendly. + * test/rdoc/test_rdoc_ri_driver.rb: Test for above. + Fri Nov 30 09:50:16 2012 Eric Hodel <drbrain@s...> * lib/rdoc/markdown.rb: Fixed warnings with -w Index: lib/rdoc/ri/driver.rb =================================================================== --- lib/rdoc/ri/driver.rb (revision 38020) +++ lib/rdoc/ri/driver.rb (revision 38021) @@ -842,10 +842,12 @@ unless pages.include? page_name then found_names = pages.select do |n| - n =~ /^#{Regexp.escape page_name}\.[^.]+$/ + n =~ /#{Regexp.escape page_name}\.[^.]+$/ end - if found_names.length > 1 then + if found_names.length.zero? then + return display_page_list store, pages + elsif found_names.length > 1 then return display_page_list store, found_names, page_name end Index: test/rdoc/test_rdoc_ri_driver.rb =================================================================== --- test/rdoc/test_rdoc_ri_driver.rb (revision 38020) +++ test/rdoc/test_rdoc_ri_driver.rb (revision 38021) @@ -747,6 +747,40 @@ assert_match %r%README\.md%, out end + def test_display_page_ignore_directory + util_store + + other = @store1.add_file 'doc/globals.rdoc' + other.parser = RDoc::Parser::Simple + other.comment = + doc( + head(1, 'globals.rdoc'), + para('Globals go here')) + + @store1.save_page other + + out, = capture_io do + @driver.display_page 'home:globals' + end + + assert_match %r%= globals\.rdoc%, out + end + + def test_display_page_missing + util_store + + out, = capture_io do + @driver.display_page 'home:missing' + end + + out, = capture_io do + @driver.display_page_list @store1 + end + + assert_match %r%= Pages in ~/\.rdoc%, out + assert_match %r%README\.rdoc%, out + end + def test_display_page_list util_store -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/