html_validation 0.0.1 → 0.4.1
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/Gemfile +1 -0
- data/README.rdoc +1 -1
- data/{lib/tasks/validation.thor → bin/validation} +9 -3
- data/html_validation.gemspec +1 -1
- data/lib/html_validation/have_valid_html.rb +1 -4
- data/lib/html_validation/html_validation_result.rb +2 -0
- data/lib/html_validation/page_validations.rb +61 -0
- data/lib/html_validation/version.rb +1 -1
- data/lib/html_validation.rb +3 -60
- metadata +6 -5
- data/VERSION +0 -1
data/Gemfile
CHANGED
data/README.rdoc
CHANGED
@@ -78,7 +78,7 @@ On linux/OS X machines, confirm the right installation path shows up with: whic
|
|
78
78
|
in the data_folder. Typically this is the default folder: spec/.validation.
|
79
79
|
After a validation fails, run the thor task to accept or reject validation exceptions.
|
80
80
|
|
81
|
-
From your project's root folder, run:
|
81
|
+
From your project's root folder, run: validation review
|
82
82
|
|
83
83
|
Note, if you configure an alternate data_folder, you may pass it as an option
|
84
84
|
to the Thor task.
|
@@ -1,5 +1,9 @@
|
|
1
|
-
#!/usr/bin/env
|
2
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'thor'
|
5
|
+
require 'html_validation'
|
6
|
+
|
3
7
|
|
4
8
|
class Validation < Thor
|
5
9
|
include PageValidations
|
@@ -24,4 +28,6 @@ class Validation < Thor
|
|
24
28
|
end
|
25
29
|
$stdout.puts "HTML Validation Acceptance completed"
|
26
30
|
end
|
27
|
-
end
|
31
|
+
end
|
32
|
+
|
33
|
+
Validation.start
|
data/html_validation.gemspec
CHANGED
@@ -9,9 +9,9 @@ Gem::Specification.new do |gem|
|
|
9
9
|
gem.homepage = "https://github.com/ericbeland/html_validation"
|
10
10
|
|
11
11
|
gem.files = `git ls-files`.split($\)
|
12
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
12
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
13
|
gem.name = "html_validation"
|
15
14
|
gem.require_paths = ["lib"]
|
15
|
+
gem.executables = ['validation']
|
16
16
|
gem.version = PageValidations::HTML_VALIDATOR_VERSION
|
17
17
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
module PageValidations
|
4
|
+
|
5
|
+
class HTMLValidation
|
6
|
+
|
7
|
+
# The data_folder is where we store our output. options[:tidyopts], which defaults to "-qi"
|
8
|
+
# can be used to override the command line options to html tidy. On *nix, man tidy to see
|
9
|
+
# what else you might use for this string instead of "-qi", however "-qi" is probably what
|
10
|
+
# you want 95% of the time.
|
11
|
+
|
12
|
+
# You may also pass :ignore_proprietary => true as an option to suppress messages like:
|
13
|
+
# line 1 column 176 - Warning: <textarea> proprietary attribute "wrap"
|
14
|
+
# line 1 column 176 - Warning: <textarea> proprietary attribute "spellcheck"
|
15
|
+
|
16
|
+
# It may be useful to pass a subfolder in your project as the data_folder, so your
|
17
|
+
# HTML Validation status and validation results are stored along with your source.
|
18
|
+
def initialize(folder_for_data = nil, options = {})
|
19
|
+
self.data_folder = folder_for_data || default_result_file_path
|
20
|
+
@options = options
|
21
|
+
end
|
22
|
+
|
23
|
+
# For each stored exception, yield an HTMLValidationResult object to allow the user to
|
24
|
+
# call .accept! on the exception if it is OK.
|
25
|
+
def each_exception
|
26
|
+
Dir.chdir(@data_folder)
|
27
|
+
Dir.glob("*.exceptions.txt").each do |file|
|
28
|
+
if File.open(File.join(@data_folder, file), 'r').read != ''
|
29
|
+
yield HTMLValidationResult.load_from_files(file.gsub('.exceptions.txt',''))
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def validation(html, resource)
|
35
|
+
resource_data_path = File.join(@data_folder, filenameize(resource))
|
36
|
+
HTMLValidationResult.new(resource, html, resource_data_path, @options)
|
37
|
+
end
|
38
|
+
|
39
|
+
def data_folder=(path)
|
40
|
+
FileUtils.mkdir_p(path)
|
41
|
+
@data_folder = path
|
42
|
+
end
|
43
|
+
|
44
|
+
def default_result_file_path
|
45
|
+
posix = RbConfig::CONFIG['host_os'] =~ /(darwin|linux)/
|
46
|
+
rootpath = Rails.root if defined?(Rails)
|
47
|
+
rootpath ||= HTMLValidationMatcher.data_path if HTMLValidationMatcher.data_path
|
48
|
+
rootpath ||= posix ? '/tmp/' : "c:\\tmp\\"
|
49
|
+
File.join(rootpath, '.validation')
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
# Takes a url or filepath qne trims and sanitizes it for use as a filename.
|
55
|
+
def filenameize(path)
|
56
|
+
path.gsub!(/www.|^(http:\/\/|\/|C:\\)/, '')
|
57
|
+
path.gsub(/[^0-9A-Za-z.]/, '_')
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
data/lib/html_validation.rb
CHANGED
@@ -18,65 +18,8 @@
|
|
18
18
|
|
19
19
|
require 'rbconfig'
|
20
20
|
|
21
|
-
require File.expand_path(File.join(File.dirname(__FILE__), 'html_validation/html_validation_result'))
|
22
|
-
require File.expand_path(File.join(File.dirname(__FILE__), 'html_validation/html_validation_matcher'))
|
23
21
|
|
24
|
-
module PageValidations
|
25
|
-
|
26
|
-
class HTMLValidation
|
27
|
-
|
28
|
-
# The data_folder is where we store our output. options[:tidyopts], which defaults to "-qi"
|
29
|
-
# can be used to override the command line options to html tidy. On *nix, man tidy to see
|
30
|
-
# what else you might use for this string instead of "-qi", however "-qi" is probably what
|
31
|
-
# you want 95% of the time.
|
32
|
-
|
33
|
-
# You may also pass :ignore_proprietary => true as an option to suppress messages like:
|
34
|
-
# line 1 column 176 - Warning: <textarea> proprietary attribute "wrap"
|
35
|
-
# line 1 column 176 - Warning: <textarea> proprietary attribute "spellcheck"
|
36
|
-
|
37
|
-
# It may be useful to pass a subfolder in your project as the data_folder, so your
|
38
|
-
# HTML Validation status and validation results are stored along with your source.
|
39
|
-
def initialize(folder_for_data = nil, options = {})
|
40
|
-
self.data_folder = folder_for_data || default_result_file_path
|
41
|
-
@options = options
|
42
|
-
end
|
43
22
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
Dir.chdir(@data_folder)
|
48
|
-
Dir.glob("*.exceptions.txt").each do |file|
|
49
|
-
if File.open(File.join(@data_folder, file), 'r').read != ''
|
50
|
-
yield HTMLValidationResult.load_from_files(file.gsub('.exceptions.txt',''))
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def validation(html, resource)
|
56
|
-
resource_data_path = File.join(@data_folder, filenameize(resource))
|
57
|
-
HTMLValidationResult.new(resource, html, resource_data_path, @options)
|
58
|
-
end
|
59
|
-
|
60
|
-
def data_folder=(path)
|
61
|
-
FileUtils.mkdir_p(path)
|
62
|
-
@data_folder = path
|
63
|
-
end
|
64
|
-
|
65
|
-
def default_result_file_path
|
66
|
-
posix = RbConfig::CONFIG['host_os'] =~ /(darwin|linux)/
|
67
|
-
rootpath = Rails.root if defined?(Rails)
|
68
|
-
rootpath ||= HTMLValidationMatcher.data_path if HTMLValidationMatcher.data_path
|
69
|
-
rootpath ||= posix ? '/tmp/' : "c:\\tmp\\"
|
70
|
-
File.join(rootpath, '.validation')
|
71
|
-
end
|
72
|
-
|
73
|
-
private
|
74
|
-
|
75
|
-
# Takes a url or filepath qne trims and sanitizes it for use as a filename.
|
76
|
-
def filenameize(path)
|
77
|
-
path.gsub!(/www.|^(http:\/\/|\/|C:\\)/, '')
|
78
|
-
path.gsub(/[^0-9A-Za-z.]/, '_')
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
82
|
-
end
|
23
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'html_validation/page_validations'))
|
24
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'html_validation/html_validation_result'))
|
25
|
+
require File.expand_path(File.join(File.dirname(__FILE__), 'html_validation/html_validation_matcher'))
|
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: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,13 +9,14 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-04-05 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: HTML Validation lets you validate html locally. Lets you build html validation
|
15
15
|
into your test suite, but break the rules if you must.
|
16
16
|
email:
|
17
17
|
- ebeland@gmail.com
|
18
|
-
executables:
|
18
|
+
executables:
|
19
|
+
- validation
|
19
20
|
extensions: []
|
20
21
|
extra_rdoc_files: []
|
21
22
|
files:
|
@@ -27,14 +28,14 @@ files:
|
|
27
28
|
- LICENSE.txt
|
28
29
|
- README.rdoc
|
29
30
|
- Rakefile
|
30
|
-
-
|
31
|
+
- bin/validation
|
31
32
|
- html_validation.gemspec
|
32
33
|
- lib/html_validation.rb
|
33
34
|
- lib/html_validation/have_valid_html.rb
|
34
35
|
- lib/html_validation/html_validation_matcher.rb
|
35
36
|
- lib/html_validation/html_validation_result.rb
|
37
|
+
- lib/html_validation/page_validations.rb
|
36
38
|
- lib/html_validation/version.rb
|
37
|
-
- lib/tasks/validation.thor
|
38
39
|
- spec/html_validator_matcher_spec.rb
|
39
40
|
- spec/html_validator_spec.rb
|
40
41
|
- spec/spec_helper.rb
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.1.1
|