Geminstaller C0 Coverage Information - RCov

lib/geminstaller/gem_runner_proxy.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
lib/geminstaller/gem_runner_proxy.rb 65 56
87.69%
85.71%

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 module GemInstaller
2   class GemRunnerProxy
3     attr_writer :gem_runner_class, :gem_cmd_manager_class, :output_listener, :exact_match_list_command
4     attr_writer :options, :enhanced_stream_ui, :output_filter
5 
6     def run(args = [], stdin = [])
7       @output_filter.geminstaller_output(:commandecho,"'gem #{args.join(' ')}'\n")
8       gem_runner = create_gem_runner
9       # We have to manually initialize the configuration here, or else the GemCommandManager singleton
10       # will initialize with the (incorrect) default args when we call GemRunner.run.
11       gem_runner.do_configuration(args)
12       gem_cmd_manager = @gem_cmd_manager_class.instance
13       gem_cmd_manager.ui = @enhanced_stream_ui
14       gem_cmd_manager.commands[:list] = @exact_match_list_command
15       
16       exit_status = nil
17       begin
18         # The call below is to work around RubyGem's behavior of caching (only) the last-used source when
19         # multiple gem commands for gems on different sources are issued via the API
20         Gem.sources.replace Gem.default_sources
21         gem_runner.run(args)
22       rescue SystemExit => system_exit
23         if GemInstaller::RubyGemsVersionChecker.matches?('>1.0.1')
24           raise system_exit unless system_exit.is_a? Gem::SystemExitException
25           exit_status = system_exit.message
26         else
27           raise system_exit
28         end
29       rescue GemInstaller::RubyGemsExit => normal_exit
30         exit_status = normal_exit.message
31       rescue GemInstaller::GemInstallerError => exit_error
32         raise_error_with_output(exit_error, args, @output_listener)
33       end
34       output_lines = @output_listener.read!
35       output_lines.push(exit_status) if exit_status
36       output_lines.collect do |line|
37         line.split("\n")
38       end.flatten
39     end
40     
41     def create_gem_runner
42       if GemInstaller::RubyGemsVersionChecker.matches?('< 0.9')
43         @gem_runner_class.new()
44       else
45         @gem_runner_class.new(:command_manager => @gem_cmd_manager_class)
46       end
47     end
48         
49     def raise_error_with_output(exit_error, args, listener)
50       error_class = exit_error.class
51       error_message = exit_error.message
52       gem_command_output = listener.read!
53       if gem_command_output.join('') =~ /Errno::EACCES/
54         error_message = access_error_message + "\n" + error_message
55         error_class = GemInstaller::GemInstallerAccessError
56       end      
57       descriptive_exit_message = exit_error.descriptive_exit_message(error_message, 'gem', args, gem_command_output)
58       raise error_class.new(descriptive_exit_message)
59     end
60     
61     def access_error_message
62       "You don't have permission to install a gem.\nThis is not a problem with GemInstaller.\nYou probably want use the --sudo option or run GemInstaller as sudo,\nor install your gems to a non-root-owned location.\nSee http://geminstaller.rubyforge.org/documentation/documentation.html#dealing_with_sudo\n"
63     end
64   end
65 end

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