1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/digest/lib/digest.rb (Digest): Try to auto-load non-standard

digest modules when a specified digest class is missing.

* ext/digest/lib/digest.rb: Define Digest(name) for ease of
  dynamically selecting a hashing algorithm.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
knu 2006-10-13 12:02:32 +00:00
parent f678390e1f
commit 3a4ce48c75
2 changed files with 23 additions and 3 deletions

View file

@ -1,3 +1,11 @@
Fri Oct 13 21:00:01 2006 Akinori MUSHA <knu@iDaemons.org>
* ext/digest/lib/digest.rb (Digest): Try to auto-load non-standard
digest modules when a specified digest class is missing.
* ext/digest/lib/digest.rb: Define Digest(name) for ease of
dynamically selecting a hashing algorithm.
Fri Oct 13 20:53:37 2006 Akinori MUSHA <knu@iDaemons.org>
* ext/digest/digest.c (Init_digest): Digest::Base.new() does no

View file

@ -1,13 +1,21 @@
require 'digest.so'
module Digest
autoload "MD5", "digest/md5"
autoload "RMD160", "digest/rmd160"
autoload "SHA1", "digest/sha1"
autoload "SHA256", "digest/sha2"
autoload "SHA384", "digest/sha2"
autoload "SHA512", "digest/sha2"
def self.const_missing(name)
begin
require File.join('digest', name.downcase)
return Digest.const_get(name) if Digest.const_defined?(name)
rescue LoadError => e
end
raise NameError, "Digest class not found: Digest::#{name}"
end
class Base
# creates a digest object and read given file, _name_.
#
@ -25,3 +33,7 @@ module Digest
end
end
end
def Digest(name)
Digest.const_get(name)
end