Geminstaller C0 Coverage Information - RCov

lib/geminstaller/application.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
lib/geminstaller/application.rb 109 98
98.17%
97.96%

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 Application
3     # we have accessors instead of just writers so that we can ensure it is assembled correctly in the dependency injector test
4     attr_accessor :config_builder, :install_processor, :output_filter, :arg_parser, :args, :options, :rogue_gem_finder, :bundler_exporter
5     attr_writer :autogem
6     
7     def initialize
8       @args = nil
9     end
10     
11     def install
12       begin
13         exit_flag_and_return_code = handle_args
14         if exit_flag_and_return_code[0]
15           return exit_flag_and_return_code[1]
16         end
17         if @options[:bundler_export]
18           @bundler_exporter.output(@config_builder.build_config)
19           return 0
20         end
21         gems = create_gems_from_config
22         if @options[:print_rogue_gems]
23           @rogue_gem_finder.print_rogue_gems(gems, @config_builder.config_file_paths_array)
24           return 0
25         end
26         if gems.size == 0
27           message = "No gems found in config file.  Try the --print-rogue-gems option to help populate your config file."
28           @output_filter.geminstaller_output(:info,message + "\n")          
29         else
30           process_gems(gems)
31         end
32       rescue Exception => e
33         handle_exception(e)
34         return 1
35       end
36       return 0
37     end
38     
39     def autogem
40       begin
41         # TODO: do some validation that args only contains --config option, especially not print_rogue_gems since this would mask a missing file error
42         exit_flag_and_return_code = handle_args
43         if exit_flag_and_return_code[0]
44           return exit_flag_and_return_code[1]
45         end
46         gems = create_gems_from_config
47         message = "GemInstaller is automatically requiring gems: "
48         print_startup_message(gems, message)
49         return @autogem.autogem(gems)
50       rescue Exception => e
51         handle_exception(e)
52         return 1
53       end
54     end
55     
56     def handle_exception(e)
57       message = e.message
58       message += "\n"
59       @output_filter.geminstaller_output(:error,message)
60       backtrace_as_string = e.backtrace.join("\n")
61       @output_filter.geminstaller_output(:debug,"#{backtrace_as_string}\n")
62       raise e if @options[:exceptions]
63     end
64     
65     def create_gems_from_config
66       begin
67         config = @config_builder.build_config
68       rescue GemInstaller::MissingFileError => e
69         # if user wants to print rogue gems and they have no config at all, don't show an error
70         return [] if @options[:print_rogue_gems] && (@config_builder.config_file_paths_array.size == 1) 
71         missing_path = e.message
72         error_message = "Error: A GemInstaller config file is missing at #{missing_path}.  You can generate one with the --print-rogue-gems option.  See the GemInstaller docs at http://geminstaller.rubyforge.org for more info."
73         raise GemInstaller::MissingFileError.new(error_message)
74       end
75       config.gems
76     end
77     
78     def process_gems(gems)
79       message = "GemInstaller is verifying gem installation: "
80       print_startup_message(gems, message)
81       @install_processor.process(gems)
82     end
83 
84     def handle_args
85       return_code = @arg_parser.parse(@args)
86       arg_parser_output = @arg_parser.output
87       if (arg_parser_output && arg_parser_output != '')
88         if return_code == 0
89           @output_filter.geminstaller_output(:info,arg_parser_output)
90         else
91           @output_filter.geminstaller_output(:error,arg_parser_output)
92         end
93         return [true, return_code]
94       end
95       config_file_paths = @options[:config_paths]
96       @config_builder.config_file_paths = config_file_paths if config_file_paths
97       return [false, 0]
98     end
99 
100     def print_startup_message(gems, message)
101       gems.each_with_index do |gem, index|
102         gem_info = "#{gem.name} #{gem.version}"
103         message += gem_info 
104         message += ", " if index + 1 < gems.size
105       end
106       @output_filter.geminstaller_output(:debug,message + "\n")
107     end
108   end
109 end

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