C0 code coverage information

Generated on Tue Dec 04 22:06:27 -0500 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
app/models/ingredient.rb 77 48
100.0% 
100.0% 
 1 #####
 2 #
 3 # Copyright 2007 Chris Strom, Robin Strom
 4 #
 5 # This file is part of EEE Code.
 6 #
 7 # EEE Code is free software: you can redistribute it and/or modify
 8 # it under the terms of the GNU General Public License as published by
 9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
11 #
12 # EEE Code is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with EEE Code.  If not, see <http://www.gnu.org/licenses/>.
19 #
20 class Ingredient < ActiveRecord::Base
21   has_many :preparations
22   has_many :recipes, :through => :preparations
23 
24   validates_uniqueness_of :name, :scope => [:kind]
25   validates_uniqueness_of :kind, :scope => [:name], :allow_nil => true
26 
27   COMMON_INGREDIENT_NAMES =
28     [
29      'butter',
30      'cheese',
31      'chicken',
32      'flour',
33      'garlic',
34      'milk',
35      'mushrooms',
36      'oil',
37      'olive oil',
38      'onion',
39      'onions',
40      'parsley',
41      'pasta',
42      'salt',
43      'salt & pepper',
44      'tomatoes',
45      'water'
46     ]
47 
48   def self.sorted_names
49     Ingredient.find(:all, :select => 'DISTINCT name').sort_by{ |i| i.pretty_name }.map(&:name)
50   end
51 
52   def self.common_names
53     COMMON_INGREDIENT_NAMES
54   end
55 
56   def self.common_ingredients
57     self.find(:all, :conditions => ["name in (?)", COMMON_INGREDIENT_NAMES])
58   end
59 
60   def self.names
61     Ingredient.find(:all, :select => 'DISTINCT name').map(&:name)
62   end
63 
64   def self.recipes_by_name(name)
65     Ingredient.find(:all, :conditions => { :name => name }).map(&:recipes).flatten
66   end
67 
68   def pretty_name
69     name.sub(/\[recipe:\d{4}\/\d\d\/\d\d\/\w+ ([^\]]+)\]/ , "\\1").downcase
70   end
71 
72   def full_name
73     kind.blank? ? name : name + ", " + kind
74   end
75 
76   alias_method :to_s, :full_name
77 end

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

Valid XHTML 1.0! Valid CSS!