ruby-changes:24541
From: emboss <ko1@a...>
Date: Thu, 2 Aug 2012 10:59:07 +0900 (JST)
Subject: [ruby-changes:24541] emboss:r36592 (trunk): * ext/openssl/lib/openssl/digest.rb
emboss 2012-08-02 10:58:49 +0900 (Thu, 02 Aug 2012) New Revision: 36592 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36592 Log: * ext/openssl/lib/openssl/digest.rb test/openssl/test_digest.rb: Add Digest module function to OpenSSL module and test it. Patch provided by Eric Hodel. [ruby-core:46908][Feature #6819] Modified files: trunk/ChangeLog trunk/ext/openssl/lib/openssl/digest.rb trunk/test/openssl/test_digest.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 36591) +++ ChangeLog (revision 36592) @@ -1,3 +1,10 @@ +Thu Aug 2 10:51:12 2012 Martin Bosslet <Martin.Bosslet@g...> + + * ext/openssl/lib/openssl/digest.rb + test/openssl/test_digest.rb: Add Digest module function to OpenSSL + module and test it. Patch provided by Eric Hodel. + [ruby-core:46908][Feature #6819] + Wed Aug 1 22:29:12 2012 Benoit Daloze <eregontp@g...> ext/digest/digest.c (hexencode_str_new): return an ASCII string Index: ext/openssl/lib/openssl/digest.rb =================================================================== --- ext/openssl/lib/openssl/digest.rb (revision 36591) +++ ext/openssl/lib/openssl/digest.rb (revision 36592) @@ -68,5 +68,22 @@ end end # Digest + + # Returns a Digest subclass by +name+. + # + # require 'openssl' + # + # OpenSSL::Digest("MD5") + # # => OpenSSL::Digest::MD5 + # + # Digest("Foo") + # # => NameError: wrong constant name Foo + + def Digest(name) + OpenSSL::Digest.const_get(name) + end + + module_function :Digest + end # OpenSSL Index: test/openssl/test_digest.rb =================================================================== --- test/openssl/test_digest.rb (revision 36591) +++ test/openssl/test_digest.rb (revision 36592) @@ -103,6 +103,14 @@ end end + def test_openssl_digest + assert_equal OpenSSL::Digest::MD5, OpenSSL::Digest("MD5") + + assert_raises NameError do + OpenSSL::Digest("no such digest") + end + end + private def check_digest(oid) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/