Geminstaller C0 Coverage Information - RCov

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

Name Total Lines Lines of Code Total Coverage Code Coverage
spec/fixture/rubygems_dist/rubygems-trunk/lib/rubygems/builder.rb 94 53
45.74%
16.98%

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 require 'rubygems/user_interaction'
8 
9 ##
10 # The Builder class processes RubyGem specification files
11 # to produce a .gem file.
12 
13 class Gem::Builder
14 
15   include Gem::UserInteraction
16 
17   ##
18   # Constructs a builder instance for the provided specification
19   #
20   # spec:: [Gem::Specification] The specification instance
21 
22   def initialize(spec)
23     require "yaml"
24     require "rubygems/package"
25     require "rubygems/security"
26 
27     @spec = spec
28   end
29 
30   ##
31   # Builds the gem from the specification.  Returns the name of the file
32   # written.
33 
34   def build
35     @spec.mark_version
36     @spec.validate
37     @signer = sign
38     write_package
39     say success if Gem.configuration.verbose
40     @spec.file_name
41   end
42 
43   def success
44     <<-EOM
45   Successfully built RubyGem
46   Name: #{@spec.name}
47   Version: #{@spec.version}
48   File: #{@spec.file_name}
49 EOM
50   end
51 
52   private
53 
54   ##
55   # If the signing key was specified, then load the file, and swap to the
56   # public key (TODO: we should probably just omit the signing key in favor of
57   # the signing certificate, but that's for the future, also the signature
58   # algorithm should be configurable)
59 
60   def sign
61     signer = nil
62 
63     if @spec.respond_to?(:signing_key) and @spec.signing_key then
64       signer = Gem::Security::Signer.new @spec.signing_key, @spec.cert_chain
65       @spec.signing_key = nil
66       @spec.cert_chain = signer.cert_chain.map { |cert| cert.to_s }
67     end
68 
69     signer
70   end
71 
72   def write_package
73     open @spec.file_name, 'wb' do |gem_io|
74       Gem::Package.open gem_io, 'w', @signer do |pkg|
75         pkg.metadata = @spec.to_yaml
76 
77         @spec.files.each do |file|
78           next if File.directory? file
79           next if file == @spec.file_name # Don't add gem onto itself
80 
81           stat = File.stat file
82           mode = stat.mode & 0777
83           size = stat.size
84 
85           pkg.add_file_simple file, mode, size do |tar_io|
86             tar_io.write open(file, "rb") { |f| f.read }
87           end
88         end
89       end
90     end
91   end
92 
93 end
94 

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