C0 code coverage information

Generated on Tue Oct 16 11:40:49 -0400 2007 with rcov 0.8.0


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/alexandria/ui/completion_models.rb 182 129
42.9% 
25.6% 
  1 # Copyright (C) 2005-2006 Laurent Sansonetti
  2 #
  3 # Alexandria is free software; you can redistribute it and/or
  4 # modify it under the terms of the GNU General Public License as
  5 # published by the Free Software Foundation; either version 2 of the
  6 # License, or (at your option) any later version.
  7 #
  8 # Alexandria is distributed in the hope that it will be useful,
  9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
 10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 11 # General Public License for more details.
 12 #
 13 # You should have received a copy of the GNU General Public
 14 # License along with Alexandria; see the file COPYING.  If not,
 15 # write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 16 # Boston, MA 02111-1307, USA.
 17 
 18 class Gtk::Entry
 19     def complete_titles
 20         complete(Alexandria::UI::CompletionModels::TITLE)
 21     end
 22 
 23     def complete_authors
 24         complete(Alexandria::UI::CompletionModels::AUTHOR)
 25     end
 26 
 27     def complete_publishers
 28         complete(Alexandria::UI::CompletionModels::PUBLISHER)
 29     end
 30 
 31     def complete_editions
 32         complete(Alexandria::UI::CompletionModels::EDITION)
 33     end
 34 
 35     def complete_borrowers
 36         complete(Alexandria::UI::CompletionModels::BORROWER)
 37     end
 38 
 39     #######
 40     private
 41     #######
 42 
 43     def complete(model_id)
 44         completion = Gtk::EntryCompletion.new
 45         model = Alexandria::UI::CompletionModels.instance.models[model_id]
 46         completion.model = model
 47         completion.text_column = 0
 48         self.completion = completion 
 49     end
 50 end
 51 
 52 begin
 53     require 'revolution'
 54     
 55     EVOLUTION_CONTACTS = 
 56         Revolution::Revolution.new.get_all_contacts.map do |contact|
 57         
 58         first, last = contact.first_name, contact.last_name
 59         
 60         if first
 61             first.strip!
 62             first = nil if first.empty?
 63         end
 64 
 65         if last
 66             last.strip!
 67             last = nil if last.empty?
 68         end
 69 
 70         first and last ? first + ' ' + last : first ? first : last
 71     end
 72 rescue LoadError
 73     EVOLUTION_CONTACTS = []
 74 end
 75 
 76 module Alexandria
 77 module UI
 78     class CompletionModels
 79         include Singleton
 80 
 81         TITLE, AUTHOR, PUBLISHER, EDITION, BORROWER = (0..5).to_a
 82 
 83         def initialize
 84             @models, @libraries = [], []
 85             5.times { @models << Gtk::ListStore.new(String) }
 86             touch
 87         end
 88 
 89         def add_source(library)
 90             @libraries << library
 91             library.add_observer(self)
 92             touch
 93         end
 94 
 95         def remove_source(library)
 96             @libraries.delete_if { |x| x.name == library.name}
 97             library.delete_observer(self)
 98             touch
 99         end
100 
101         def update(library, kind, book)
102             # FIXME: Do not rebuild all the models there.
103             touch
104         end
105 
106         def models
107             rebuild_models if dirty?
108             @models
109         end
110  
111         def title_model
112             rebuild_models if dirty?
113             @models[TITLE]
114         end
115 
116         def author_model
117             rebuild_models if dirty?
118             @models[AUTHOR]
119         end
120 
121         def publisher_model
122             rebuild_models if dirty?
123             @models[PUBLISHER]
124         end
125         
126         def edition_model
127             rebuild_models if dirty?
128             @models[EDITION]
129         end
130 
131         def borrower_model
132             rebuilds_models if dirty?
133             @models[BORROWER]
134         end
135 
136         #######
137         private
138         #######
139             
140         def touch
141             @dirty = true
142         end
143 
144         def dirty?
145             @dirty
146         end
147 
148         def rebuild_models
149             titles, authors, publishers, editions, borrowers = [],[],[],[],[]
150             @libraries.each do |library|
151                 library.each do |book|
152                     titles << book.title
153                     authors.concat(book.authors)
154                     publishers << book.publisher
155                     editions << book.edition
156                     borrowers << book.loaned_to
157                 end
158             end
159 
160             borrowers.concat(EVOLUTION_CONTACTS)
161             borrowers.uniq!
162 
163             fill_model(@models[TITLE], titles)
164             fill_model(@models[AUTHOR], authors)
165             fill_model(@models[EDITION], editions)
166             fill_model(@models[PUBLISHER], publishers)
167             fill_model(@models[BORROWER], borrowers)
168             @dirty = false
169         end
170 
171         def fill_model(model, values)
172             model.clear
173             iter = nil
174             values.uniq.each do |value|
175                 next if value.nil?
176                 iter = iter ? model.insert_after(iter) : model.append 
177                 iter[0] = value
178             end
179         end
180     end
181 end
182 end

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

Valid XHTML 1.0! Valid CSS!