Class: Concordion::CSSDecorator
- Inherits:
-
Object
- Object
- Concordion::CSSDecorator
- Defined in:
- lib/concordion/css_decorator.rb
Instance Method Summary collapse
- #add_concordion_css_link(root, html, type) ⇒ Object
- #add_css_file_to_output_dir(writer, type) ⇒ Object
- #append_to_head(html, s) ⇒ Object
- #css ⇒ Object
- #css_filename ⇒ Object
- #decorate_tag(rv, tag, cpr) ⇒ Object
- #inline_css(html) ⇒ Object
- #link_to_css(html) ⇒ Object
Instance Method Details
#add_concordion_css_link(root, html, type) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/concordion/css_decorator.rb', line 7 def add_concordion_css_link(root, html, type) if html.at("head").nil? root.search("html").prepend('<head></head>') end if type == :link link_to_css(html) else inline_css(html) end end |
#add_css_file_to_output_dir(writer, type) ⇒ Object
38 39 40 41 42 |
# File 'lib/concordion/css_decorator.rb', line 38 def add_css_file_to_output_dir(writer, type) if !writer.output_file_exists?(css_filename) && type == :link writer.calculate_filename_and_overwrite(css, css_filename) end end |
#append_to_head(html, s) ⇒ Object
18 19 20 |
# File 'lib/concordion/css_decorator.rb', line 18 def append_to_head(html, s) html.search("head").append(s) end |
#css ⇒ Object
30 31 32 |
# File 'lib/concordion/css_decorator.rb', line 30 def css Concordion::CSS.css_string end |
#css_filename ⇒ Object
34 35 36 |
# File 'lib/concordion/css_decorator.rb', line 34 def css_filename Concordion::CSS.css_filename end |
#decorate_tag(rv, tag, cpr) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/concordion/css_decorator.rb', line 44 def decorate_tag(rv, tag, cpr) context = tag.to_html expected = tag.inner_html xpath = tag.xpath if rv[:result] tag[:class] = 'concordion_success' return nil end tag[:class] = 'concordion_failure' cpr.attribute_error(rv[:actual], rv[:expected]) Concordion::ErrorCondition.new(expected, rv[:actual], xpath, context, cpr.is_assert_true_command?) end |
#inline_css(html) ⇒ Object
26 27 28 |
# File 'lib/concordion/css_decorator.rb', line 26 def inline_css(html) append_to_head(html, "<style type='text/css'>#{css}</style>") end |
#link_to_css(html) ⇒ Object
21 22 23 |
# File 'lib/concordion/css_decorator.rb', line 21 def link_to_css(html) append_to_head(html, "<link rel='stylesheet' type='text/css' href='#{css_filename}' />") end |