summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-10-21 08:52:09 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2006-10-21 08:52:09 +0000
commit0c80ce785d85482d574b5a212218034a6ec12397 (patch)
tree806d10a8c06c435706cb24e39a47fcc696084a88
parentd754c11644e9849f004a321e99519f696f90498d (diff)
* ext/digest/lib/digest.rb: Follow the framework updates.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11200 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog4
-rw-r--r--ext/digest/lib/digest.rb17
2 files changed, 16 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 7178c2d..6ab47f7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Sat Oct 21 17:50:40 2006 Akinori MUSHA <knu@iDaemons.org>
+
+ * ext/digest/lib/digest.rb: Follow the framework updates.
+
Fri Oct 20 22:00:43 2006 Akinori MUSHA <knu@iDaemons.org>
* ext/digest/lib/digest/hmac.rb: Complete half-boiled updates.
diff --git a/ext/digest/lib/digest.rb b/ext/digest/lib/digest.rb
index 1d1e420..a56d475 100644
--- a/ext/digest/lib/digest.rb
+++ b/ext/digest/lib/digest.rb
@@ -16,20 +16,27 @@ module Digest
raise NameError, "Digest class not found: Digest::#{name}"
end
- class Base
- # creates a digest object and read given file, _name_.
+ class ::Digest::Class
+ # creates a digest object and reads a given file, _name_.
#
# p Digest::SHA256.file("X11R6.8.2-src.tar.bz2").hexdigest
# # => "f02e3c85572dc9ad7cb77c2a638e3be24cc1b5bea9fdbb0b0299c9668475c534"
def self.file(name)
- digest = self.new
+ new.file(name)
+ end
+ end
+
+ module Instance
+ # updates the digest with the contents of a given file _name_ and
+ # returns self.
+ def file(name)
File.open(name, "rb") {|f|
buf = ""
while f.read(16384, buf)
- digest.update buf
+ update buf
end
}
- digest
+ self
end
end
end