bbc_standards 0.1.1 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/bbc_standards/validator.rb +14 -3
- data/lib/bbc_standards.rb +1 -1
- metadata +3 -3
@@ -7,7 +7,7 @@ module BBCStandards
|
|
7
7
|
def initialize(xml)
|
8
8
|
@xml = xml
|
9
9
|
# TODO: remove this once Barlesque sorts out the BBC Search form
|
10
|
-
@xml.sub!('<form method="get" action="http://search.bbc.co.uk/search" accept-charset="utf-8"
|
10
|
+
@xml.sub!('<form method="get" action="http://search.bbc.co.uk/search" accept-charset="utf-8"> <fieldset> <input',
|
11
11
|
'<form method="get" action="http://search.bbc.co.uk/search" accept-charset="utf-8"><fieldset><legend>foo</legend><input')
|
12
12
|
@doc = Nokogiri::HTML(xml)
|
13
13
|
@errors = []
|
@@ -57,14 +57,25 @@ module BBCStandards
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def test_bbc_standards
|
60
|
+
rt = Raakt::Test.new(@xml)
|
61
|
+
# Check title structure
|
60
62
|
@errors << Error.new("Title is not valid") unless @xml =~ /<title>\w+( - )?([^<-]+)?( - )?([^<-]+)?<\/title>/
|
63
|
+
# Check 1 h1 tag
|
61
64
|
@errors << Error.new("Page doesn't have 1 <h1> tag") unless @doc.xpath('//h1').size == 1
|
62
|
-
|
65
|
+
# Check heading structure
|
66
|
+
@errors << Error.new("Document heading structure is wrong") unless rt.check_document_structure.size == 0
|
67
|
+
# Check images have alt tags
|
68
|
+
@errors += rt.check_images.map { |e| Error.new(e.text) }
|
69
|
+
# Check images have width and height attributes
|
70
|
+
@errors += @doc.xpath('//img[not(@width) or not(@height)]').map { |img| Error.new("No width or height attribute for #{img.to_s}") }
|
71
|
+
# Check use of <br/> for whitespace (more than one consecutive <br/>)
|
63
72
|
@errors << Error.new("Page is using <br> for whitespace") if @xml =~ /<br\/>\s*<br\/>/
|
64
|
-
|
73
|
+
# Check for banned tags
|
74
|
+
%w(b i big blink marquee s strike tt u center nobr font).each do |tag|
|
65
75
|
@errors << Error.new("Page is using <#{tag}>") if @doc.xpath("//#{tag}").any?
|
66
76
|
end
|
67
77
|
end
|
78
|
+
|
68
79
|
end
|
69
80
|
|
70
81
|
class Error
|
data/lib/bbc_standards.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bbc_standards
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Sinclair
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-04-06 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -63,6 +63,6 @@ rubyforge_project:
|
|
63
63
|
rubygems_version: 1.3.5
|
64
64
|
signing_key:
|
65
65
|
specification_version: 3
|
66
|
-
summary:
|
66
|
+
summary: BBCStandards provides rspec helpers for checking whether documents conform to the BBC FM&T Guidelines and Standards.
|
67
67
|
test_files: []
|
68
68
|
|