summaryrefslogtreecommitdiff
path: root/tool/checksum.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-07 07:09:43 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-05-07 07:09:43 +0000
commit8869cdf576757d567e2c14453297fc932627563f (patch)
treec0363d09c52d634ba0685ee0239aec2990503822 /tool/checksum.rb
parent19e0fa010e8c02b7ba6a1fd3c59adfd65e462062 (diff)
checksum.rb: check the target
* tool/checksum.rb (Checksum#update?): check if the target exists too. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50438 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'tool/checksum.rb')
-rwxr-xr-xtool/checksum.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/tool/checksum.rb b/tool/checksum.rb
index 40f444e..0de54a3 100755
--- a/tool/checksum.rb
+++ b/tool/checksum.rb
@@ -7,15 +7,22 @@ class Checksum
@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
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
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