[前][次][番号順一覧][スレッド一覧]

ruby-changes:15402

From: drbrain <ko1@a...>
Date: Sun, 11 Apr 2010 10:34:49 +0900 (JST)
Subject: [ruby-changes:15402] Ruby:r27295 (trunk): Update to RDoc 2.5.3

drbrain	2010-04-11 10:34:28 +0900 (Sun, 11 Apr 2010)

  New Revision: 27295

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=27295

  Log:
    Update to RDoc 2.5.3

  Modified files:
    trunk/ChangeLog
    trunk/NEWS
    trunk/lib/rdoc/rdoc.rb
    trunk/lib/rdoc.rb
    trunk/test/rdoc/test_rdoc_rdoc.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 27294)
+++ ChangeLog	(revision 27295)
@@ -1,3 +1,7 @@
+Sun Apr 11 10:33:34 2010  Eric Hodel  <drbrain@s...>
+
+	* lib/rdoc:  Update to RDoc 2.5.3.  Includes r27288 and r27290.
+
 Sun Apr 11 09:31:39 2010  Aaron Patterson <aaron@t...>
 
 	* test/syck/*: Moved test/yaml to test/syck since it's actually
Index: lib/rdoc.rb
===================================================================
--- lib/rdoc.rb	(revision 27294)
+++ lib/rdoc.rb	(revision 27295)
@@ -383,7 +383,7 @@
   ##
   # RDoc version you are using
 
-  VERSION = '2.5.2'
+  VERSION = '2.5.3'
 
   ##
   # Name of the dotfile that contains the description of files to be processed
Index: lib/rdoc/rdoc.rb
===================================================================
--- lib/rdoc/rdoc.rb	(revision 27294)
+++ lib/rdoc/rdoc.rb	(revision 27295)
@@ -38,6 +38,11 @@
   attr_accessor :generator
 
   ##
+  # Hash of files and their last modified times.
+
+  attr_reader :last_modified
+
+  ##
   # RDoc options
 
   attr_accessor :options
@@ -75,13 +80,13 @@
   end
 
   def initialize
-    @current      = nil
-    @exclude      = nil
-    @generator    = nil
-    @last_created = {}
-    @old_siginfo  = nil
-    @options      = nil
-    @stats        = nil
+    @current       = nil
+    @exclude       = nil
+    @generator     = nil
+    @last_modified = {}
+    @old_siginfo   = nil
+    @options       = nil
+    @stats         = nil
   end
 
   ##
@@ -132,35 +137,39 @@
   # contain the flag file <tt>created.rid</tt> then we refuse to use it, as
   # we may clobber some manually generated documentation
 
-  def setup_output_dir(op_dir, force)
-    flag_file = output_flag_file op_dir
+  def setup_output_dir(dir, force)
+    flag_file = output_flag_file dir
 
     last = {}
 
-    if File.exist? op_dir then
-      unless File.directory? op_dir then
-        error "'#{op_dir}' exists, and is not a directory"
-      end
+    if File.exist? dir then
+      error "#{dir} exists and is not a directory" unless File.directory? dir
+
       begin
         open flag_file do |io|
-          unless force
+          unless force then
             Time.parse io.gets
+
             io.each do |line|
-              file, time = line.split(/\t/, 2)
+              file, time = line.split "\t", 2
               time = Time.parse(time) rescue next
               last[file] = time
             end
           end
         end
-      rescue
-        error "\nDirectory #{op_dir} already exists, but it looks like it\n" +
-          "isn't an RDoc directory. Because RDoc doesn't want to risk\n" +
-          "destroying any of your existing files, you'll need to\n" +
-          "specify a different output directory name (using the\n" +
-          "--op <dir> option).\n\n"
+      rescue SystemCallError, TypeError
+        error <<-ERROR
+
+Directory #{dir} already exists, but it looks like it isn't an RDoc directory.
+
+Because RDoc doesn't want to risk destroying any of your existing files,
+you'll need to specify a different output directory name (using the --op <dir>
+option)
+
+        ERROR
       end
     else
-      FileUtils.mkdir_p(op_dir)
+      FileUtils.mkdir_p dir
     end
 
     last
@@ -170,7 +179,7 @@
   # Update the flag file in an output directory.
 
   def update_output_dir(op_dir, time, last = {})
-    File.open(output_flag_file(op_dir), "w") do |f|
+    open output_flag_file(op_dir), "w" do |f|
       f.puts time.rfc2822
       last.each do |n, t|
         f.puts "#{n}\t#{t.rfc2822}"
@@ -226,12 +235,12 @@
 
       case type = stat.ftype
       when "file" then
-        next if last_created = @last_created[rel_file_name] and
-                stat.mtime.to_i <= last_created.to_i
+        next if last_modified = @last_modified[rel_file_name] and
+                stat.mtime.to_i <= last_modified.to_i
 
         if force_doc or RDoc::Parser.can_parse(rel_file_name) then
           file_list << rel_file_name.sub(/^\.\//, '')
-          @last_created[rel_file_name] = stat.mtime
+          @last_modified[rel_file_name] = stat.mtime
         end
       when "directory" then
         next if rel_file_name == "CVS" || rel_file_name == ".svn"
@@ -356,7 +365,7 @@
 
     @exclude = @options.exclude
 
-    @last_created = setup_output_dir @options.op_dir, @options.force_update
+    @last_modified = setup_output_dir @options.op_dir, @options.force_update
 
     start_time = Time.now
 
@@ -382,7 +391,7 @@
           self.class.current = self
 
           @generator.generate file_info
-          update_output_dir ".", start_time, @last_created
+          update_output_dir ".", start_time, @last_modified
         ensure
           self.class.current = nil
         end
@@ -396,7 +405,7 @@
   end
 
   def read_file_contents(filename)
-    content = File.open(filename, "rb") { |f| f.read }
+    content = open filename, "rb" do |f| f.read end
 
     if defined? Encoding then
       if /coding[=:]\s*([^\s;]+)/i =~ content[%r"\A(?:#!.*\n)?.*\n"]
Index: NEWS
===================================================================
--- NEWS	(revision 27294)
+++ NEWS	(revision 27295)
@@ -201,7 +201,7 @@
 
 * RDoc
 
-  * Updated to RDoc 2.5.2
+  * Updated to RDoc 2.5.3
 
 * logger
 
Index: test/rdoc/test_rdoc_rdoc.rb
===================================================================
--- test/rdoc/test_rdoc_rdoc.rb	(revision 27294)
+++ test/rdoc/test_rdoc_rdoc.rb	(revision 27295)
@@ -1,4 +1,5 @@
 require 'tempfile'
+require 'tmpdir'
 require 'rubygems'
 require 'minitest/autorun'
 require 'rdoc/rdoc'
@@ -11,7 +12,7 @@
   end
 
   def teardown
-    @tempfile.close
+    @tempfile.close rescue nil # HACK for 1.8.6
   end
 
   def test_gather_files
@@ -19,6 +20,24 @@
     assert_equal [file], @rdoc.gather_files([file, file])
   end
 
+  def test_normalized_file_list
+    files = @rdoc.normalized_file_list [__FILE__]
+
+    files = files.map { |file| File.expand_path file }
+
+    assert_equal [File.expand_path(__FILE__)], files
+  end
+
+  def test_normalized_file_list_not_modified
+    files = [__FILE__]
+
+    @rdoc.last_modified[__FILE__] = File.stat(__FILE__).mtime
+
+    files = @rdoc.normalized_file_list [__FILE__]
+
+    assert_empty files
+  end
+
   def test_read_file_contents
     @tempfile.write "hi everybody"
     @tempfile.flush
@@ -62,5 +81,75 @@
     assert_empty @rdoc.remove_unparseable file_list
   end
 
+  def test_setup_output_dir
+    path = @tempfile.path
+    @tempfile.unlink
+
+    last = @rdoc.setup_output_dir path, false
+
+    assert_empty last
+
+    assert File.directory? path
+  ensure
+    FileUtils.rm_f path
+  end
+
+  def test_setup_output_dir_exists
+    path = @tempfile.path
+    @tempfile.unlink
+    FileUtils.mkdir_p path
+
+    open @rdoc.output_flag_file(path), 'w' do |io|
+      io.puts Time.at 0
+      io.puts "./lib/rdoc.rb\t#{Time.at 86400}"
+    end
+
+    last = @rdoc.setup_output_dir path, false
+
+    assert_equal 1, last.size
+    assert_equal Time.at(86400), last['./lib/rdoc.rb']
+  ensure
+    FileUtils.rm_f path
+  end
+
+  def test_setup_output_dir_exists_empty_created_rid
+    path = @tempfile.path
+    @tempfile.unlink
+    FileUtils.mkdir_p path
+
+    open @rdoc.output_flag_file(path), 'w' do end
+
+    e = assert_raises RDoc::Error do
+      @rdoc.setup_output_dir path, false
+    end
+
+    assert_match %r%Directory #{Regexp.escape path} already exists%, e.message
+  ensure
+    FileUtils.rm_f path
+  end
+
+  def test_setup_output_dir_exists_file
+    path = @tempfile.path
+
+    e = assert_raises RDoc::Error do
+      @rdoc.setup_output_dir path, false
+    end
+
+    assert_match(%r%#{Regexp.escape path} exists and is not a directory%,
+                 e.message)
+  end
+
+  def test_setup_output_dir_exists_not_rdoc
+    skip "No Dir::mktmpdir, upgrade your ruby" unless Dir.respond_to? :mktmpdir
+
+    Dir.mktmpdir do |dir|
+      e = assert_raises RDoc::Error do
+        @rdoc.setup_output_dir dir, false
+      end
+
+      assert_match %r%Directory #{Regexp.escape dir} already exists%, e.message
+    end
+  end
+
 end
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]