C0 code coverage information

Generated on Wed Oct 07 08:33:56 -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/core/common.rb 150 55
90.0%  
74.5%  
  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 'rake'
 18 require 'buildr/core/util'
 19 
 20 
 21 module Buildr
 22 
 23   # :call-seq:
 24   #   struct(hash) => Struct
 25   #
 26   # Convenience method for creating an anonymous Struct.
 27   #
 28   # For example:
 29   #   COMMONS             = struct(
 30   #     :collections      =>'commons-collections:commons-collections:jar:3.1',
 31   #     :lang             =>'commons-lang:commons-lang:jar:2.1',
 32   #     :logging          =>'commons-logging:commons-logging:jar:1.0.3',
 33   #   )
 34   #
 35   #   compile.with COMMONS.logging
 36   def struct(hash)
 37     Struct.new(nil, *hash.keys).new(*hash.values)  
 38   end
 39 
 40   # :call-seq:
 41   #   write(name, content)
 42   #   write(name) { ... }
 43   #
 44   # Write the contents into a file. The second form calls the block and writes the result.
 45   #
 46   # For example:
 47   #   write 'TIMESTAMP', Time.now
 48   #   write('TIMESTAMP') { Time.now }
 49   #
 50   # Yields to the block before writing the file, so you can chain read and write together.
 51   # For example:
 52   #   write('README') { read('README').sub("${build}", Time.now) }
 53   def write(name, content = nil)
 54     mkpath File.dirname(name)
 55     content = yield if block_given?
 56     File.open(name.to_s, 'wb') { |file| file.write content.to_s }
 57     content.to_s
 58   end
 59 
 60   # :call-seq:
 61   #   read(name) => string
 62   #   read(name) { |string| ... } => result
 63   #
 64   # Reads and returns the contents of a file. The second form yields to the block and returns
 65   # the result of the block.
 66   #
 67   # For example:
 68   #   puts read('README')
 69   #   read('README') { |text| puts text }
 70   def read(name)
 71     contents = File.open(name.to_s) { |f| f.read }
 72     if block_given?
 73       yield contents
 74     else
 75       contents
 76     end
 77   end
 78 
 79   # :call-seq:
 80   #    download(url_or_uri) => task
 81   #    download(path=>url_or_uri) =>task
 82   #
 83   # Create a task that will download a file from a URL.
 84   #
 85   # Takes a single argument, a hash with one pair. The key is the file being
 86   # created, the value if the URL to download. The task executes only if the
 87   # file does not exist; the URL is not checked for updates.
 88   #
 89   # The task will show download progress on the console; if there are MD5/SHA1
 90   # checksums on the server it will verify the download before saving it.
 91   #
 92   # For example:
 93   #   download 'image.jpg'=>'http://example.com/theme/image.jpg'
 94   def download(args)
 95     args = URI.parse(args) if String === args
 96     if URI === args
 97       # Given only a download URL, download into a temporary file.
 98       # You can infer the file from task name.
 99       temp = Tempfile.open(File.basename(args.to_s))
100       file(temp.path).tap do |task|
101         # Since temporary file exists, force a download.
102         class << task ; def needed? ; true ; end ; end
103         task.sources << args
104         task.enhance { args.download temp }
105       end
106     else
107       # Download to a file created by the task.
108       fail unless args.keys.size == 1
109       uri = URI.parse(args.values.first.to_s)
110       file(args.keys.first.to_s).tap do |task|
111         task.sources << uri
112         task.enhance { uri.download task.name }
113       end
114     end
115 
116   end
117 
118   # A file task that concatenates all its prerequisites to create a new file.
119   #
120   # For example:
121   #   concat("master.sql"=>["users.sql", "orders.sql", reports.sql"]
122   #
123   # See also Buildr#concat.
124   class ConcatTask < Rake::FileTask
125     def initialize(*args) #:nodoc:
126       super
127       enhance do |task|
128         content = prerequisites.inject("") do |content, prereq|
129           content << File.read(prereq.to_s) if File.exists?(prereq) && !File.directory?(prereq)
130           content
131         end
132         File.open(task.name, "wb") { |file| file.write content }
133       end
134     end
135   end
136 
137   # :call-seq:
138   #    concat(target=>files) => task
139   #
140   # Creates and returns a file task that concatenates all its prerequisites to create
141   # a new file. See #ConcatTask.
142   #
143   # For example:
144   #   concat("master.sql"=>["users.sql", "orders.sql", reports.sql"]
145   def concat(args)
146     file, arg_names, deps = Buildr.application.resolve_args([args])
147     ConcatTask.define_task(File.expand_path(file)=>deps)
148   end
149 
150 end

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

Valid XHTML 1.0! Valid CSS!