summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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