zevarito-uglify_html 0.11 → 0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ version 0.12
2
+
3
+ * Pass an array with name elements to pass through
4
+
1
5
  version 0.11
2
6
 
3
7
  * Process UL and OL lists
data/lib/uglify_html.rb CHANGED
@@ -1,12 +1,16 @@
1
- require 'hpricot_ext'
1
+ require File.expand_path(File.dirname(__FILE__) + "/hpricot_ext.rb")
2
2
 
3
3
  class UglifyHtml
4
- def initialize(html)
4
+ def initialize(html, options = {})
5
5
  @doc = Hpricot html
6
+ options[:pass_through] ||= []
7
+ @options = options
6
8
  end
7
9
 
8
10
  def make_ugly
9
11
  (@doc/"*").each do |e|
12
+ next if @options[:pass_through].include? e.name
13
+
10
14
  case e.name
11
15
  when 'b', 'strong' then process_with_style(e, "font-weight", "bold")
12
16
  when 'i', 'em' then process_with_style(e, "font-style", "italic")
data/test/test_uglify.rb CHANGED
@@ -1,8 +1,19 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + "/test_helper")
2
2
 
3
3
  class UglifyHtmlTest < Test::Unit::TestCase
4
- def assert_renders_uglify(uglify, html)
5
- assert_equal uglify, UglifyHtml.new(html).make_ugly
4
+ def assert_renders_uglify(uglify, html, options ={})
5
+ assert_equal uglify, UglifyHtml.new(html, options).make_ugly
6
+ end
7
+
8
+ context "let pass through certain elements" do
9
+ test "pass strong tags, pass em tags" do
10
+ html = "<p>some <strong>bold</strong> text inside a paragraph</p>"
11
+ uglify = "<p>some <strong>bold</strong> text inside a paragraph</p>"
12
+ assert_renders_uglify uglify, html, {:pass_through => ['strong']}
13
+ html = "<p>some <em>bold</em> text inside a paragraph</p>"
14
+ uglify = "<p>some <em>bold</em> text inside a paragraph</p>"
15
+ assert_renders_uglify uglify, html, {:pass_through => ['em']}
16
+ end
6
17
  end
7
18
 
8
19
  context "convert common tags" do
data/uglify_html.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "uglify_html"
3
- s.version = "0.11"
3
+ s.version = "0.12"
4
4
  s.date = "2009-08-10"
5
5
 
6
6
  s.description = "Make ugly a Html document"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zevarito-uglify_html
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.11"
4
+ version: "0.12"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alvaro Gil