Geminstaller C0 Coverage Information - RCov

lib/geminstaller/gem_list_checker.rb

Name Total Lines Lines of Code Total Coverage Code Coverage
lib/geminstaller/gem_list_checker.rb 55 41
100.00%
100.00%

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 GemListChecker
3     attr_writer :gem_command_manager, :gem_arg_processor, :version_specifier
4     
5     def find_remote_matching_gem(gem)
6       gem_list_match_regexp =  /^#{gem.regexp_escaped_name} \(.*/
7       common_args = @gem_arg_processor.strip_non_common_gem_args(gem.install_options)
8       remote_list = @gem_command_manager.list_remote_gem(gem, common_args)
9 
10       matched_lines = []
11       remote_list.each do |line|
12         if line.match(gem_list_match_regexp)
13           matched_lines << line
14         end
15       end
16       
17       if matched_lines.size > 1
18         error_message = "Error: more than one remote gem matches (this should not happen and is probably a bug in geminstaller).  Gem name = '#{gem.name}', install options = '#{gem.install_options.join(' ')}'.  Matching remote gems: \n"
19         matched_lines.each do |line|
20           error_message += line + "\n"
21         end
22         raise GemInstaller::GemInstallerError.new(error_message)
23       end
24 
25       if matched_lines.size == 0
26         error_message = "Error: Could not find remote gem to install.  Gem name = '#{gem.name}', Gem version = '#{gem.version}', install options = '#{gem.install_options.join(' ')}'.  Your remote gem server may be having problems.  You should try to list the remote gem yourself:  'gem list -r -v '#{gem.version}' #{common_args.join(' ')} #{gem.name}'.  If it exists on the server, try running geminstaller again and open a ticket here: http://thewoolleyweb.lighthouseapp.com/projects/11580-geminstaller.  Output of remote gem list command: \n#{remote_list}"
27         raise GemInstaller::GemInstallerError.new(error_message)
28       end
29 
30       return matched_lines[0]
31     end
32     
33     def verify_and_specify_remote_gem!(gem)
34       # TODO: this seems like it is a hack, but we must have a non-ambiguous version on the gem in order for 
35       # noninteractive_chooser to be able to parse the gem list for multi-platform gems.  This will not be necessary
36       # if a future RubyGems release allows specification/searching of the platform, because then we won't need noninteractive_chooser
37       
38       version_list = available_versions(gem)
39       specified_version = @version_specifier.specify(gem.version, version_list, gem.name)
40       gem.version = specified_version
41     end
42 
43     def available_versions(gem)
44       remote_match_line = find_remote_matching_gem(gem)
45       version_list = parse_out_version_list(remote_match_line)
46     end
47     
48     def parse_out_version_list(line)
49       # return everything between first set of parenthesis
50       version_list = line.split(/[()]/)[1]
51       version_list
52     end
53         
54   end
55 end

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