C0 code coverage information

Generated on Sat Feb 02 17:44:25 +0100 2008 with rcov 0.8.1.2


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/ramaze/gestalt.rb 127 51
69.3% 
27.5% 
  1 #          Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com
  2 # All files in this distribution are subject to the terms of the Ruby license.
  3 
  4 =begin rdoc
  5 Example:
  6 
  7   require 'ramaze'
  8   require 'ramaze/gestalt'
  9 
 10   def random_color
 11     ('#' << '%02x' * 3) % (1..3).map{ rand(255) }
 12   end
 13 
 14   puts Ramaze::Gestalt.build{
 15     html do
 16       head do
 17         title{"Hello World"}
 18       end
 19       body do
 20         h1{"Hello, World!"}
 21         div(:style => 'width:100%') do
 22           10.times do
 23             div(:style => "width:#{rand(100)}%;height:#{rand(100)}%;background:#{random_color}"){ '&nbsp;' }
 24           end
 25         end
 26       end
 27     end
 28   }
 29 =end
 30 
 31 module Ramaze
 32 
 33   # Gestalt is the custom HTML/XML builder for Ramaze, based on a very simple
 34   # DSL it will build your markup.
 35 
 36   class Gestalt
 37     attr_accessor :out
 38 
 39     # The default way to start building your markup.
 40     # Takes a block and returns the markup.
 41     #
 42     # Example:
 43     #   html =
 44     #     Gestalt.build do
 45     #       html do
 46     #         head do
 47     #           title "Hello, World!"
 48     #         end
 49     #         body do
 50     #           h1 "Hello, World!"
 51     #         end
 52     #       end
 53     #     end
 54     #
 55 
 56     def self.build &block
 57       self.new(&block).to_s
 58     end
 59 
 60     # Gestalt.new is like ::build but will return itself.
 61     # you can either access #out or .to_s it, which will
 62     # return the actual markup.
 63     #
 64     # Useful for distributed building of one page.
 65 
 66     def initialize &block
 67       @out = ''
 68       instance_eval(&block) if block_given?
 69     end
 70 
 71     # catching all the tags. passing it to _gestalt_build_tag
 72 
 73     def method_missing meth, *args, &block
 74       _gestalt_call_tag meth, args, &block
 75     end
 76 
 77     # workaround for Kernel#p to make <p /> tags possible.
 78 
 79     def p *args, &block
 80       _gestalt_call_tag :p, args, &block
 81     end
 82 
 83     def _gestalt_call_tag name, args, &block
 84       if args.size == 1 and args[0].kind_of? Hash
 85         # args are just attributes, children in block...
 86         _gestalt_build_tag name, args[0], &block
 87       else
 88         # no attributes, but text
 89         _gestalt_build_tag name, {}, args, &block
 90       end
 91     end
 92 
 93     # build a tag for `name`, using `args` and an optional block that
 94     # will be yielded
 95 
 96     def _gestalt_build_tag name, attr={}, text=[]
 97       @out << "<#{name}"
 98       @out << attr.inject(''){ |s,v| s << %{ #{v[0]}="#{_gestalt_escape_entities(v[1])}"} }
 99       if text != [] or block_given?
100         @out << ">"
101         @out << _gestalt_escape_entities([text].join)
102         if block_given?
103           text = yield
104           @out << text.to_str if text != @out and text.respond_to?(:to_str)
105         end
106         @out << "</#{name}>"
107       else
108         @out << ' />'
109       end
110     end
111 
112     def _gestalt_escape_entities(s)
113       s.to_s.gsub(/&/, '&amp;').
114         gsub(/"/, '&quot;').
115         gsub(/'/, '&apos;').
116         gsub(/</, '&lt;').
117         gsub(/>/, '&gt;')
118     end
119 
120     # @out.to_s
121 
122     def to_s
123       @out.to_s
124     end
125     alias to_str to_s
126   end
127 end

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

Valid XHTML 1.0! Valid CSS!