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

ruby-changes:38357

From: nobu <ko1@a...>
Date: Thu, 7 May 2015 16:10:10 +0900 (JST)
Subject: [ruby-changes:38357] nobu:r50438 (trunk): checksum.rb: check the target

nobu	2015-05-07 16:09:43 +0900 (Thu, 07 May 2015)

  New Revision: 50438

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

  Log:
    checksum.rb: check the target
    
    * tool/checksum.rb (Checksum#update?): check if the target exists
      too.

  Modified files:
    trunk/ext/io/console/depend
    trunk/tool/checksum.rb
Index: ext/io/console/depend
===================================================================
--- ext/io/console/depend	(revision 50437)
+++ ext/io/console/depend	(revision 50438)
@@ -15,5 +15,5 @@ win32_vk.inc: win32_vk.list https://github.com/ruby/ruby/blob/trunk/ext/io/console/depend#L15
 
 {$(srcdir)}.list.chksum:
 	@$(RUBY) -I$(top_srcdir)/tool -rchecksum \
-	    -e "Checksum.update(ARGV) {|k,f|k.copy(f) rescue k.make(f)}" \
+	    -e "Checksum.update(ARGV) {|k|k.copy(k.target) rescue k.make(k.target)}" \
 	    -- --make=$(MAKE) -I$(srcdir) $(<F) $(@F:.chksum=.inc)
Index: tool/checksum.rb
===================================================================
--- tool/checksum.rb	(revision 50437)
+++ tool/checksum.rb	(revision 50438)
@@ -7,15 +7,22 @@ class Checksum https://github.com/ruby/ruby/blob/trunk/tool/checksum.rb#L7
     @vpath = vpath
   end
 
+  attr_reader :source, :target
+
   def source=(source)
     @source = source
     @checksum = File.basename(source, ".*") + ".chksum"
   end
 
+  def target=(target)
+    @target = target
+  end
+
   def update?
     src = @vpath.read(@source)
     @len = src.length
     @sum = src.sum
+    return false unless @vpath.search(File.method(:exist?), @target)
     begin
       data = @vpath.read(@checksum)
     rescue
@@ -47,8 +54,8 @@ class Checksum https://github.com/ruby/ruby/blob/trunk/tool/checksum.rb#L54
     true
   end
 
-  def make(arg)
-    system([@make, arg].compact.join(' '))
+  def make(*args)
+    system(@make, *args)
   end
 
   def def_options(opt = (require 'optparse'; OptionParser.new))
@@ -59,7 +66,7 @@ class Checksum https://github.com/ruby/ruby/blob/trunk/tool/checksum.rb#L66
 
   def self.update(argv)
     k = new(VPath.new)
-    k.source, *argv = k.def_options.parse(*argv)
+    k.source, k.target, *argv = k.def_options.parse(*argv)
     k.update {|k| yield(k, *argv)}
   end
 end

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

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