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.rb 166 125
21.1% 
8.8% 
  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 BookPropertiesDialog < BookPropertiesDialogBase
 21         include GetText
 22         extend GetText
 23         GetText.bindtextdomain(Alexandria::TEXTDOMAIN, nil, nil, "UTF-8")
 24 #		def initialize(parent, library, book, &on_close_cb)
 25         def initialize(parent, library, book)
 26             super(parent, library.cover(book))
 27             puts "Initializing Book Properties Dialog..." if $DEBUG
 28 
 29             cancel_button = Gtk::Button.new(Gtk::Stock::CANCEL)
 30             cancel_button.signal_connect('clicked') { on_cancel }
 31             cancel_button.show
 32             @button_box << cancel_button
 33 
 34             #@on_close_cb = on_close_cb Not really hooked up to anything... (JCM)
 35             close_button = Gtk::Button.new(Gtk::Stock::SAVE)
 36             close_button.signal_connect('clicked') { on_close }
 37             close_button.show
 38             @button_box << close_button
 39            
 40             help_button = Gtk::Button.new(Gtk::Stock::HELP)
 41             help_button.signal_connect('clicked') { on_help }
 42             help_button.show
 43             @button_box << help_button
 44             @button_box.set_child_secondary(help_button, true)
 45            
 46             @entry_title.text = @book_properties_dialog.title = book.title
 47             @entry_isbn.text = (book.isbn or "")
 48             @entry_publisher.text = book.publisher
 49             @entry_publish_date.text = (book.publishing_year.to_s \
 50                                         rescue "")
 51             @entry_publish_date.signal_connect('focus-out-event') do
 52                 text = @entry_publish_date.text 
 53                 unless text.empty?
 54                     year = text.to_i
 55                     if year == 0 or year > (Time.now.year + 10) or year < 10
 56                         @entry_publish_date.text = ""
 57                         @entry_publish_date.grab_focus
 58                         true 
 59                     elsif year < 100
 60                         @entry_publish_date.text = "19" + year.to_s
 61                         false
 62                     end
 63                 else
 64                     false
 65                 end              
 66             end
 67             @entry_edition.text = book.edition
 68             if book.tags
 69             	@entry_tags.text = book.tags.join(" ")
 70             end
 71             
 72             book.authors.each do |author|
 73                 iter = @treeview_authors.model.append
 74                 iter[0] = author
 75                 iter[1] = true
 76             end
 77         
 78             buffer = Gtk::TextBuffer.new
 79             buffer.text = (book.notes or "")
 80             @textview_notes.buffer = buffer
 81            
 82             @library, @book = library, book
 83             self.cover = Icons.cover(library, book)
 84             self.rating = (book.rating or Book::DEFAULT_RATING)
 85             
 86             if @checkbutton_loaned.active = book.loaned?
 87                 @entry_loaned_to.text = (book.loaned_to or "")
 88                 self.loaned_since = (book.loaned_since or Time.now)
 89             end
 90             
 91             @checkbutton_own.active = book.own?
 92             @checkbutton_redd.active = book.redd?
 93             @checkbutton_want.active = book.want?
 94             
 95             if @checkbutton_own.active = book.own?
 96             	@checkbutton_want.inconsistent = true
 97             end
 98             
 99              
100             
101         end
102 
103         #######
104         private
105         #######
106         
107         def on_close
108             if @entry_isbn.text == ""
109                 @book.isbn = nil
110             else
111                 ary = @library.select { |book| book.ident == @entry_isbn.text }
112                 unless ary.empty? or (ary.length == 1 and ary.first == @book)
113                     ErrorDialog.new(@parent, 
114                                     _("Couldn't modify the book"), 
115                                     _("The EAN/ISBN you provided is already " +
116                                       "used in this library."))
117                     return
118                 end                   
119                 @book.isbn = begin
120                     Library.canonicalise_ean(@entry_isbn.text)
121                 rescue Alexandria::Library::InvalidISBNError
122                     ErrorDialog.new(@parent, 
123                                     _("Couldn't modify the book"), 
124                                     _("Couldn't validate the EAN/ISBN you " +
125                                       "provided.  Make sure it is written " +
126                                       "correcty, and try again."))
127                     return
128                 end
129             end
130             @book.title = @entry_title.text
131             @book.publisher = @entry_publisher.text
132             year = @entry_publish_date.text.to_i
133             @book.publishing_year = year == 0 ? nil : year
134             @book.edition = @entry_edition.text
135             @book.authors = []
136             @treeview_authors.model.each { |m, p, i| @book.authors << i[0] }      
137             @book.notes = @textview_notes.buffer.text 
138             @book.rating = @current_rating
139            
140             @book.loaned = @checkbutton_loaned.active?
141             @book.loaned_to = @entry_loaned_to.text
142             @book.loaned_since = Time.at(@date_loaned_since.time)
143            
144            	@book.redd = @checkbutton_redd.active?
145            	@book.own = @checkbutton_own.active?
146             @book.want = @checkbutton_want.active?
147             @book.tags = @entry_tags.text.split
148             @library.save(@book) 
149             #@on_close_cb.call(@book)
150             @book_properties_dialog.destroy
151         end
152 
153         def on_cancel
154             @book_properties_dialog.destroy
155         end
156 
157         def on_help
158             begin
159                 Gnome::Help.display('alexandria', 'editing-book-properties')
160             rescue => e 
161                 ErrorDialog.new(@preferences_dialog, e.message)
162             end
163         end
164     end
165 end
166 end

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

Valid XHTML 1.0! Valid CSS!