Geminstaller C0 Coverage Information - RCov

spec/fixture/rubygems_dist/rubygems-trunk/lib/rubygems/commands/install_command.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
spec/fixture/rubygems_dist/rubygems-trunk/lib/rubygems/commands/install_command.rb 176 131
86.93%
83.21%

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 require 'rubygems/command'
2 require 'rubygems/doc_manager'
3 require 'rubygems/install_update_options'
4 require 'rubygems/dependency_installer'
5 require 'rubygems/local_remote_options'
6 require 'rubygems/validator'
7 require 'rubygems/version_option'
8 
9 ##
10 # Gem installer command line tool
11 #
12 # See `gem help install`
13 
14 class Gem::Commands::InstallCommand < Gem::Command
15 
16   include Gem::VersionOption
17   include Gem::LocalRemoteOptions
18   include Gem::InstallUpdateOptions
19 
20   def initialize
21     defaults = Gem::DependencyInstaller::DEFAULT_OPTIONS.merge({
22       :generate_rdoc     => true,
23       :generate_ri       => true,
24       :format_executable => false,
25       :test              => false,
26       :version           => Gem::Requirement.default,
27     })
28 
29     super 'install', 'Install a gem into the local repository', defaults
30 
31     add_install_update_options
32     add_local_remote_options
33     add_platform_option
34     add_version_option
35     add_prerelease_option "to be installed. (Only for listed gems)"
36   end
37 
38   def arguments # :nodoc:
39     "GEMNAME       name of gem to install"
40   end
41 
42   def defaults_str # :nodoc:
43     "--both --version '#{Gem::Requirement.default}' --rdoc --ri --no-force\n" \
44     "--no-test --install-dir #{Gem.dir}"
45   end
46 
47   def description # :nodoc:
48     <<-EOF
49 The install command installs local or remote gem into a gem repository.
50 
51 For gems with executables ruby installs a wrapper file into the executable
52 directory by default.  This can be overridden with the --no-wrappers option.
53 The wrapper allows you to choose among alternate gem versions using _version_.
54 
55 For example `rake _0.7.3_ --version` will run rake version 0.7.3 if a newer
56 version is also installed.
57 
58 If an extension fails to compile during gem installation the gem
59 specification is not written out, but the gem remains unpacked in the
60 repository.  You may need to specify the path to the library's headers and
61 libraries to continue.  You can do this by adding a -- between RubyGems'
62 options and the extension's build options:
63 
64   $ gem install some_extension_gem
65   [build fails]
66   Gem files will remain installed in \\
67   /path/to/gems/some_extension_gem-1.0 for inspection.
68   Results logged to /path/to/gems/some_extension_gem-1.0/gem_make.out
69   $ gem install some_extension_gem -- --with-extension-lib=/path/to/lib
70   [build succeeds]
71   $ gem list some_extension_gem
72 
73   *** LOCAL GEMS ***
74 
75   some_extension_gem (1.0)
76   $
77 
78 If you correct the compilation errors by editing the gem files you will need
79 to write the specification by hand.  For example:
80 
81   $ gem install some_extension_gem
82   [build fails]
83   Gem files will remain installed in \\
84   /path/to/gems/some_extension_gem-1.0 for inspection.
85   Results logged to /path/to/gems/some_extension_gem-1.0/gem_make.out
86   $ [cd /path/to/gems/some_extension_gem-1.0]
87   $ [edit files or what-have-you and run make]
88   $ gem spec ../../cache/some_extension_gem-1.0.gem --ruby > \\
89              ../../specifications/some_extension_gem-1.0.gemspec
90   $ gem list some_extension_gem
91 
92   *** LOCAL GEMS ***
93 
94   some_extension_gem (1.0)
95   $
96 
97     EOF
98   end
99 
100   def usage # :nodoc:
101     "#{program_name} GEMNAME [GEMNAME ...] [options] -- --build-flags"
102   end
103 
104   def execute
105     if options[:include_dependencies] then
106       alert "`gem install -y` is now default and will be removed"
107       alert "use --ignore-dependencies to install only the gems you list"
108     end
109 
110     installed_gems = []
111 
112     ENV.delete 'GEM_PATH' if options[:install_dir].nil? and RUBY_VERSION > '1.9'
113 
114     exit_code = 0
115 
116     get_all_gem_names.each do |gem_name|
117       begin
118         inst = Gem::DependencyInstaller.new options
119         inst.install gem_name, options[:version]
120 
121         inst.installed_gems.each do |spec|
122           say "Successfully installed #{spec.full_name}"
123         end
124 
125         installed_gems.push(*inst.installed_gems)
126       rescue Gem::InstallError => e
127         alert_error "Error installing #{gem_name}:\n\t#{e.message}"
128         exit_code |= 1
129       rescue Gem::GemNotFoundException => e
130         show_lookup_failure e.name, e.version, e.errors
131 
132         exit_code |= 2
133       end
134     end
135 
136     unless installed_gems.empty? then
137       gems = installed_gems.length == 1 ? 'gem' : 'gems'
138       say "#{installed_gems.length} #{gems} installed"
139 
140       # NOTE: *All* of the RI documents must be generated first.  For some
141       # reason, RI docs cannot be generated after any RDoc documents are
142       # generated.
143 
144       if options[:generate_ri] then
145         installed_gems.each do |gem|
146           Gem::DocManager.new(gem, options[:rdoc_args]).generate_ri
147         end
148 
149         Gem::DocManager.update_ri_cache
150       end
151 
152       if options[:generate_rdoc] then
153         installed_gems.each do |gem|
154           Gem::DocManager.new(gem, options[:rdoc_args]).generate_rdoc
155         end
156       end
157 
158       if options[:test] then
159         installed_gems.each do |spec|
160           gem_spec = Gem::SourceIndex.from_installed_gems.find_name(spec.name, spec.version.version).first
161           result = Gem::Validator.new.unit_test(gem_spec)
162           if result and not result.passed?
163             unless ask_yes_no("...keep Gem?", true)
164               require 'rubygems/uninstaller'
165               Gem::Uninstaller.new(spec.name, :version => spec.version.version).uninstall
166             end
167           end
168         end
169       end
170     end
171 
172     raise Gem::SystemExitException, exit_code
173   end
174 
175 end
176 

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