Geminstaller C0 Coverage Information - RCov

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

Name Total Lines Lines of Code Total Coverage Code Coverage
spec/fixture/rubygems_dist/rubygems-trunk/lib/rubygems/format.rb 83 45
92.77%
88.89%

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 'fileutils'
8 
9 require 'rubygems/package'
10 
11 ##
12 # Gem::Format knows the guts of the RubyGem .gem file format and provides the
13 # capability to read gem files
14 
15 class Gem::Format
16 
17   attr_accessor :spec
18   attr_accessor :file_entries
19   attr_accessor :gem_path
20 
21   extend Gem::UserInteraction
22 
23   ##
24   # Constructs a Format representing the gem's data which came from +gem_path+
25 
26   def initialize(gem_path)
27     @gem_path = gem_path
28   end
29 
30   ##
31   # Reads the gem +file_path+ using +security_policy+ and returns a Format
32   # representing the data in the gem
33 
34   def self.from_file_by_path(file_path, security_policy = nil)
35     format = nil
36 
37     unless File.exist?(file_path)
38       raise Gem::Exception, "Cannot load gem at [#{file_path}] in #{Dir.pwd}"
39     end
40 
41     start = File.read file_path, 20
42 
43     if start.nil? or start.length < 20 then
44       nil
45     elsif start.include?("MD5SUM =") # old version gems
46       require 'rubygems/old_format'
47 
48       Gem::OldFormat.from_file_by_path file_path
49     else
50       open file_path, Gem.binary_mode do |io|
51         from_io io, file_path, security_policy
52       end
53     end
54   end
55 
56   ##
57   # Reads a gem from +io+ at +gem_path+ using +security_policy+ and returns a
58   # Format representing the data from the gem
59 
60   def self.from_io(io, gem_path="(io)", security_policy = nil)
61     format = new gem_path
62 
63     Gem::Package.open io, 'r', security_policy do |pkg|
64       format.spec = pkg.metadata
65       format.file_entries = []
66 
67       pkg.each do |entry|
68         size = entry.header.size
69         mode = entry.header.mode
70 
71         format.file_entries << [{
72             "size" => size, "mode" => mode, "path" => entry.full_name,
73           },
74           entry.read
75         ]
76       end
77     end
78 
79     format
80   end
81 
82 end
83 

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