Geminstaller C0 Coverage Information - RCov

spec/fixture/rubygems_dist/rubygems-trunk/lib/rubygems/gem_openssl.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
spec/fixture/rubygems_dist/rubygems-trunk/lib/rubygems/gem_openssl.rb 94 43
68.09%
39.53%

Key

Code reported as executed by Ruby looks like this...and this: this line is also marked as covered.Lines considered as run by rcov, but not reported by Ruby, look like this,and this: these lines were inferred by rcov (using simple heuristics).Finally, here's a line marked as not executed.

Coverage Details

1 #--
2 # Copyright 2006 by Chad Fowler, Rich Kilmer, Jim Weirich and others.
3 # All rights reserved.
4 # See LICENSE.txt for permissions.
5 #++
6 
7 #--
8 # Some system might not have OpenSSL installed, therefore the core
9 # library file openssl might not be available.  We localize testing
10 # for the presence of OpenSSL in this file.
11 #++
12 
13 module Gem
14   class << self
15     ##
16     # Is SSL (used by the signing commands) available on this
17     # platform?
18 
19     def ssl_available?
20       @ssl_available
21     end
22 
23     ##
24     # Is SSL available?
25 
26     attr_writer :ssl_available
27 
28     ##
29     # Ensure that SSL is available.  Throw an exception if it is not.
30 
31     def ensure_ssl_available
32       unless ssl_available?
33         raise Gem::Exception, "SSL is not installed on this system"
34       end
35     end
36   end
37 end
38 
39 begin
40   require 'openssl'
41 
42   # Reference a constant defined in the .rb portion of ssl (just to
43   # make sure that part is loaded too).
44 
45   dummy = OpenSSL::Digest::SHA1
46 
47   Gem.ssl_available = true
48 
49   class OpenSSL::X509::Certificate # :nodoc:
50     # Check the validity of this certificate.
51     def check_validity(issuer_cert = nil, time = Time.now)
52       ret = if @not_before && @not_before > time
53               [false, :expired, "not valid before '#@not_before'"]
54             elsif @not_after && @not_after < time
55               [false, :expired, "not valid after '#@not_after'"]
56             elsif issuer_cert && !verify(issuer_cert.public_key)
57               [false, :issuer, "#{issuer_cert.subject} is not issuer"]
58             else
59               [true, :ok, 'Valid certificate']
60             end
61 
62       # return hash
63       { :is_valid => ret[0], :error => ret[1], :desc => ret[2] }
64     end
65   end
66 
67 rescue LoadError, StandardError
68   Gem.ssl_available = false
69 end
70 
71 # :stopdoc:
72 
73 module Gem::SSL
74 
75   # We make our own versions of the constants here.  This allows us
76   # to reference the constants, even though some systems might not
77   # have SSL installed in the Ruby core package.
78   #
79   # These constants are only used during load time.  At runtime, any
80   # method that makes a direct reference to SSL software must be
81   # protected with a Gem.ensure_ssl_available call.
82 
83   if Gem.ssl_available? then
84     PKEY_RSA = OpenSSL::PKey::RSA
85     DIGEST_SHA1 = OpenSSL::Digest::SHA1
86   else
87     PKEY_RSA = :rsa
88     DIGEST_SHA1 = :sha1
89   end
90 
91 end
92 
93 # :startdoc:
94 

Generated on Mon May 10 23:40:28 -0700 2010 with rcov 0.9.8