validate-website 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/bin/validate-website +4 -1
- data/lib/validate_website.rb +12 -12
- data/spec/spec_helper.rb +5 -4
- data/spec/validate_website_spec.rb +1 -1
- data/spec/validator_spec.rb +1 -1
- metadata +4 -4
data/Rakefile
CHANGED
data/bin/validate-website
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
lib_dir = File.join(File.dirname(__FILE__), '..', 'lib')
|
5
|
+
$:.unshift(File.expand_path(lib_dir))
|
3
6
|
|
4
7
|
developer_mode = false
|
5
8
|
developer_mode = true if __FILE__ == $0
|
data/lib/validate_website.rb
CHANGED
@@ -92,17 +92,6 @@ class ValidateWebsite
|
|
92
92
|
opts.parse!(args)
|
93
93
|
end
|
94
94
|
|
95
|
-
def get_url(page, elem, attrname)
|
96
|
-
u = elem.attributes[attrname] if elem.attributes[attrname]
|
97
|
-
return if u.nil?
|
98
|
-
begin
|
99
|
-
abs = page.to_absolute(URI(u))
|
100
|
-
rescue
|
101
|
-
abs = nil
|
102
|
-
end
|
103
|
-
return abs if abs && page.in_domain?(abs)
|
104
|
-
end
|
105
|
-
|
106
95
|
def crawl(site, opts={})
|
107
96
|
@anemone = Anemone.crawl(site, opts) do |anemone|
|
108
97
|
anemone.skip_links_like Regexp.new(opts[:exclude]) if opts[:exclude]
|
@@ -121,7 +110,7 @@ class ValidateWebsite
|
|
121
110
|
end
|
122
111
|
if p.content_type == 'text/css'
|
123
112
|
p.body.scan(/url\((['".\/\w-]+)\)/).each do |url|
|
124
|
-
url = url.
|
113
|
+
url = url.first.gsub("'", "").gsub('"', '')
|
125
114
|
abs = p.to_absolute(URI(url))
|
126
115
|
links << abs
|
127
116
|
end
|
@@ -175,4 +164,15 @@ class ValidateWebsite
|
|
175
164
|
def to_file(msg)
|
176
165
|
open(options[:file], 'a').write("#{msg}\n") if options[:file]
|
177
166
|
end
|
167
|
+
|
168
|
+
def get_url(page, elem, attrname)
|
169
|
+
u = elem.attributes[attrname] if elem.attributes[attrname]
|
170
|
+
return if u.nil?
|
171
|
+
begin
|
172
|
+
abs = page.to_absolute(URI(u))
|
173
|
+
rescue
|
174
|
+
abs = nil
|
175
|
+
end
|
176
|
+
return abs if abs && page.in_domain?(abs)
|
177
|
+
end
|
178
178
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
require '
|
2
|
-
require File.dirname(__FILE__) + '/fakeweb_helper'
|
3
|
-
|
4
|
-
$:.unshift(File.dirname(__FILE__) + '/../lib/')
|
1
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'fakeweb_helper'))
|
5
2
|
require 'anemone'
|
3
|
+
|
4
|
+
lib_dir = File.join(File.dirname(__FILE__), '..', 'lib')
|
5
|
+
$:.unshift(File.expand_path(lib_dir))
|
6
|
+
|
6
7
|
require 'validate_website'
|
7
8
|
|
8
9
|
SPEC_DOMAIN = 'http://www.example.com/'
|
data/spec/validator_spec.rb
CHANGED
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: 9
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 5
|
9
|
-
-
|
10
|
-
version: 0.5.
|
9
|
+
- 1
|
10
|
+
version: 0.5.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-11-
|
18
|
+
date: 2010-11-04 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|