C0 code coverage information

Generated on Fri Aug 25 11:26:24 PDT 2006 with rcov 0.7.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/helpers/application_helper.rb 287 240
23.7% 
15.0% 
  1 # Methods added to this helper will be available to all templates in the application.
  2 module ApplicationHelper
  3     include Localization
  4     
  5     def class_active(linkname)
  6       if(@controller.controller_name == linkname) then
  7         return "id='current'"
  8       end
  9     end
 10 
 11     def data_image_tag(image_object, options = nil)
 12         build_image_tag('image', image_object, options)
 13     end
 14 
 15     def data_big_thumb_tag(image_object, options = nil)
 16         build_image_tag('big_thumb', image_object, options)
 17     end
 18 
 19     def data_small_thumb_tag(image_object, options = nil)
 20         build_image_tag('small_thumb', image_object, options)
 21     end
 22 
 23     def data_tiny_thumb_tag(image_object, options = nil)
 24         build_image_tag('tiny_thumb', image_object, options)
 25     end
 26 
 27     def build_image_tag(tag_type, image_object, options = nil)
 28         if image_object
 29             tag_opts = { :src => "/images/#{tag_type}/#{image_object[:id]}.#{image_object[:original_filename]}",
 30             :alt => image_object[:title],
 31             :title => image_object[:title] }
 32             if options
 33                 tag_opts.merge! options
 34             end
 35             tag("img", tag_opts)
 36         else
 37             ""
 38         end
 39     end
 40 
 41     def insound_link(artist_name) 
 42         url = "http://search.insound.com/search/results4.jsp?query=#{artist_name.sub(' ', '%20')}&from=47597"
 43         "<a href=\"#{ url }\" onclick=\"window.open(this.href); return false;\" onkeypress=\"window.open(this.href); return false;\">#{
 44         image_tag('buy_insound.gif', :title => 'Buy it from Insound', :alt => 'Buy it from Insound')}</a>"
 45     end
 46     
 47     def ampcamp_link(artist_name) 
 48         url = "http://www.ampcamp.com/basic_search_result.php?ref=2&keywords=#{artist_name.sub(' ', '%20')}&select=2"
 49         "<a href=\"#{ url }\" onclick=\"window.open(this.href); return false;\" onkeypress=\"window.open(this.href); return false;\">#{
 50         image_tag('buy_ampcamp.gif', :title => 'Buy it from Amp Camp', :alt => 'Buy it from Amp Camp')}</a>"
 51     end
 52 
 53     def emusic_link(artist_name) 
 54         url = "http://www.emusic.com/search.html?mode=a&QT=#{artist_name.sub(' ', '%20')}&fref=150242"
 55         "<a href=\"#{ url }\" onclick=\"window.open(this.href); return false;\" onkeypress=\"window.open(this.href); return false;\">#{
 56         image_tag('download_emusic.gif', :title => 'Download it from Emusic', :alt => 'Download it from Emusic')}</a>"
 57     end
 58 
 59     def relation_link(rel)
 60         rel_type = nil
 61         action = nil
 62         title = nil
 63         
 64         case rel.class.to_s
 65         when 'RecordReview'
 66             rel_type = "Review"
 67             action = "record_review"
 68             title = "#{h(rel.artist)}: #{h(rel.title)}"
 69         when 'News', 'NewsBlurb'
 70             rel_type = "News"
 71             action = "news"
 72             title = sanitize rel.title
 73         when 'TrackReview'
 74             rel_type = "Track Review"
 75             action = "track_review"
 76             title = "#{h(rel.artist)}: \"#{sanitize(rel.title)}\""
 77         when 'Download'
 78             rel_type ="Download"
 79             action = "download"
 80             title = "<strong>#{rel.download_type.type_name if rel.download_type}</strong>: #{h(rel.artist)}: #{sanitize(rel.title)}"
 81         when 'Feature'
 82             rel_type = rel.sub_category.short_title
 83             action = "feature"
 84             title = sanitize rel.full_title
 85         end
 86         "<a href=\"#{ url_for(:controller => 'article', :action => action, :id => rel.id, :artist_title => rel)}\">Pitchfork #{rel_type}: #{title}</a>"
 87     end
 88     
 89     def article_link(link)
 90         "<a href=\"#{link.url}\" onclick=\"window.open(this.href); return false;\" onkeypress=\"window.open(this.href); return false;\">#{sanitize link.title}: #{h link.url}</a>"
 91     end
 92 
 93     def to_yes_no(value)
 94         if value != 0
 95             "Yes"
 96         else
 97             "No"
 98         end
 99     end
100 
101     def is_in_role?(role_id)
102         @session['user'] and @session['user'].role_id >= role_id
103     end
104 
105     @@DEFAULT_HEAD_OPTIONS = {
106         :notice => true,
107         :message => true,
108         :error => false
109         }.freeze
110 
111     # Abstraction to make views a little cleaner
112     def form_input(helper_method, field_name, options = {}, form_name = nil)
113         form_name = "user" if form_name.nil?
114         case helper_method.to_s
115         when 'hidden_field'
116             self.hidden_field(form_name, field_name, options)
117         when /^.*button$/
118             prompt = l(:"#{@controller.controller_name}_#{field_name}_button")
119             <<-EOL
120             #{self.send(helper_method, form_name, prompt, options)}
121             EOL
122         else
123             field = (
124                 case helper_method
125                 when :select
126                     self.send(helper_method, form_name, field_name, options.delete('values'), options)
127                 when :password_field
128                     options[:value] = ""
129                     self.send(helper_method, form_name, field_name, options)
130                 else
131                     self.send(helper_method, form_name, field_name, options)
132                 end)
133             lname = "#{form_name}_#{field_name}_form"
134             prompt = l(:"#{lname}")
135             if UserSystem::CONFIG[:two_column_input]
136                 <<-EOL
137                 <label>#{prompt}:</label>
138                 #{field}
139                 <br />
140                 EOL
141             else
142                 <<-EOL
143                 <label>#{prompt}:</label>
144                 #{field}
145                 <br />
146                 EOL
147             end
148         end
149     end
150 
151     def button_helper(name, options = {})
152         label = l(:"#{@controller.controller_name}_#{name}_button")
153         "#{self.send(:submit_tag, label, options)}"
154     end
155 
156     def link_helper(name, options = {})
157         raise ArgumentError if name.nil?
158         label = l(:"#{@controller.controller_name}_#{name}_link")
159         "#{self.send(:link_to, label, options)}"
160     end
161 
162     def title_helper
163         "#{@controller.controller_class_name} #{@controller.action_name}"
164     end
165 
166     def head_helper(options = {})
167         label = l(:"#{@controller.controller_name}_#{@controller.action_name}_head")
168         notice = message = error = nil
169         opts = @@DEFAULT_HEAD_OPTIONS.dup
170         opts.update(options.symbolize_keys)
171         s = "<h1>#{label}</h1>"
172         if @flash['notice'] and not opts[:notice].nil? and opts[:notice]
173             notice = "<div><p>#{@flash['notice']}</p></div>"
174             s = s + notice
175         end
176         if @flash['message'] and not opts[:message].nil? and opts[:message]
177             message = "<div id=\"ErrorExplanation\"><p>#{@flash['message']}</p></div>"
178             s = s + message
179         end
180         if not opts[:error].nil? and opts[:error]
181             error = error_messages_for('user')
182             if not error.nil?
183                 error = error + "<br/>"
184                 s = s + error
185             end
186         end
187         return s
188         <<-EOL
189         <h3>#{label}</h3>
190         #{notice}
191         #{message}
192         #{error}
193         EOL
194     end
195 
196     def message_helper(name)
197         l(:"#{@controller.controller_name}_#{name}_message")
198     end
199 
200     def start_form_tag_helper(options = {})
201         url = url_for(:action => "#{@controller.action_name}")
202         "#{self.send(:start_form_tag, url, options)}"
203     end
204 
205     def attributes(hash)
206         hash.keys.inject("") { |attrs, key| attrs + %{#{key}="#{h(hash[key])}" } }
207     end
208 
209     def read_only_field(form_name, field_name, html_options)
210         "<span #{attributes(html_options)}>#{instance_variable_get('@' + form_name)[field_name]}</span>"
211     end
212 
213     def submit_button(form_name, prompt, html_options)
214         %{<input name="submit" type="submit" value="#{prompt}" />}
215     end
216 
217     def changeable(user, field)
218         if user.new_record? or UserSystem::CONFIG[:changeable_fields].include?(field)
219             :text_field
220         else
221             :read_only_field
222         end
223     end
224     
225     def pager_nav(paginator, page_params = nil, options = {})
226         
227   # attempt to clean :keywords if they exist with gsub 
228   if !page_params.nil? and !page_params[:keywords].nil?
229     page_params[:keywords].to_s!
230     page_params[:keywords].gsub!("'","\'")
231   end
232   
233   pager = "<strong>Page</strong> "
234         page_window = paginator.current.window(3)
235         special_case = ":artist_title => @params[:artist_title], "
236 	page_window.to_a.each do |page| 
237             if page.number == paginator.current.number
238                 pager << "<strong>#{ page.number }</strong> "
239             else
240                 pager << eval("link_to(page.number, { :controller => @params[:controller], :action => @params[:action], :sub_action => @params[:sub_action], :id => @params[:id], #{special_case if params[:action] != 'news'}:page => ('page_' + page.number.to_s)#{", " << page_params if page_params} }.merge(options))") << " "
241             end
242             unless page.number == page_window.last.number
243                 pager << "| "
244             end
245         end
246         
247         # more_page_num = page_window.last.number
248         pager << "| " << eval("link_to('More...', { :controller => @params[:controller], :action => @params[:action], :sub_action => @params[:sub_action], :id => @params[:id], #{special_case if params[:action] != 'news'}:page => ('page_' + (page_window.last.number + 1).to_s)#{", " << page_params if page_params} }.merge(options))") << " " unless page_window.last.last?
249 
250 
251         pager << eval("link_to('&lt;Prev', { :controller => @params[:controller], :action => @params[:action], :sub_action => @params[:sub_action], :id => @params[:id], #{special_case if params[:action] != 'news'}:page => ('page_' + paginator.current.previous.number.to_s)#{", " << page_params if page_params} }.merge(options))") << " " if paginator.current.previous
252         pager << eval("link_to('Next&gt;', { :controller => @params[:controller], :action => @params[:action], :sub_action => @params[:sub_action], :id => @params[:id], #{special_case if params[:action] != 'news'}:page => ('page_' + paginator.current.next.number.to_s)#{", " << page_params if page_params} }.merge(options))") if paginator.current.next
253         pager
254     end
255     
256     def star_rating(rating)
257         star_string = ""
258         float_rating = rating.to_f
259         
260         float_rating.floor.times { star_string << image_tag('star.gif',{:title=>"star",:alt=>"star",:class=>"stars",:style=>"margin-right:0px;"}) }
261         (2 * ( float_rating - float_rating.floor )).to_i.times { star_string << image_tag('star-half.gif',{:title=>"half star",:alt=>"half star",:class=>"stars",:style=>"margin-right:0px;"}) }
262         star_string
263     end
264     
265     def sort_td_class_helper(param)
266       result = ' class="sortup"' if @params[:sort] == param
267       result = ' class="sortdown"' if @params[:sort] == param + "_reverse"
268       return result
269     end
270         
271     def sort_link_helper(text, param, criteria=nil, page=nil)
272       key = param
273       key += "_reverse" if params[:sort] == param
274       options = {
275           :params => { :sort => key, :criteria => criteria, :page => page }
276       }
277       html_options = {
278         :title => "Sort by this field",
279         :href => url_for(:action => 'list')
280       }
281       link_to(text, options, html_options)
282     end
283     
284     def clean_title(title)
285         title.delete("~")
286     end
287 end

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

Valid XHTML 1.0! Valid CSS!