html_acceptance 0.1.15 → 0.1.16
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/VERSION +1 -1
- data/html_acceptance.gemspec +3 -4
- data/lib/html_acceptance/html_acceptance_result.rb +26 -23
- data/spec/html_acceptance_spec.rb +1 -1
- metadata +18 -44
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.16
|
data/html_acceptance.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{html_acceptance}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.16"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Eric Beland"]
|
12
|
-
s.date = %q{2011-02-
|
12
|
+
s.date = %q{2011-02-18}
|
13
13
|
s.description = %q{HTML Acceptance lets you accept warnings/errors. Less noisey validation will hopefully let you build html validation into your test suite, but break the rules if you must.}
|
14
14
|
s.email = %q{ebeland@testomatix.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -38,7 +38,7 @@ Gem::Specification.new do |s|
|
|
38
38
|
s.licenses = ["MIT"]
|
39
39
|
s.require_paths = ["lib"]
|
40
40
|
s.requirements = ["HTML Tidy on the command PATH or at /usr/bin/tidy"]
|
41
|
-
s.rubygems_version = %q{1.
|
41
|
+
s.rubygems_version = %q{1.5.2}
|
42
42
|
s.summary = %q{Wrapper for HTMLTidy that lets you accept warnings/errors}
|
43
43
|
s.test_files = [
|
44
44
|
"spec/html_acceptance_spec.rb",
|
@@ -46,7 +46,6 @@ Gem::Specification.new do |s|
|
|
46
46
|
]
|
47
47
|
|
48
48
|
if s.respond_to? :specification_version then
|
49
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
50
49
|
s.specification_version = 3
|
51
50
|
|
52
51
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
@@ -3,6 +3,7 @@ require 'open3'
|
|
3
3
|
class HTMLAcceptanceResult
|
4
4
|
attr_accessor :resource, :html, :exceptions
|
5
5
|
|
6
|
+
# valid options[:tidy_opts]
|
6
7
|
def initialize(resource, html, datapath, options={})
|
7
8
|
@resource = resource
|
8
9
|
@html = html
|
@@ -12,11 +13,11 @@ class HTMLAcceptanceResult
|
|
12
13
|
valid?
|
13
14
|
end
|
14
15
|
|
15
|
-
# takes a .url
|
16
|
-
def self.load_from_files(
|
17
|
-
resource = File.open("#{
|
18
|
-
html = File.open("#{
|
19
|
-
HTMLAcceptanceResult.new(resource, html,
|
16
|
+
# takes a .url and loads the data into this object
|
17
|
+
def self.load_from_files(filepath)
|
18
|
+
resource = File.open("#{filepath}.resource.txt", 'r').read
|
19
|
+
html = File.open("#{filepath}.html.txt", 'r').read
|
20
|
+
HTMLAcceptanceResult.new(resource, html, filepath)
|
20
21
|
end
|
21
22
|
|
22
23
|
# Validates an html string using html tidy. If there are no warnings or exceptions, or
|
@@ -25,23 +26,22 @@ class HTMLAcceptanceResult
|
|
25
26
|
# compares the exception strings with the lines and columns removed. Name can be a filename,
|
26
27
|
# file system path, or url, so long it is uniquely associated with the passed in html.
|
27
28
|
def valid?
|
28
|
-
@exceptions = validate
|
29
|
-
File.delete(data_path("accepted
|
30
|
-
valid=(filter(@exceptions) == '' or accepted?(@exceptions))
|
31
|
-
save_html_and_exceptions
|
29
|
+
@exceptions = validate
|
30
|
+
File.delete(data_path("accepted")) if File.exists?(data_path("accepted")) if @exceptions == ''
|
31
|
+
valid = (filter(@exceptions) == '' or accepted?(@exceptions))
|
32
|
+
save_html_and_exceptions
|
32
33
|
valid
|
33
34
|
end
|
34
|
-
|
35
35
|
|
36
36
|
# Saves the exception string for the given url or file path. When next run, if the exception
|
37
37
|
# string is identical, valid? will return true. Note that #exceptions will still list the
|
38
38
|
# exception string, though, even if it is an accepted exception string.
|
39
39
|
def accept!
|
40
|
-
File.open(data_path("accepted
|
40
|
+
File.open(data_path("accepted"), 'w') {|f| f.write(@exceptions) }
|
41
41
|
end
|
42
42
|
|
43
43
|
private
|
44
|
-
|
44
|
+
# We specifically prefer /usr/bin/tidyby default on *nix as there is another "tidy" programs
|
45
45
|
# that could end up earlier on the path. On snow leopard, tidy was installed at this location
|
46
46
|
# for me by default.
|
47
47
|
def tidy_command
|
@@ -52,19 +52,19 @@ class HTMLAcceptanceResult
|
|
52
52
|
|
53
53
|
# get the filename for storing a type of data
|
54
54
|
def data_path(filetype)
|
55
|
-
"#{@datapath}.#{filetype}"
|
55
|
+
"#{@datapath}.#{filetype}.txt"
|
56
56
|
end
|
57
57
|
|
58
58
|
def save_html_and_exceptions
|
59
|
-
File.open(data_path("
|
60
|
-
File.open(data_path("
|
61
|
-
|
62
|
-
end
|
59
|
+
File.open(data_path("html"), 'w') {|f| f.write(@html) }
|
60
|
+
File.open(data_path("resource"), 'w') {|f| f.write(@resource) }
|
61
|
+
File.open(data_path("exceptions"), 'w') {|f| f.write(@exceptions) }
|
62
|
+
end
|
63
63
|
|
64
64
|
# have we previously accepted this exact string for this path?
|
65
65
|
def accepted?(exception_str)
|
66
66
|
exception_str=filter(exception_str)
|
67
|
-
File.exists?(data_path('accepted
|
67
|
+
File.exists?(data_path('accepted')) ? filter(File.open(data_path('accepted'),"r").read) == exception_str : false
|
68
68
|
end
|
69
69
|
|
70
70
|
# Line numbers of exceptions are likely to change with any minor edit, so our validation
|
@@ -77,11 +77,14 @@ class HTMLAcceptanceResult
|
|
77
77
|
# /line [0-9]+ column [0-9]+ - / + =~ "line 1 column 1 - Warning: missing <!DOCTYPE> declaration"
|
78
78
|
end
|
79
79
|
|
80
|
-
def validate
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
80
|
+
def validate
|
81
|
+
results=''
|
82
|
+
Open3.popen3(tidy_command) do |stdin, stdout, stderr, wait_thr|
|
83
|
+
stdin.puts @html
|
84
|
+
stdin.close
|
85
|
+
results=stderr.read
|
86
|
+
end
|
87
|
+
results
|
85
88
|
end
|
86
89
|
|
87
90
|
end
|
metadata
CHANGED
@@ -1,13 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: html_acceptance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
- 15
|
10
|
-
version: 0.1.15
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.16
|
11
6
|
platform: ruby
|
12
7
|
authors:
|
13
8
|
- Eric Beland
|
@@ -15,71 +10,53 @@ autorequire:
|
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
12
|
|
18
|
-
date: 2011-02-
|
13
|
+
date: 2011-02-18 00:00:00 -05:00
|
19
14
|
default_executable:
|
20
15
|
dependencies:
|
21
16
|
- !ruby/object:Gem::Dependency
|
22
|
-
type: :development
|
23
|
-
prerelease: false
|
24
17
|
name: rspec
|
25
|
-
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
19
|
none: false
|
27
20
|
requirements:
|
28
21
|
- - ~>
|
29
22
|
- !ruby/object:Gem::Version
|
30
|
-
hash: 3
|
31
|
-
segments:
|
32
|
-
- 2
|
33
|
-
- 3
|
34
|
-
- 0
|
35
23
|
version: 2.3.0
|
36
|
-
requirement: *id001
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
24
|
type: :development
|
39
25
|
prerelease: false
|
26
|
+
version_requirements: *id001
|
27
|
+
- !ruby/object:Gem::Dependency
|
40
28
|
name: bundler
|
41
|
-
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
42
30
|
none: false
|
43
31
|
requirements:
|
44
32
|
- - ~>
|
45
33
|
- !ruby/object:Gem::Version
|
46
|
-
hash: 23
|
47
|
-
segments:
|
48
|
-
- 1
|
49
|
-
- 0
|
50
|
-
- 0
|
51
34
|
version: 1.0.0
|
52
|
-
requirement: *id002
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
35
|
type: :development
|
55
36
|
prerelease: false
|
37
|
+
version_requirements: *id002
|
38
|
+
- !ruby/object:Gem::Dependency
|
56
39
|
name: jeweler
|
57
|
-
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
58
41
|
none: false
|
59
42
|
requirements:
|
60
43
|
- - ~>
|
61
44
|
- !ruby/object:Gem::Version
|
62
|
-
hash: 7
|
63
|
-
segments:
|
64
|
-
- 1
|
65
|
-
- 5
|
66
|
-
- 2
|
67
45
|
version: 1.5.2
|
68
|
-
requirement: *id003
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
46
|
type: :development
|
71
47
|
prerelease: false
|
48
|
+
version_requirements: *id003
|
49
|
+
- !ruby/object:Gem::Dependency
|
72
50
|
name: rcov
|
73
|
-
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
74
52
|
none: false
|
75
53
|
requirements:
|
76
54
|
- - ">="
|
77
55
|
- !ruby/object:Gem::Version
|
78
|
-
hash: 3
|
79
|
-
segments:
|
80
|
-
- 0
|
81
56
|
version: "0"
|
82
|
-
|
57
|
+
type: :development
|
58
|
+
prerelease: false
|
59
|
+
version_requirements: *id004
|
83
60
|
description: HTML Acceptance lets you accept warnings/errors. Less noisey validation will hopefully let you build html validation into your test suite, but break the rules if you must.
|
84
61
|
email: ebeland@testomatix.com
|
85
62
|
executables: []
|
@@ -120,7 +97,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
120
97
|
requirements:
|
121
98
|
- - ">="
|
122
99
|
- !ruby/object:Gem::Version
|
123
|
-
hash:
|
100
|
+
hash: 3196192247928734117
|
124
101
|
segments:
|
125
102
|
- 0
|
126
103
|
version: "0"
|
@@ -129,14 +106,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
106
|
requirements:
|
130
107
|
- - ">="
|
131
108
|
- !ruby/object:Gem::Version
|
132
|
-
hash: 3
|
133
|
-
segments:
|
134
|
-
- 0
|
135
109
|
version: "0"
|
136
110
|
requirements:
|
137
111
|
- HTML Tidy on the command PATH or at /usr/bin/tidy
|
138
112
|
rubyforge_project:
|
139
|
-
rubygems_version: 1.
|
113
|
+
rubygems_version: 1.5.2
|
140
114
|
signing_key:
|
141
115
|
specification_version: 3
|
142
116
|
summary: Wrapper for HTMLTidy that lets you accept warnings/errors
|