C0 code coverage information

Generated on Tue Oct 16 11:40:50 -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/dialogs/book_properties_dialog_base.rb 205 158
36.1% 
20.9% 
  1 # Copyright (C) 2004-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 module Alexandria
 19 module UI
 20     class BookPropertiesDialogBase < GladeBase
 21         include GetText
 22         extend GetText
 23         GetText.bindtextdomain(Alexandria::TEXTDOMAIN, nil, nil, "UTF-8")
 24 
 25         COVER_MAXWIDTH = 140    # pixels
 26 
 27         def initialize(parent, cover_file)
 28             super('book_properties_dialog.glade')
 29             @book_properties_dialog.transient_for = parent
 30             @parent, @cover_file = parent, cover_file
 31 
 32             @entry_title.complete_titles
 33             @entry_title.grab_focus
 34             @entry_publisher.complete_publishers
 35             @entry_edition.complete_editions
 36             @entry_loaned_to.complete_borrowers
 37 
 38             @treeview_authors.model = Gtk::ListStore.new(String, TrueClass)
 39             @treeview_authors.selection.mode = Gtk::SELECTION_SINGLE
 40             renderer = Gtk::CellRendererText.new
 41             renderer.signal_connect('edited') do |cell, path_string, new_text|
 42                 path = Gtk::TreePath.new(path_string)
 43                 iter = @treeview_authors.model.get_iter(path)
 44                 iter[0] = new_text
 45             end
 46             renderer.signal_connect('editing_started') do |cell, entry,
 47                                                            path_string|
 48                 entry.complete_authors
 49             end
 50             col = Gtk::TreeViewColumn.new("", renderer,
 51                                           :text => 0,
 52                                           :editable => 1)
 53             @treeview_authors.append_column(col)
 54         end
 55 
 56         def on_title_changed
 57             title = @entry_title.text.strip
 58             @book_properties_dialog.title = unless title.empty?
 59                 _("Properties for '%s'") % title
 60             else
 61                 _("Properties")
 62             end
 63         end
 64 
 65         def on_add_author
 66             iter = @treeview_authors.model.append
 67             iter[0] = _("Author")
 68             iter[1] = true
 69             @treeview_authors.set_cursor(iter.path,
 70                                          @treeview_authors.get_column(0),
 71                                          true)
 72         end
 73 
 74         def on_remove_author
 75             if iter = @treeview_authors.selection.selected
 76                     @treeview_authors.model.remove(iter)
 77             end
 78         end
 79 
 80         def on_image_rating1_press
 81             self.rating = 1
 82         end
 83 
 84         def on_image_rating2_press
 85             self.rating = 2
 86         end
 87 
 88         def on_image_rating3_press
 89             self.rating = 3
 90         end
 91 
 92         def on_image_rating4_press
 93             self.rating = 4
 94         end
 95 
 96         def on_image_rating5_press
 97             self.rating = 5
 98         end
 99 
100         def on_image_no_rating_press
101             self.rating = 0
102         end
103 
104         def redd_toggled
105         end
106 
107         def own_toggled
108                 if @checkbutton_own.active?
109                         @checkbutton_want.inconsistent = true
110                 else
111                         @checkbutton_want.inconsistent = false
112                 end
113         end
114 
115         def want_toggled
116         end
117 
118         @@latest_filechooser_directory = ENV['HOME']
119         def on_change_cover
120             backend = `uname`.chomp == "FreeBSD" ? "neant" : "gnome-vfs"
121             dialog = Gtk::FileChooserDialog.new(_("Select a cover image"),
122                                                 @book_properties_dialog,
123                                                 Gtk::FileChooser::ACTION_OPEN,
124                                                 backend,
125                                                 [_("No Cover"),
126                                                  Gtk::Dialog::RESPONSE_REJECT],
127                                                 [Gtk::Stock::CANCEL,
128                                                  Gtk::Dialog::RESPONSE_CANCEL],
129                                                 [Gtk::Stock::OPEN,
130                                                  Gtk::Dialog::RESPONSE_ACCEPT])
131             dialog.current_folder = @@latest_filechooser_directory
132             response = dialog.run
133             if response == Gtk::Dialog::RESPONSE_ACCEPT
134                 begin
135                     cover = Gdk::Pixbuf.new(dialog.filename)
136                     # At this stage the file format is recognized.
137                     FileUtils.cp(dialog.filename, @cover_file)
138                     self.cover = cover
139                     @@latest_filechooser_directory = dialog.current_folder
140                 rescue RuntimeError => e
141                     ErrorDialog.new(@book_properties_dialog, e.message)
142                 end
143             elsif response == Gtk::Dialog::RESPONSE_REJECT
144                 FileUtils.rm_f(@cover_file)
145                 self.cover = Icons::BOOK_ICON
146             end
147             dialog.destroy
148         end
149 
150         def on_destroy; end     # no action by default
151 
152         def on_loaned
153             loaned = @checkbutton_loaned.active?
154             @entry_loaned_to.sensitive = loaned
155             @date_loaned_since.sensitive = loaned
156             @label_loaning_duration.visible = loaned
157         end
158 
159         def on_loaned_date_changed
160             loaned_time = Time.at(@date_loaned_since.time)
161             n_days = ((Time.now - loaned_time) / (3600*24)).to_i
162             @label_loaning_duration.label = if n_days > 0
163                 n_("%d day", "%d days", n_days) % n_days
164             else
165                 ""
166             end
167         end
168 
169         #######
170         private
171         #######
172 
173         def rating=(rating)
174             images = [
175                 @image_rating1,
176                 @image_rating2,
177                 @image_rating3,
178                 @image_rating4,
179                 @image_rating5
180             ]
181             raise "out of range" if rating < 0 or rating > images.length
182             images[0..rating-1].each { |x| x.pixbuf = Icons::STAR_SET }
183             images[rating..-1].each { |x| x.pixbuf = Icons::STAR_UNSET }
184             @current_rating = rating
185         end
186 
187         def cover=(pixbuf)
188             if pixbuf.width > COVER_MAXWIDTH
189                 new_height = pixbuf.height /
190                              (pixbuf.width / COVER_MAXWIDTH.to_f)
191                 # We don't want to modify in place the given pixbuf,
192                 # that's why we make a copy.
193                 pixbuf = pixbuf.scale(COVER_MAXWIDTH, new_height)
194             end
195             @image_cover.pixbuf = pixbuf
196         end
197 
198         def loaned_since=(time)
199             @date_loaned_since.time = time.tv_sec
200             # XXX 'date_changed' signal not automatically called after #time=.
201             on_loaned_date_changed
202         end
203     end
204 end
205 end

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

Valid XHTML 1.0! Valid CSS!