C0 code coverage information
Generated on Tue Jun 09 17:50:06 +0900 2009 with
rcov 0.8.1.2
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.
1 # -*- coding: utf-8 -*-
2 require 'nested_ajax'
3 4 module NestedAjax 5 module RenderExt 6 def self.included(mod) 7 mod.extend(ClassMethod) 8 mod.module_eval do 9 alias_method_chain :render,
:nested_ajax 10 end
11 end 12 13 private 14 15
def auto_complete_html(name_and_ids, options = {}) 16 options = { 17 :outer_tag => :ul, 18 :inner_tag => :li, 19 }.update(options || {})
20 outer_tag =
options[:outer_tag] 21
inner_tag = options[:inner_tag] 22 outer_tag = [outer_tag, {}] unless
outer_tag.is_a?(Array) 23
inner_tag = [inner_tag, {}] unless inner_tag.is_a?(Array) 24 timestamp = Time.now.to_i
25 inner_tags =
name_and_ids.map do |(name, id)| 26 response.template.content_tag(inner_tag.first,
27
response.template.sanitize(name) + 28 response.template.content_tag(:span, 29 response.template.sanitize(id.to_s),
30 :style =>
'display:none;'), 31
inner_tag.last) 32 end
33
response.template.content_tag(outer_tag.first, inner_tags.join,
outer_tag.last) 34 end
35 36 37 def render_if_xhr(*args, &block) 38 render(*args, &block) if
request.xhr? 39
request.xhr? 40 end
41 42 protected 43 44 DEFAULT_NESTED_AJAX_LAYOUT = 'nested_ajax' 45 46 def render_with_nested_ajax(options = nil,
extra_options = {}, &block) 47 if request.xhr? 48 flash.discard 49 if (options.nil? || options.is_a?(Hash)) 50 layout =
self.class.read_inheritable_attribute(:ajax_layout) 51 begin 52 layout ||=
view_paths.find_template("layouts/#{DEFAULT_NESTED_AJAX_LAYOUT}",
default_template_format) 53 rescue Exception => e 54 # rescue
ActionView::MissingTemplate 55 #
と書かないのはrcovが無視しちゃうためです。 56 57 #
find_templateは見つからなかったときにActionView::MissingTemplate
外をraiseします。 58 #
ここでは見つかったら使うだけなので、無視します。
59 raise e unless
e.is_a?(ActionView::MissingTemplate) 60 end 61 layout ||= false 62 options ||= {} 63 options[:layout] = layout 64 end 65 end 66 render_without_nested_ajax(options,
extra_options, &block) 67 end 68 69
module ClassMethod 70 def
ajax_layout(template_name) 71 write_inheritable_attribute(:ajax_layout,
template_name) 72 end
73 end 74 75 end 76 end
Generated using the rcov
code coverage analysis tool for Ruby version 0.8.1.2.