html_validation 1.1.4 → 1.1.6

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
- SHA1:
3
- metadata.gz: 1c71f1d5bf532b471165022225527f2eb624abac
4
- data.tar.gz: 3544c06a88e7c88ccf01beea50da0dfb3e706683
2
+ SHA256:
3
+ metadata.gz: 2be1ecba4fac05b51602b3c9896ed7b0fd33e39b530996d547638c5c921c5f4b
4
+ data.tar.gz: de11cf5ea5b782484c1f74c76bdfc0f0afd787838e996aec35c18c2595df46b7
5
5
  SHA512:
6
- metadata.gz: 2f5f523eb348772060dc955ad5500ce2e51d873d20c3f226cf907ddce96a51739df3133be57e07b2bd6ff61c3299d4fd97cbf764094c4055efd79d7e45ec6df7
7
- data.tar.gz: f2baacdf1e9248d68733eafcf23c04629ed61bc1f9d2207f1bac9d332ae19214f702cfe4d278f69968f23a85bf473d05296bb4e9dac710325bd8668699c163ac
6
+ metadata.gz: 60a3e005e249723e68ce8a9466053a78050ba63177261a1855a974e50094e6d294b1f35b3b72828f8a45fa973bb71cc39ba568ac9873371053bea2840226b7dd
7
+ data.tar.gz: 787273a1c5ac354efbf488a79ac71801b5bcae6c9b31208ac38c8ef4b32dde93b5b780dfeaf06a7edcd598373a2a7bb6e0cc1499ad651c64f3695f2d1a24a890
@@ -1,5 +1,3 @@
1
-
2
-
3
1
  module PageValidations
4
2
 
5
3
  class HaveValidHTML
@@ -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
@@ -44,7 +44,7 @@ class HTMLValidationResult
44
44
  # file system path, or url, so long it is uniquely associated with the passed in html.
45
45
  def valid?
46
46
  @exceptions = validate
47
- File.delete(data_path("accepted")) if File.exists?(data_path("accepted")) if @exceptions == ''
47
+ File.delete(data_path("accepted")) if File.exist?(data_path("accepted")) if @exceptions == ''
48
48
  valid = (filter(@exceptions) == '' or accepted?(@exceptions))
49
49
  save_html_and_exceptions
50
50
  valid
@@ -54,11 +54,11 @@ 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!
61
- if File.exists?(data_path("accepted"))
61
+ if File.exist?(data_path("accepted"))
62
62
  File.delete data_path("accepted")
63
63
  end
64
64
  end
@@ -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.exist?(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,12 +115,11 @@ 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
122
122
  stderr.close
123
123
  result
124
124
  end
125
-
126
125
  end
@@ -20,7 +20,6 @@ module PageValidations
20
20
 
21
21
 
22
22
  class HTMLValidation
23
-
24
23
  def self.result_attributes *names
25
24
  @@result_attributes = names.each do |name|
26
25
  class_eval(%Q{
@@ -136,6 +135,5 @@ module PageValidations
136
135
  new_path = path.gsub(/www.|^(http:\/\/|\/|C:\\)/, '')
137
136
  new_path.gsub(/[^0-9A-Za-z.]/, '_')
138
137
  end
139
-
140
138
  end
141
139
  end
@@ -1,3 +1,3 @@
1
1
  module PageValidations
2
- HTML_VALIDATOR_VERSION = "1.1.4"
2
+ HTML_VALIDATOR_VERSION = "1.1.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
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.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Beland
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-01 00:00:00.000000000 Z
11
+ date: 2023-08-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: HTML Validation lets you validate html locally. Lets you build html validation
14
14
  into your test suite, but break the rules if you must.
@@ -29,7 +29,7 @@ homepage: https://github.com/ericbeland/html_validation
29
29
  licenses:
30
30
  - MIT
31
31
  metadata: {}
32
- post_install_message:
32
+ post_install_message:
33
33
  rdoc_options: []
34
34
  require_paths:
35
35
  - lib
@@ -44,9 +44,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
46
  requirements: []
47
- rubyforge_project:
48
- rubygems_version: 2.5.1
49
- signing_key:
47
+ rubygems_version: 3.3.26
48
+ signing_key:
50
49
  specification_version: 4
51
50
  summary: Local HTML validation for tests and RSpec.
52
51
  test_files: []