C0 code coverage information

Generated on Thu Jun 07 11:33:59 -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
app/models/team.rb 183 155
33.3% 
23.2% 
  1 class Team < ActiveRecord::Base
  2 	belongs_to :school
  3 	belongs_to :bracket
  4 	belongs_to :tournament
  5 	has_many :players, :dependent => :destroy
  6 	has_many :team_results, :dependent => :destroy
  7 	has_and_belongs_to_many :games
  8 
  9 	def self.ranked(bracket=nil)
 10 		teams = Team.find(:all).select {|t| t.played_any_games? }
 11 		teams = teams.select{|b| b.bracket ==bracket} unless bracket.nil?
 12 		teams.sort! {|a,b|
 13 			if a.win_percentage == b.win_percentage
 14 				a.points <=> b.points
 15 			else
 16 				a.win_percentage <=> b.win_percentage
 17 			end
 18 		}
 19 		teams.reverse!
 20 	end
 21 
 22 	def self.rostered
 23 		#refactor more! add Team#rostered or something
 24 		self.find(:all).select{|t| t.players.size > 0}.sort_by{|t| t.name}
 25 	end
 26 
 27 	def self.unrostered
 28 		self.find(:all).reject{|t| t.players.size > 0}.sort_by{|t| t.name}
 29 	end
 30 
 31 	def games_played
 32 		team_results.size
 33 	end
 34 
 35 	def played_any_games?
 36 		games_played > 0
 37 	end
 38 
 39 	def points
 40 		points = 0
 41 		for round in team_results do
 42 			points += round.score
 43 		end
 44 		points
 45 	end
 46 
 47 	# This should include ties.
 48 	def win_points
 49 		(wins).to_f
 50 	end	
 51 
 52 	def wins
 53 		out = 0
 54 		for round in team_results do
 55 			if round.win
 56 				out += 1
 57 			end
 58 		end
 59 		out
 60 	end
 61 
 62 	def losses
 63 		out = 0
 64 		for round in team_results do
 65 			if not round.win and not round.tie
 66 				out += 1
 67 			end
 68 		end
 69 		out
 70 	end
 71 
 72 	def ties
 73 		out = 0
 74 		for round in team_results do
 75 			if round.tie
 76 				out += 1
 77 			end
 78 		end
 79 		out
 80 	end
 81 
 82 	def win_percentage
 83 		return win_points.to_f / games_played.to_f if played_any_games?
 84 		# This should be returned to returning nan or inf after 
 85 		# sorting is fixed
 86 		0.0
 87 	end
 88 
 89 	def tuh
 90 		out = 0
 91 		for round in team_results do
 92 			out += round.tuh
 93 		end
 94 		out
 95 	end
 96 
 97 	def powers
 98 		out = 0
 99 		for round in team_results do
100 			out += round.powers
101 		end
102 		out
103 	end
104 
105 	def tossups
106 		out = 0
107 		for round in team_results do
108 			out += round.tossups
109 		end
110 		out
111 	end
112 
113 	def negs
114 		out = 0
115 		for round in team_results do
116 			out += round.negs
117 		end
118 		out
119 	end
120 
121 	def points_per_game
122 		if games_played == 0
123 			return 0.0
124 		end
125 		points.to_f / games_played.to_f
126 	end
127 	def points_against
128 		out = 0
129 		for game in games do
130 			for result in game.team_results do
131 				if result.team != self
132 					out += result.score
133 				end
134 			end
135 		end
136 		out
137 	end
138 
139 	def points_against_per_game
140 		points_against.to_f / team_results.size.to_f
141 	end
142 
143 	def margin
144 		points_per_game - points_against_per_game
145 	end
146 
147 	def points_per_tuh
148 		points.to_f / tuh.to_f
149 	end
150 	
151 	def points_per_20h
152 		points_per_tuh * 20
153 	end
154 	
155 	def powers_per_neg
156 		if negs == 0
157 			return (0.0/0.0)
158 		else
159 			return powers.to_f / negs.to_f
160 		end
161 	end
162 
163 	def bonuses_heard
164 		out = 0
165 		for round in team_results do
166 			out += round.bonuses_heard
167 		end
168 		out
169 	end
170 
171 	def bonus_points
172 		out = 0
173 		for round in team_results do
174 			out += round.bonus_points
175 		end
176 		out
177 	end
178 
179 	def bonus_conversion
180 		return 0 if bonuses_heard == 0
181 		bonus_points.to_f / bonuses_heard.to_f
182 	end
183 end

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

Valid XHTML 1.0! Valid CSS!