html_validation 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1c71f1d5bf532b471165022225527f2eb624abac
4
- data.tar.gz: 3544c06a88e7c88ccf01beea50da0dfb3e706683
3
+ metadata.gz: 5922a978e4acaf0b7f437d4c42a77f23d2b02aab
4
+ data.tar.gz: e3d9a002a264c181e69668d6817d5a2631823d53
5
5
  SHA512:
6
- metadata.gz: 2f5f523eb348772060dc955ad5500ce2e51d873d20c3f226cf907ddce96a51739df3133be57e07b2bd6ff61c3299d4fd97cbf764094c4055efd79d7e45ec6df7
7
- data.tar.gz: f2baacdf1e9248d68733eafcf23c04629ed61bc1f9d2207f1bac9d332ae19214f702cfe4d278f69968f23a85bf473d05296bb4e9dac710325bd8668699c163ac
6
+ metadata.gz: e6e9a96483cac87c9c865daf501e42db8a7bea659df29b16da948c1abb40489a412f6d0e361586fbf2fd20405f84273774d35f009f7c722fcb5fa9e12372ddbc
7
+ data.tar.gz: 2c23cab2a04de790e4c9e6f872e7185a0a9fef2930e97cebfe5a89458aba7dc2faa710815a57fa720a0e56f1835c217031d3492569e690de7723ac93facfc6b9
@@ -14,12 +14,12 @@ class HTMLValidationResult
14
14
 
15
15
  # options ex: options[:tidy_opts] = ['--show-warnings false']
16
16
  def initialize(resource, html, datapath, tidy_flags = [], options = {})
17
- @resource = resource
18
- @html = html
19
- @exceptions = ''
20
- @datapath = datapath
21
- @tidy_flags = (HTMLValidation.default_tidy_flags + tidy_flags).uniq
22
- @options = options
17
+ @resource = resource
18
+ @html = html
19
+ @exceptions = ''
20
+ @datapath = datapath
21
+ @tidy_flags = (HTMLValidation.default_tidy_flags + tidy_flags).uniq
22
+ @options = options
23
23
  valid?
24
24
  end
25
25
 
@@ -32,9 +32,9 @@ class HTMLValidationResult
32
32
 
33
33
  # takes a .url and loads the data into this object
34
34
  def self.load_from_files(filepath)
35
- resource = File.open("#{filepath}.resource.txt", 'r').read
36
- html = File.open("#{filepath}.html.txt", 'r').read
37
- HTMLValidationResult.new(resource, html, filepath)
35
+ resource = File.open("#{filepath}.resource.txt", 'r').read
36
+ html = File.open("#{filepath}.html.txt", 'r').read
37
+ HTMLValidationResult.new(resource, html, filepath)
38
38
  end
39
39
 
40
40
  # Validates an html string using html tidy. If there are no warnings or exceptions, or
@@ -54,7 +54,7 @@ class HTMLValidationResult
54
54
  # string is identical, valid? will return true. Note that #exceptions will still list the
55
55
  # exception string, though, even if it is an accepted exception string.
56
56
  def accept!
57
- File.open(data_path("accepted"), 'w') {|f| f.write(@exceptions) }
57
+ File.open(data_path("accepted"), 'w') {|f| f.write(@exceptions)}
58
58
  end
59
59
 
60
60
  def reject!
@@ -82,15 +82,15 @@ class HTMLValidationResult
82
82
  end
83
83
 
84
84
  def save_html_and_exceptions
85
- File.open(data_path("html"), 'w') {|f| f.write(@html) }
86
- File.open(data_path("resource"), 'w') {|f| f.write(@resource) }
87
- File.open(data_path("exceptions"), 'w') {|f| f.write(@exceptions) }
85
+ File.open(data_path("html"), 'w') {|f| f.write(@html)}
86
+ File.open(data_path("resource"), 'w') {|f| f.write(@resource)}
87
+ File.open(data_path("exceptions"), 'w') {|f| f.write(@exceptions)}
88
88
  end
89
89
 
90
- # have we previously accepted this exact string for this path?
90
+ # have we previously accepted this exact string for this path?
91
91
  def accepted?(exception_str)
92
92
  exception_str = filter(exception_str)
93
- File.exists?(data_path('accepted')) ? filter(File.open(data_path('accepted'),"r").read) == exception_str : false
93
+ File.exists?(data_path('accepted')) ? filter(File.open(data_path('accepted'), "r").read) == exception_str : false
94
94
  end
95
95
 
96
96
  # Line numbers of exceptions are likely to change with any minor edit, so our validation
@@ -98,15 +98,15 @@ class HTMLValidationResult
98
98
  # if the errors change position in the file (up or down b/c you add or remove code),
99
99
  # accepted exception strings will remain valid.
100
100
  def filter(str)
101
- str = str.gsub(/^line.*trimming empty.*\n/, '') # the messages about empty are overzealous, and not invalid
102
- str = str.gsub(/^line.*proprietary.*\n/, '') if options[:ignore_proprietary] # if you use IE only attributes like wrap, or spellcheck or things not in standard
101
+ str = str.gsub(/^line.*trimming empty.*\n/, '') # the messages about empty are overzealous, and not invalid
102
+ str = str.gsub(/^line.*proprietary.*\n/, '') if options[:ignore_proprietary] # if you use IE only attributes like wrap, or spellcheck or things not in standard
103
103
  str = str.gsub(/^line.*(?:Error|Warning):.*<\/?(?:#{options[:ignored_tag_errors].join('|')})>.*\n/, '') if options[:ignored_tag_errors] && options[:ignored_tag_errors].any?
104
104
  str = str.gsub(/^line.*(?:Error|Warning):.* attribute \"(?:#{options[:ignored_attribute_errors].join('|')})\".*\n/, '') if options[:ignored_attribute_errors] && options[:ignored_attribute_errors].any?
105
105
  if options[:ignored_errors] && options[:ignored_errors].any? && str.gsub(/^line.*(?:Error|Warning):/, '') =~ ignored_errors_regex
106
- str = str.gsub(Regexp.new(/^line.*(?:Error|Warning):/.source + '.*' + ignored_errors_regex.source + '.*' +/\n/.source), '')
106
+ str = str.gsub(Regexp.new(/^line.*(?:Error|Warning):/.source + '.*' + ignored_errors_regex.source + '.*' + /\n/.source), '')
107
107
  end
108
108
  str.gsub(/line [0-9]+ column [0-9]+ -/, '')
109
- # /line [0-9]+ column [0-9]+ - / + =~ "line 1 column 1 - Warning: missing <!DOCTYPE> declaration"
109
+ # /line [0-9]+ column [0-9]+ - / + =~ "line 1 column 1 - Warning: missing <!DOCTYPE> declaration"
110
110
  end
111
111
 
112
112
  def ignored_errors_regex
@@ -115,7 +115,7 @@ class HTMLValidationResult
115
115
 
116
116
  def validate
117
117
  stdin, stdout, stderr = Open3.popen3(tidy_command)
118
- stdin.puts @html
118
+ stdin.puts @html.encode!("UTF-8", invalid: :replace, undef: :replace).force_encoding("utf-8")
119
119
  stdin.close
120
120
  stdout.close
121
121
  result = stderr.read
@@ -1,3 +1,3 @@
1
1
  module PageValidations
2
- HTML_VALIDATOR_VERSION = "1.1.4"
2
+ HTML_VALIDATOR_VERSION = "1.1.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: html_validation
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Beland