tiegz-kadoku 0.1

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/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008 Tieg Zaharia
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
File without changes
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/testtask'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ desc 'Run unit tests.'
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << 'lib'
11
+ t.pattern = 'test/*_test.rb'
12
+ t.verbose = true
13
+ end
data/TODO ADDED
@@ -0,0 +1,8 @@
1
+ * tests
2
+ * compare to original source to make sure nothing is omitted
3
+ * edge cases:
4
+ * Javascript newlines... preserve in case there are no semi-colons?
5
+ * pre, block, etc... preserve newlines too?
6
+ * test the after_filter
7
+ * add a helper for Rack-based apps too
8
+ * seems to break on html docs without an xml decl. or doctype?
data/kadoku.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "kadoku"
3
+ s.version = "0.1"
4
+ s.date = "2008-12-17"
5
+ s.summary = "Uses Hpricot to clean up your unreadable HTML (ie ERB-generated html) [use with caution]"
6
+ s.email = "tieg.zaharia+kadoku@gmail.com"
7
+ s.homepage = "http://github.com/tiegz/kadoku"
8
+ s.description = "Kadoku is a Ruby library that uses Hpricot to clean up your unreadable HTML (ie ERB-generated html) [use with caution]"
9
+ s.has_rdoc = true
10
+ s.authors = ["Tieg Zaharia"]
11
+ s.files = ["kadoku.gemspec",
12
+ "MIT-LICENSE",
13
+ "Rakefile",
14
+ "README",
15
+ "TODO",
16
+ "lib/kadoku/kadoku.rb",
17
+ "lib/kadoku/kadoku/markup.rb",
18
+ "lib/kadoku/kadoku/markup_after_filter.rb"]
19
+ s.test_files = ["test/test_helper.rb",
20
+ "test/kadoku_markup_test.rb"]
21
+ s.rdoc_options = ["--main", "README"]
22
+ s.extra_rdoc_files = ["README", "MIT-LICENSE", "TODO"]
23
+ s.add_dependency("hpricot", ["> 0.6.164"])
24
+ end
@@ -0,0 +1,78 @@
1
+ require(File.join(File.dirname(__FILE__), 'test_helper'))
2
+
3
+ class KadokuMarkupTest < Test::Unit::TestCase
4
+ def setup
5
+ @bad_html = %Q!
6
+ <html>
7
+ <HEAD> <title>My page</tiTLE></HEAD>
8
+ <body >
9
+ <h1> WOAH WHAT'S HAPPENING <span>I DON'T KNOW</span>
10
+ </h1>
11
+
12
+ <p>Here, I'll explain. </p>
13
+ </body>
14
+
15
+ </html>
16
+ !
17
+ @good_html = %Q!
18
+ <html>
19
+ \t<head>
20
+ \t\t<title>
21
+ \t\t\tMy page
22
+ \t\t</title>
23
+ \t</head>
24
+ \t<body>
25
+ \t\t<h1>
26
+ \t\t\t WOAH WHAT'S HAPPENING
27
+ \t\t\t<span>
28
+ \t\t\t\tI DON'T KNOW
29
+ \t\t\t</span>
30
+ \t\t</h1>
31
+ \t\t<p>
32
+ \t\t\tHere, I'll explain.
33
+ \t\t</p>
34
+ \t</body>
35
+ </html>!
36
+ @good_html_with_asterisk_indentation = %Q!
37
+ <html>
38
+ *<head>
39
+ **<title>
40
+ ***My page
41
+ **</title>
42
+ *</head>
43
+ *<body>
44
+ **<h1>
45
+ *** WOAH WHAT'S HAPPENING
46
+ ***<span>
47
+ ****I DON'T KNOW
48
+ ***</span>
49
+ **</h1>
50
+ **<p>
51
+ ***Here, I'll explain.
52
+ **</p>
53
+ *</body>
54
+ </html>!
55
+ end
56
+
57
+ def test_should_instantiate_new_markup
58
+ markup = Kadoku::Markup.new(@bad_html)
59
+ assert markup.is_a?(Kadoku::Markup)
60
+ assert_not_nil markup.hpricot
61
+ assert markup.hpricot.is_a?(Hpricot::Doc)
62
+ end
63
+
64
+ def test_to_html_should_return_hpricots_to_html
65
+ markup = Kadoku::Markup.new(@bad_html)
66
+ assert_equal markup.to_html, markup.hpricot.to_html
67
+ end
68
+
69
+ def test_should_clean_basic_markup
70
+ markup = Kadoku::Markup.new(@bad_html)
71
+ assert_equal @good_html.strip, markup.to_clean_html.strip
72
+ end
73
+
74
+ def test_should_clean_basic_markup_with_asterisks_instead_of_tabs
75
+ markup = Kadoku::Markup.new(@bad_html, :clean_indent => "*")
76
+ assert_equal @good_html_with_asterisk_indentation.strip, markup.to_clean_html.strip
77
+ end
78
+ end
@@ -0,0 +1,6 @@
1
+ $: << File.join(File.dirname(__FILE__), '..', 'lib')
2
+ $: << File.join(File.dirname(__FILE__))
3
+
4
+ require 'rubygems'
5
+ require 'test/unit'
6
+ require 'kadoku'
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tiegz-kadoku
3
+ version: !ruby/object:Gem::Version
4
+ version: "0.1"
5
+ platform: ruby
6
+ authors:
7
+ - Tieg Zaharia
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-12-17 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: hpricot
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">"
21
+ - !ruby/object:Gem::Version
22
+ version: 0.6.164
23
+ version:
24
+ description: Kadoku is a Ruby library that uses Hpricot to clean up your unreadable HTML (ie ERB-generated html) [use with caution]
25
+ email: tieg.zaharia+kadoku@gmail.com
26
+ executables: []
27
+
28
+ extensions: []
29
+
30
+ extra_rdoc_files:
31
+ - README
32
+ - MIT-LICENSE
33
+ - TODO
34
+ files:
35
+ - kadoku.gemspec
36
+ - MIT-LICENSE
37
+ - Rakefile
38
+ - README
39
+ - TODO
40
+ - lib/kadoku/kadoku.rb
41
+ - lib/kadoku/kadoku/markup.rb
42
+ - lib/kadoku/kadoku/markup_after_filter.rb
43
+ has_rdoc: true
44
+ homepage: http://github.com/tiegz/kadoku
45
+ post_install_message:
46
+ rdoc_options:
47
+ - --main
48
+ - README
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "0"
56
+ version:
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: "0"
62
+ version:
63
+ requirements: []
64
+
65
+ rubyforge_project:
66
+ rubygems_version: 1.2.0
67
+ signing_key:
68
+ specification_version: 2
69
+ summary: Uses Hpricot to clean up your unreadable HTML (ie ERB-generated html) [use with caution]
70
+ test_files:
71
+ - test/test_helper.rb
72
+ - test/kadoku_markup_test.rb