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

ruby-changes:15320

From: nobu <ko1@a...>
Date: Sat, 3 Apr 2010 18:15:40 +0900 (JST)
Subject: [ruby-changes:15320] Ruby:r27207 (trunk): * lib/rdoc/rdoc.rb (RDoc#{setup,update}_output_dir): store mtimes

nobu	2010-04-03 18:15:13 +0900 (Sat, 03 Apr 2010)

  New Revision: 27207

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

  Log:
    * lib/rdoc/rdoc.rb (RDoc#{setup,update}_output_dir): store mtimes
      per files in the flag file.
    
    * lib/rdoc/rdoc.rb (RDoc#normalized_file_list): skip already
      processed and unmodified files.

  Modified files:
    trunk/ChangeLog
    trunk/lib/rdoc/rdoc.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 27206)
+++ ChangeLog	(revision 27207)
@@ -1,3 +1,11 @@
+Sat Apr  3 18:15:02 2010  Nobuyoshi Nakada  <nobu@r...>
+
+	* lib/rdoc/rdoc.rb (RDoc#{setup,update}_output_dir): store mtimes
+	  per files in the flag file.
+
+	* lib/rdoc/rdoc.rb (RDoc#normalized_file_list): skip already
+	  processed and unmodified files.
+
 Sat Apr  3 15:09:30 2010  Nobuyoshi Nakada  <nobu@r...>
 
 	* common.mk (rdoc): no force-update, and add RDOCFLAGS.
Index: lib/rdoc/rdoc.rb
===================================================================
--- lib/rdoc/rdoc.rb	(revision 27206)
+++ lib/rdoc/rdoc.rb	(revision 27207)
@@ -135,20 +135,29 @@
   def setup_output_dir(op_dir, force)
     flag_file = output_flag_file op_dir
 
+    last = {}
+
     if File.exist? op_dir then
       unless File.directory? op_dir then
         error "'#{op_dir}' exists, and is not a directory"
       end
       begin
-        created = File.read(flag_file)
-      rescue SystemCallError
+        open(flag_file) do |f|
+          unless force
+            Time.parse(f.gets)
+            f.each do |line|
+              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"
-      else
-        last = (Time.parse(created) unless force rescue nil)
       end
     else
       FileUtils.mkdir_p(op_dir)
@@ -160,8 +169,13 @@
   ##
   # Update the flag file in an output directory.
 
-  def update_output_dir(op_dir, time)
-    File.open(output_flag_file(op_dir), "w") { |f| f.puts time.rfc2822 }
+  def update_output_dir(op_dir, time, last = {})
+    File.open(output_flag_file(op_dir), "w") do |f|
+      f.puts time.rfc2822
+      last.each do |n, t|
+        f.puts "#{n}\t#{t.rfc2822}"
+      end
+    end
   end
 
   ##
@@ -212,10 +226,11 @@
 
       case type = stat.ftype
       when "file"
-        next if @last_created and stat.mtime < @last_created
+        next if last_created = @last_created[rel_file_name] and stat.mtime <= last_created
 
         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
         end
       when "directory"
         next if rel_file_name == "CVS" || rel_file_name == ".svn"
@@ -366,7 +381,7 @@
           self.class.current = self
 
           @generator.generate file_info
-          update_output_dir ".", start_time
+          update_output_dir ".", start_time, @last_created
         ensure
           self.class.current = nil
         end

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

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