tidy-ext 0.1.12 → 0.1.13
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +79 -0
- data/Rakefile +4 -3
- data/VERSION +1 -1
- metadata +10 -9
- data/.gitignore +0 -7
data/README.md
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
Description
|
2
|
+
-----------
|
3
|
+
|
4
|
+
This is the HTML Tidy library built as a Ruby extension.
|
5
|
+
|
6
|
+
The original C source for Tidy can be found at
|
7
|
+
[http://tidy.sourceforge.net](http://tidy.sourceforge.net)
|
8
|
+
|
9
|
+
You can read more about Tidy at
|
10
|
+
[http://www.w3.org/People/Raggett/tidy/](http://www.w3.org/People/Raggett/tidy/)
|
11
|
+
|
12
|
+
This version of Ruby Tidy is compatible enough with the Ruby wrapper around the standalone tidy to be called by
|
13
|
+
[Tarantula](http://github.com/relevance/tarantula).
|
14
|
+
|
15
|
+
Usage
|
16
|
+
-----
|
17
|
+
|
18
|
+
<pre>
|
19
|
+
require 'tidy'
|
20
|
+
|
21
|
+
tidy = Tidy.open({:show_warnings => true}) do |tidy|
|
22
|
+
xml = tidy.clean("<html><body>String</body></html>")
|
23
|
+
end
|
24
|
+
</pre>
|
25
|
+
|
26
|
+
When using cucumber to write tests, it might be useful to copy features/step_definitions/tidy_steps.rb into your project's step definitions.
|
27
|
+
|
28
|
+
<pre>
|
29
|
+
require 'tidy'
|
30
|
+
|
31
|
+
Given /^(.+) is tidy$/ do |page_name|
|
32
|
+
|
33
|
+
visit path_to(page_name)
|
34
|
+
tidy = Tidy.open({:show_warnings => true}) do |tidy|
|
35
|
+
out = tidy.clean(response.body)
|
36
|
+
end
|
37
|
+
|
38
|
+
tidy.errors.scan(/(\d+) warnings?, (\d+) errors? were found!/) do |w,e|
|
39
|
+
warnings = w.to_i
|
40
|
+
errors = e.to_i
|
41
|
+
unless warnings == 0 && errors == 0
|
42
|
+
raise tidy.errors
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
</pre>
|
47
|
+
|
48
|
+
This allows you to write a cucumber feature like
|
49
|
+
|
50
|
+
<pre>
|
51
|
+
Scenario: visit the login page
|
52
|
+
|
53
|
+
Given the login page is tidy
|
54
|
+
|
55
|
+
And I am on the login page
|
56
|
+
And I fill in "email" with "blah"
|
57
|
+
And I fill in "password" with "blah"
|
58
|
+
And I press "Log in"
|
59
|
+
</pre>
|
60
|
+
|
61
|
+
If you want to run Tarantula on your Rails application, you may want to create a rake task lib/tasks/tarantula.rake that looks like:
|
62
|
+
|
63
|
+
<pre>
|
64
|
+
ENV["RAILS_ENV"] = "test" # so that rake tarantula:test always runs in your test env
|
65
|
+
ENV["TIDY_PATH"] = "tidy" # Tarantula will not load Tidy if this is not set
|
66
|
+
|
67
|
+
load File.join(RAILS_ROOT, Dir["vendor/gems/tarantula-*/tasks/*.rake"])
|
68
|
+
</pre>
|
69
|
+
|
70
|
+
Installing
|
71
|
+
----------
|
72
|
+
|
73
|
+
Using http://rubygems.org:
|
74
|
+
|
75
|
+
<pre>
|
76
|
+
$ [sudo] gem install tidy-ext
|
77
|
+
</pre>
|
78
|
+
|
79
|
+
|
data/Rakefile
CHANGED
@@ -5,10 +5,11 @@ begin
|
|
5
5
|
require 'jeweler'
|
6
6
|
Jeweler::Tasks.new do |gem|
|
7
7
|
gem.name = "tidy-ext"
|
8
|
-
gem.summary = "W3C HTML Tidy library implemented as a Ruby extension."
|
8
|
+
gem.summary = "W3C HTML Tidy library implemented as a Ruby native extension."
|
9
9
|
gem.description = "Tidy up web pages."
|
10
10
|
gem.email = "carl.douglas@gmail.com"
|
11
11
|
gem.homepage = "http://github.com/carld/tidy"
|
12
|
+
gem.rubyforge_project = "tidy-ext"
|
12
13
|
gem.authors = ["A. Carl Douglas"]
|
13
14
|
gem.extensions = FileList["ext/**/extconf.rb"]
|
14
15
|
end
|
@@ -42,7 +43,7 @@ rescue LoadError
|
|
42
43
|
puts "RSpec (or a dependency) not available. Install it with: gem install rspec"
|
43
44
|
end
|
44
45
|
|
45
|
-
require '
|
46
|
+
require 'rdoc/task'
|
46
47
|
Rake::RDocTask.new do |rdoc|
|
47
48
|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
49
|
|
@@ -79,7 +80,7 @@ namespace :gcov do
|
|
79
80
|
end
|
80
81
|
|
81
82
|
desc "Clean, compile with gcc coverage and run specs"
|
82
|
-
task :all
|
83
|
+
task :all => ["clean", :compile, :spec] do |t|
|
83
84
|
end
|
84
85
|
|
85
86
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.13
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tidy-ext
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 13
|
10
|
+
version: 0.1.13
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- A. Carl Douglas
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-10-21 00:00:00 +13:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -27,9 +27,10 @@ extensions:
|
|
27
27
|
- ext/tidy/extconf.rb
|
28
28
|
extra_rdoc_files:
|
29
29
|
- LICENSE
|
30
|
+
- README.md
|
30
31
|
files:
|
31
|
-
- .gitignore
|
32
32
|
- LICENSE
|
33
|
+
- README.md
|
33
34
|
- Rakefile
|
34
35
|
- VERSION
|
35
36
|
- ext/tidy/access.c
|
@@ -97,8 +98,8 @@ homepage: http://github.com/carld/tidy
|
|
97
98
|
licenses: []
|
98
99
|
|
99
100
|
post_install_message:
|
100
|
-
rdoc_options:
|
101
|
-
|
101
|
+
rdoc_options: []
|
102
|
+
|
102
103
|
require_paths:
|
103
104
|
- lib
|
104
105
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -121,10 +122,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
122
|
version: "0"
|
122
123
|
requirements: []
|
123
124
|
|
124
|
-
rubyforge_project:
|
125
|
+
rubyforge_project: tidy-ext
|
125
126
|
rubygems_version: 1.3.7
|
126
127
|
signing_key:
|
127
128
|
specification_version: 3
|
128
|
-
summary: W3C HTML Tidy library implemented as a Ruby extension.
|
129
|
+
summary: W3C HTML Tidy library implemented as a Ruby native extension.
|
129
130
|
test_files: []
|
130
131
|
|