C0 code coverage information

Generated on Wed Oct 07 08:34:00 -0700 2009 with rcov 0.8.2.1


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.
Name Total lines Lines of code Total coverage Code coverage
lib/buildr/ide/idea7x.rb 212 147
84.4%  
77.6%  
  1 # Licensed to the Apache Software Foundation (ASF) under one or more
  2 # contributor license agreements.  See the NOTICE file distributed with this
  3 # work for additional information regarding copyright ownership.  The ASF
  4 # licenses this file to you under the Apache License, Version 2.0 (the
  5 # "License"); you may not use this file except in compliance with the License.
  6 # You may obtain a copy of the License at
  7 #
  8 #    http://www.apache.org/licenses/LICENSE-2.0
  9 #
 10 # Unless required by applicable law or agreed to in writing, software
 11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 13 # License for the specific language governing permissions and limitations under
 14 # the License.
 15 
 16 
 17 require 'buildr/core/project'
 18 require 'buildr/packaging'
 19 require 'stringio'
 20 
 21 
 22 module Buildr
 23   module Idea7x #:nodoc:
 24 
 25     include Extension
 26 
 27     CLASSIFIER = "-7x"
 28     IML_SUFFIX = CLASSIFIER + ".iml"
 29     IPR_TEMPLATE = "idea7x.ipr.template"
 30     MODULE_DIR = "$MODULE_DIR$"
 31     FILE_PATH_PREFIX = "file://"
 32     MODULE_DIR_URL = FILE_PATH_PREFIX + MODULE_DIR
 33     PROJECT_DIR = "$PROJECT_DIR$"
 34     PROJECT_DIR_URL = FILE_PATH_PREFIX + PROJECT_DIR
 35 
 36     first_time do
 37       # Global task "idea" generates artifacts for all projects.
 38       desc "Generate Idea 7.x artifacts for all projects"
 39       Project.local_task "idea7x"=>"artifacts"
 40     end
 41 
 42     before_define do |project|
 43       project.recursive_task("idea7x")
 44     end
 45 
 46     after_define do |project|
 47       idea7x = project.task("idea7x")
 48 
 49       # We need paths relative to the top project's base directory.
 50       root_path = lambda { |p| f = lambda { |p| p.parent ? f[p.parent] : p.base_dir }; f[p] }[project]
 51 
 52       # Find a path relative to the project's root directory.
 53       relative = lambda { |path| Util.relative_path(File.expand_path(path.to_s), project.path_to) }
 54 
 55       m2repo = Buildr::Repositories.instance.local
 56       excludes = [ '**/.svn/', '**/CVS/' ].join('|')
 57 
 58       # Only for projects that are packageable.
 59       task_name = project.path_to("#{project.name.gsub(':', '-')}#{IML_SUFFIX}")
 60       idea7x.enhance [ file(task_name) ]
 61 
 62       # The only thing we need to look for is a change in the Buildfile.
 63       file(task_name=>Buildr.application.buildfile) do |task|
 64         # Note: Use the test classpath since Eclipse compiles both "main" and "test" classes using the same classpath
 65         deps = project.test.compile.dependencies.map(&:to_s) - [ project.compile.target.to_s ]
 66 
 67         # Convert classpath elements into applicable Project objects
 68         deps.collect! { |path| Buildr.projects.detect { |prj| prj.packages.detect { |pkg| pkg.to_s == path } } || path }
 69 
 70         # project_libs: artifacts created by other projects
 71         project_libs, others = deps.partition { |path| path.is_a?(Project) }
 72 
 73         # Separate artifacts from Maven2 repository
 74         m2_libs, others = others.partition { |path| path.to_s.index(m2repo) == 0 }
 75 
 76         # Project type is going to be the first package type
 77         if package = project.packages.first
 78           info "Writing #{task.name}"
 79           File.open(task.name, "w") do |file|
 80             xml = Builder::XmlMarkup.new(:target=>file, :indent=>2)
 81             xml.module(:version=>"4", :relativePaths=>"true", :type=>"JAVA_MODULE") do
 82               xml.component(:name=>"NewModuleRootManager", "inherit-compiler-output"=>"false") do
 83 
 84                 Buildr::Idea7x.generate_compile_output(project, xml, relative)
 85 
 86                 Buildr::Idea7x.generate_content(project, xml, relative)
 87 
 88                 Buildr::Idea7x.generate_order_entries(project_libs, xml)
 89 
 90                 ext_libs = m2_libs.map { |path| "jar://#{path.to_s.sub(m2repo, "$M2_REPO$")}!/" }
 91                 ext_libs << "#{MODULE_DIR_URL}/#{relative[project.test.resources.target.to_s]}" if project.test.resources.target
 92                 ext_libs << "#{MODULE_DIR_URL}/#{relative[project.resources.target.to_s]}" if project.resources.target
 93                 
 94                 Buildr::Idea7x.generate_module_libs(xml, ext_libs)
 95                 xml.orderEntryProperties
 96               end
 97             end
 98           end
 99         end
100       end
101 
102       # Root project aggregates all the subprojects.
103       if project.parent == nil
104         Buildr::Idea7x.generate_ipr(project, idea7x, Buildr.application.buildfile)
105       end
106 
107     end # after_define
108 
109     class << self
110 
111       def generate_order_entries(project_libs, xml)
112         xml.orderEntry :type=>"sourceFolder", :forTests=>"false"
113         xml.orderEntry :type=>"inheritedJdk"
114 
115         # Classpath elements from other projects
116         project_libs.map(&:id).sort.uniq.each do |project_id|
117           xml.orderEntry :type=>'module', "module-name"=>"#{project_id}#{CLASSIFIER}"
118         end
119       end
120 
121       def generate_compile_output(project, xml, relative)
122         xml.output(:url=>"#{MODULE_DIR_URL}/#{relative[project.compile.target.to_s]}") if project.compile.target
123         xml.tag!("output-test", :url=>"#{MODULE_DIR_URL}/#{relative[project.test.compile.target.to_s]}") if project.test.compile.target
124         xml.tag!("exclude-output")
125       end
126 
127       def generate_content(project, xml, relative)
128         xml.content(:url=>"#{MODULE_DIR_URL}") do
129           unless project.compile.sources.empty?
130             srcs = project.compile.sources.map { |src| relative[src.to_s] }
131             srcs.sort.uniq.each do |path|
132               xml.sourceFolder :url=>"#{MODULE_DIR_URL}/#{path}", :isTestSource=>"false"
133             end
134           end
135           unless project.test.compile.sources.empty?
136             test_sources = project.test.compile.sources.map { |src| relative[src.to_s] }
137             test_sources.each do |paths|
138               paths.sort.uniq.each do |path|
139                 xml.sourceFolder :url=>"#{MODULE_DIR_URL}/#{path}", :isTestSource=>"true"
140               end
141             end
142           end
143           [project.resources=>false, project.test.resources=>true].each do |resources, test|
144             resources.each do |path|
145               path[0].sources.each do |srcpath|
146                 xml.sourceFolder :url=>"#{FILE_PATH_PREFIX}#{srcpath}", :isTestSource=>path[1].to_s
147               end
148             end
149           end
150           xml.excludeFolder :url=>"#{MODULE_DIR_URL}/#{relative[project.resources.target.to_s]}" if project.resources.target
151           xml.excludeFolder :url=>"#{MODULE_DIR_URL}/#{relative[project.test.resources.target.to_s]}" if project.test.resources.target
152         end
153       end
154 
155       def generate_module_libs(xml, ext_libs)
156         ext_libs.each do |path|
157           xml.orderEntry :type=>"module-library" do
158             xml.library do
159               xml.CLASSES do
160                 xml.root :url=> path
161               end
162               xml.JAVADOC
163               xml.SOURCES do
164                 xml.root :url=>"jar://#{path.sub(/\.jar$/, "-sources.jar")}!/"
165               end
166             end
167           end
168         end
169       end
170 
171       def generate_ipr(project, idea7x, sources)
172         task_name = project.path_to("#{project.name.gsub(':', '-')}-7x.ipr")
173         idea7x.enhance [ file(task_name) ]
174         file(task_name=>sources) do |task|
175           info "Writing #{task.name}"
176 
177           # Generating just the little stanza that chanages from one project to another
178           partial = StringIO.new
179           xml = Builder::XmlMarkup.new(:target=>partial, :indent=>2)
180           xml.component(:name=>"ProjectModuleManager") do
181             xml.modules do
182               project.projects.each do |subp|
183                 module_name = subp.name.gsub(":", "-")
184                 module_path = subp.base_dir ? subp.base_dir.gsub(/^#{project.base_dir}\//, '') :
185                                               subp.name.split(":")[1 .. -1].join(FILE::SEPARATOR)
186                 path = "#{module_path}/#{module_name}#{IML_SUFFIX}"
187                 xml.module :fileurl=>"#{PROJECT_DIR_URL}/#{path}", :filepath=>"#{PROJECT_DIR}/#{path}"
188               end
189               if package = project.packages.first
190                 xml.module :fileurl=>"#{PROJECT_DIR_URL}/#{project.name}#{IML_SUFFIX}", :filepath=>"#{PROJECT_DIR}/#{project.name}#{IML_SUFFIX}"
191               end
192             end
193           end
194 
195           # Loading the whole fairly constant crap
196           template_xml = REXML::Document.new(File.open(File.join(File.dirname(__FILE__), IPR_TEMPLATE)))
197           include_xml = REXML::Document.new(partial.string)
198           template_xml.root.add_element(include_xml.root)
199           File.open task.name, 'w' do |file|
200             template_xml.write file
201           end
202         end
203       end
204 
205     end
206 
207   end  # module Idea7x
208 end # module Buildr
209 
210 class Buildr::Project
211   include Buildr::Idea7x
212 end

Generated using the rcov code coverage analysis tool for Ruby version 0.8.2.1.

Valid XHTML 1.0! Valid CSS!