validate-website 0.4.0 → 0.4.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/Rakefile +1 -1
- data/bin/validate-website +3 -0
- data/lib/validate_website.rb +6 -5
- data/spec/data/html5.html +46 -0
- data/spec/data/xhtml1-strict.html +19 -0
- data/spec/validate_website_spec.rb +53 -0
- data/spec/validator_spec.rb +34 -0
- metadata +8 -5
- data/spec/css_spec.rb +0 -53
data/Rakefile
CHANGED
data/bin/validate-website
CHANGED
@@ -13,7 +13,10 @@ options = validate_website.options
|
|
13
13
|
exit_code = validate_website.crawl options[:site],
|
14
14
|
:markup_validation => options[:markup_validation],
|
15
15
|
:user_agent => options[:useragent],
|
16
|
+
:exclude => options[:exclude],
|
17
|
+
:file => options[:file],
|
16
18
|
:authorization => options[:auth],
|
19
|
+
:not_found => options[:not_found],
|
17
20
|
:cookies => options[:cookies],
|
18
21
|
:accept_cookies => options[:accept_cookies],
|
19
22
|
:verbose => options[:debug],
|
data/lib/validate_website.rb
CHANGED
@@ -12,8 +12,8 @@ class ValidateWebsite
|
|
12
12
|
|
13
13
|
def initialize(args=[])
|
14
14
|
@options = {
|
15
|
-
:markup_validation => true,
|
16
15
|
:site => 'http://localhost:3000/',
|
16
|
+
:markup_validation => true,
|
17
17
|
:useragent => Anemone::Core::DEFAULT_OPTS[:user_agent],
|
18
18
|
:exclude => nil,
|
19
19
|
:file => nil,
|
@@ -78,10 +78,6 @@ class ValidateWebsite
|
|
78
78
|
return abs if abs && page.in_domain?(abs)
|
79
79
|
end
|
80
80
|
|
81
|
-
def to_file(msg)
|
82
|
-
open(options[:file], 'a').write("#{msg}\n") if options[:file]
|
83
|
-
end
|
84
|
-
|
85
81
|
def crawl(site, opts={})
|
86
82
|
exit_code = 0
|
87
83
|
|
@@ -140,4 +136,9 @@ class ValidateWebsite
|
|
140
136
|
end
|
141
137
|
exit_code
|
142
138
|
end
|
139
|
+
|
140
|
+
private
|
141
|
+
def to_file(msg)
|
142
|
+
open(options[:file], 'a').write("#{msg}\n") if options[:file]
|
143
|
+
end
|
143
144
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8" />
|
5
|
+
<title>title</title>
|
6
|
+
<!-- meta -->
|
7
|
+
<meta name="description" content="" />
|
8
|
+
<meta name="keywords" content="" />
|
9
|
+
<meta name="author" content="" />
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
<header>
|
13
|
+
<nav>
|
14
|
+
<ul>
|
15
|
+
<li><a href="/my-url1" title="title">my url</a></li>
|
16
|
+
<li><a href="/my-url2" title="title">my url</a></li>
|
17
|
+
<li><a href="/my-url3" title="title">my url</a></li>
|
18
|
+
</ul>
|
19
|
+
</nav>
|
20
|
+
</header>
|
21
|
+
|
22
|
+
<div>
|
23
|
+
<article>
|
24
|
+
<h1>article title</h1>
|
25
|
+
<p>texte de my article</p>
|
26
|
+
<section>
|
27
|
+
<h2>article subtitle</h2>
|
28
|
+
<p>text</p>
|
29
|
+
<figure>
|
30
|
+
<a href="/my-url4"><img src="image.png" alt="my image"></a>
|
31
|
+
</figure>
|
32
|
+
</section>
|
33
|
+
</article>
|
34
|
+
</div>
|
35
|
+
|
36
|
+
<footer>
|
37
|
+
<nav>
|
38
|
+
<ul>
|
39
|
+
<li><a href="/my-url5" title="title">my url</a></li>
|
40
|
+
<li><a href="/my-url6" title="title">my url</a></li>
|
41
|
+
<li><a href="/my-url7" title="title">my url</a></li>
|
42
|
+
</ul>
|
43
|
+
</nav>
|
44
|
+
</footer>
|
45
|
+
</body>
|
46
|
+
</html>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
3
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml">
|
5
|
+
<head>
|
6
|
+
<title>title</title>
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<h1>Title 1</h1>
|
10
|
+
<p>Paragraphe.</p>
|
11
|
+
|
12
|
+
<h2>Title 2</h2>
|
13
|
+
<ul>
|
14
|
+
<li><a href="/my-url1" title="title">my url</a></li>
|
15
|
+
<li><a href="/my-url2" title="title">my url</a></li>
|
16
|
+
<li><a href="/my-url1" title="title">my url</a></li>
|
17
|
+
</ul>
|
18
|
+
</body>
|
19
|
+
</html>
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe ValidateWebsite do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
FakeWeb.clean_registry
|
7
|
+
end
|
8
|
+
|
9
|
+
context('html') do
|
10
|
+
it "should extract url" do
|
11
|
+
name = 'xhtml1-strict'
|
12
|
+
file = File.join('spec', 'data', "#{name}.html")
|
13
|
+
page = FakePage.new(name,
|
14
|
+
:body => open(file).read,
|
15
|
+
:content_type => 'text/html')
|
16
|
+
validate_website = ValidateWebsite.new
|
17
|
+
validate_website.crawl(page.url)
|
18
|
+
validate_website.anemone.should have(3).pages
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context('css') do
|
23
|
+
it "should crawl css and extract url" do
|
24
|
+
page = FakePage.new('test.css',
|
25
|
+
:body => ".test {background-image: url(pouet);}
|
26
|
+
.tests {background-image: url(/image/pouet.png)}
|
27
|
+
.tests {background-image: url(/image/pouet_42.png)}
|
28
|
+
.tests {background-image: url(/image/pouet)}",
|
29
|
+
:content_type => 'text/css')
|
30
|
+
validate_website = ValidateWebsite.new
|
31
|
+
validate_website.crawl(page.url)
|
32
|
+
validate_website.anemone.should have(5).pages
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should extract url with single quote" do
|
36
|
+
page = FakePage.new('test.css',
|
37
|
+
:body => ".test {background-image: url('pouet');}",
|
38
|
+
:content_type => 'text/css')
|
39
|
+
validate_website = ValidateWebsite.new
|
40
|
+
validate_website.crawl(page.url)
|
41
|
+
validate_website.anemone.should have(2).pages
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should extract url with double quote" do
|
45
|
+
page = FakePage.new('test.css',
|
46
|
+
:body => ".test {background-image: url(\"pouet\");}",
|
47
|
+
:content_type => 'text/css')
|
48
|
+
validate_website = ValidateWebsite.new
|
49
|
+
validate_website.crawl(page.url)
|
50
|
+
validate_website.anemone.should have(2).pages
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe Validator do
|
4
|
+
before(:each) do
|
5
|
+
FakeWeb.clean_registry
|
6
|
+
@http = Anemone::HTTP.new
|
7
|
+
end
|
8
|
+
|
9
|
+
it "xhtml1-strict should be valid" do
|
10
|
+
name = 'xhtml1-strict'
|
11
|
+
dtd_uri = 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'
|
12
|
+
file = File.join('spec', 'data', "#{name}.html")
|
13
|
+
page = FakePage.new(name,
|
14
|
+
:body => open(file).read,
|
15
|
+
:content_type => 'text/html')
|
16
|
+
@xhtml1_page = @http.fetch_page(page.url)
|
17
|
+
validator = Validator.new(@xhtml1_page)
|
18
|
+
validator.dtd.system_id.should == dtd_uri
|
19
|
+
validator.namespace.should == name
|
20
|
+
validator.should be_valid
|
21
|
+
end
|
22
|
+
|
23
|
+
it "html5 should be valid" do
|
24
|
+
pending("need to work on html5")
|
25
|
+
name = 'html5'
|
26
|
+
file = File.join('spec', 'data', "#{name}.html")
|
27
|
+
page = FakePage.new(name,
|
28
|
+
:body => open(file).read,
|
29
|
+
:content_type => 'text/html')
|
30
|
+
@html5_page = @http.fetch_page(page.url)
|
31
|
+
validator = Validator.new(@html5_page)
|
32
|
+
validator.should be_valid
|
33
|
+
end
|
34
|
+
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: validate-website
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 13
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 4
|
9
|
-
-
|
10
|
-
version: 0.4.
|
9
|
+
- 1
|
10
|
+
version: 0.4.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Laurent Arnoud
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-10-24 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -186,9 +186,12 @@ files:
|
|
186
186
|
- lib/xhtml/xhtml-ruby-1.xsd
|
187
187
|
- lib/validate_website.rb
|
188
188
|
- bin/validate-website
|
189
|
+
- spec/validator_spec.rb
|
189
190
|
- spec/spec_helper.rb
|
190
|
-
- spec/
|
191
|
+
- spec/data/html5.html
|
192
|
+
- spec/data/xhtml1-strict.html
|
191
193
|
- spec/fakeweb_helper.rb
|
194
|
+
- spec/validate_website_spec.rb
|
192
195
|
has_rdoc: true
|
193
196
|
homepage: http://github.com/spk/validate-website
|
194
197
|
licenses: []
|
data/spec/css_spec.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
|
3
|
-
describe ValidateWebsite do
|
4
|
-
|
5
|
-
before(:each) do
|
6
|
-
FakeWeb.clean_registry
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should crawl css and extract url" do
|
10
|
-
pages = []
|
11
|
-
pages << FakePage.new('test.css',
|
12
|
-
:body => ".test {background-image: url(pouet);}
|
13
|
-
.tests {background-image: url(/image/pouet.png)}
|
14
|
-
.tests {background-image: url(/image/pouet_42.png)}
|
15
|
-
.tests {background-image: url(/image/pouet)}",
|
16
|
-
:content_type => 'text/css')
|
17
|
-
pages << FakePage.new('pouet',
|
18
|
-
:content_type => 'image/png')
|
19
|
-
pages << FakePage.new('image/pouet',
|
20
|
-
:content_type => 'image/png')
|
21
|
-
pages << FakePage.new('image/pouet.png',
|
22
|
-
:content_type => 'image/png')
|
23
|
-
pages << FakePage.new('image/pouet_42.png',
|
24
|
-
:content_type => 'image/png')
|
25
|
-
validate_website = ValidateWebsite.new
|
26
|
-
validate_website.crawl(pages[0].url)
|
27
|
-
validate_website.anemone.should have(5).pages
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should extract url with single quote" do
|
31
|
-
pages = []
|
32
|
-
pages << FakePage.new('test.css',
|
33
|
-
:body => ".test {background-image: url('pouet');}",
|
34
|
-
:content_type => 'text/css')
|
35
|
-
pages << FakePage.new('pouet',
|
36
|
-
:content_type => 'image/png')
|
37
|
-
validate_website = ValidateWebsite.new
|
38
|
-
validate_website.crawl(pages[0].url)
|
39
|
-
validate_website.anemone.should have(2).pages
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should extract url with double quote" do
|
43
|
-
pages = []
|
44
|
-
pages << FakePage.new('test.css',
|
45
|
-
:body => ".test {background-image: url(\"pouet\");}",
|
46
|
-
:content_type => 'text/css')
|
47
|
-
pages << FakePage.new('pouet',
|
48
|
-
:content_type => 'image/png')
|
49
|
-
validate_website = ValidateWebsite.new
|
50
|
-
validate_website.crawl(pages[0].url)
|
51
|
-
validate_website.anemone.should have(2).pages
|
52
|
-
end
|
53
|
-
end
|