html_validation 0.5.0 → 0.5.5

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -6,19 +6,20 @@ gemspec
6
6
  # Include everything needed to run rake, tests, features, etc.
7
7
  group :development do
8
8
  gem "rspec"
9
- gem "bundler"
9
+ gem "bundler"
10
10
  end
11
11
 
12
12
  gem 'rdoc'
13
13
  gem 'thor'
14
14
  gem 'open3'
15
15
 
16
- # Unix Rubies (OSX, Linux)
16
+ # Unix Rubies (OSX, Linux)
17
17
  platform :ruby do
18
-
18
+
19
19
  end
20
20
 
21
- # Windows Rubies (RubyInstaller)
21
+ # Windows Rubies (RubyInstaller)
22
22
  platforms :mswin, :mingw do
23
-
24
- end
23
+
24
+ end
25
+
data/README.rdoc CHANGED
@@ -15,16 +15,13 @@ barring that, review and accept any errors and warnings.
15
15
 
16
16
  The current (as of March 2013) default version of Tidy doesn't support HTML 5.
17
17
  To get HTML 5 support, install this fork of tidy: https://github.com/w3c/tidy-html5
18
- Download the repo as a zip file and extract somewhere, then follow the instructions
19
- given on the page (using sudo for make commands if on Linux).
20
18
 
21
19
  Be sure to get rid of the old tidy first if you have it already.
22
20
 
23
- Redhat/Fedora: sudo yum erase tidy
24
-
25
- Ubuntu: sudo apt-get remove tidy
21
+ Debian flavors: sudo apt-get remove tidy
26
22
 
27
- OS X: sudo port uninstall tidy
23
+ Download the repo as a zip file and extract somewhere, then follow the instructions
24
+ given on the page (using sudo for make commands if on Linux).
28
25
 
29
26
  On linux/OS X machines, confirm the right installation path using: which tidy
30
27
 
@@ -44,12 +41,12 @@ On linux/OS X machines, confirm the right installation path using: which tidy
44
41
  HaveValidHTML.show_html_in_failures = true
45
42
 
46
43
 
47
- # All tidy flags, including using a config file can be passed.
44
+ All tidy flags, including using a config file can be passed.
48
45
 
49
- # A shortcut to disable Tidy Warning messages (they are on by default)
50
- # has been created for your convenience. However, some things that might be
51
- # called "errors" show up as warnings, so the recommended approach is
52
- # run, then accept the errors / warnings that are noted.
46
+ A shortcut to disable Tidy Warning messages (they are on by default)
47
+ has been created for your convenience. However, some things that might be
48
+ called "errors" show up as warnings, so the recommended approach is
49
+ run, then accept the errors / warnings that are noted.
53
50
  HTMLValidation.show_warnings = false
54
51
 
55
52
 
data/bin/validation CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
-
2
+
3
3
  require 'rubygems'
4
4
  require 'thor'
5
5
  require 'html_validation'
@@ -8,18 +8,18 @@ require 'html_validation'
8
8
  class Validation < Thor
9
9
  include PageValidations
10
10
  desc "review", "Review and Accept (or fix and rerun) HTML Validation errors"
11
-
11
+
12
12
  method_option :data_path, :aliases => "-d", :desc => "Optional custom data path (if not default of /spec/.validate)"
13
13
  def review
14
- data_path = options[:data_path] || File.join(Dir.getwd, 'spec', '.validation')
14
+ data_path = options[:data_path] || File.join(Dir.getwd, '.validation')
15
15
  $stdout.puts "Reviewing validation results in: #{data_path}"
16
-
16
+
17
17
  HTMLValidation.new(data_path).each_exception do |result|
18
- $stdout.puts "Validation exceptions for: #{result.resource}:\n#{result.exceptions}"
18
+ $stdout.puts "Validation exceptions for: #{result.resource}:\n#{result.exceptions}"
19
19
  $stdout.puts "Accept (y)es (n)o or (q)uit"
20
20
  sin = $stdin.gets
21
21
  if sin[0].downcase == 'y'
22
- result.accept!
22
+ result.accept!
23
23
  $stdout.puts "Accepted!"
24
24
  else
25
25
  $stdout.puts "Rejected!"
@@ -1,5 +1,22 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'have_valid_html'))
2
+
1
3
  module PageValidations
2
- # Namespace planned for future additional validations
4
+ # Namespace planned for future additional validations and master wrapper gem
5
+
6
+ @@data_path = nil
7
+
8
+ def self.included(base)
9
+ # get path of including file to set a default path to save results
10
+ @@data_path = File.expand_path(File.dirname(caller[0].partition(":")[0]))
11
+ end
12
+
13
+ def self.data_path
14
+ @@data_path
15
+ end
16
+
17
+ def self.data_path=(path)
18
+ @@data_path = path
19
+ end
3
20
 
4
21
 
5
22
  class HTMLValidation
@@ -80,7 +97,7 @@ module PageValidations
80
97
  def default_result_file_path
81
98
  posix = RbConfig::CONFIG['host_os'] =~ /(darwin|linux)/
82
99
  rootpath = Rails.root if defined?(Rails)
83
- rootpath ||= HTMLValidationMatcher.data_path if HTMLValidationMatcher.data_path
100
+ rootpath ||= ::PageValidations.data_path if ::PageValidations.data_path
84
101
  rootpath ||= posix ? '/tmp/' : "c:\\tmp\\"
85
102
  File.join(rootpath, '.validation')
86
103
  end
@@ -1,3 +1,3 @@
1
1
  module PageValidations
2
- HTML_VALIDATOR_VERSION = "0.5.0"
2
+ HTML_VALIDATOR_VERSION = "0.5.5"
3
3
  end
@@ -1,4 +1,3 @@
1
1
  require 'rbconfig'
2
2
  require File.expand_path(File.join(File.dirname(__FILE__), 'html_validation/page_validations'))
3
- require File.expand_path(File.join(File.dirname(__FILE__), 'html_validation/html_validation_result'))
4
- require File.expand_path(File.join(File.dirname(__FILE__), 'html_validation/html_validation_matcher'))
3
+ require File.expand_path(File.join(File.dirname(__FILE__), 'html_validation/html_validation_result'))
@@ -20,4 +20,4 @@ module HTMLValidationHelpers
20
20
  html_5_doctype + '<html><title proprietary="1">h</title></head><body><p>a para</p></body></html>'
21
21
  end
22
22
 
23
- end
23
+ end
@@ -73,20 +73,20 @@ describe "HTMLValidation" do
73
73
  end
74
74
 
75
75
  it "should work without a data path being manually set" do
76
- h = HTMLValidation.new()
77
- result = h.validation(good_html, "http://mybestsite.com")
78
- result.exceptions.should be_empty
76
+ h = HTMLValidation.new()
77
+ result = h.validation(good_html, "http://mybestsite.com")
78
+ result.exceptions.should be_empty
79
79
  end
80
80
 
81
81
  it "should not show (should ignore) warnings when they are turned off" do
82
- HTMLValidation.show_warnings = false
83
- h = HTMLValidation.new()
84
- result = h.validation(warning_html, "http://mywarningsite.com")
85
- result.exceptions.should be_empty
86
- HTMLValidation.show_warnings = true
87
- h = HTMLValidation.new()
88
- result = h.validation(warning_html, "http://myotherwarningsite.com")
89
- result.exceptions.should_not be_empty
82
+ HTMLValidation.show_warnings = false
83
+ h = HTMLValidation.new()
84
+ result = h.validation(warning_html, "http://mywarningsite.com")
85
+ result.exceptions.should be_empty
86
+ HTMLValidation.show_warnings = true
87
+ h = HTMLValidation.new()
88
+ result = h.validation(warning_html, "http://myotherwarningsite.com")
89
+ result.exceptions.should_not be_empty
90
90
  end
91
91
 
92
92
 
@@ -111,10 +111,10 @@ describe "HTMLValidation" do
111
111
  had_exceptions = false
112
112
  @h.each_exception do |e|
113
113
  had_exceptions = true
114
- e.is_a?(HTMLValidationResult).should be_true
115
- (e.resource.length > 0).should be_true
116
- (e.html.length > 0).should be_true
117
- end
114
+ e.is_a?(HTMLValidationResult).should be_true
115
+ (e.resource.length > 0).should be_true
116
+ (e.html.length > 0).should be_true
117
+ end
118
118
  had_exceptions.should be_true
119
119
  end
120
120
 
@@ -135,4 +135,4 @@ describe "HTMLValidation" do
135
135
  Dir.glob('*').each {|f| FileUtils.rm f }
136
136
  end
137
137
 
138
- end
138
+ end
data/spec/spec_helper.rb CHANGED
@@ -3,34 +3,14 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
3
  require 'rspec'
4
4
  require 'html_validation'
5
5
 
6
- include PageValidations
7
-
8
6
  # Requires supporting files with custom matchers and macros, etc,
9
7
  # in ./support/ and its subdirectories.
10
8
  Dir["#{File.dirname(__FILE__)}/helpers/**/*.rb"].each {|f| require f }
11
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f }
12
-
13
- RSpec.configure do |config|
14
-
15
9
 
16
- end
17
-
18
- def bad_html
19
- '<html><title>the title<title></head><body><p>blah blah</body></html>'
20
- end
21
-
22
- def good_html
23
- html_5_doctype + '<html><title>the title</title></head><body><p>a paragraph</p></body></html>'
24
- end
10
+ include PageValidations
11
+ include HTMLValidationHelpers
25
12
 
26
- def dtd
27
- '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
28
- end
13
+ RSpec.configure do |config|
29
14
 
30
- def html_5_doctype
31
- '<!DOCTYPE html>'
32
- end
33
15
 
34
- def warning_html
35
- html_5_doctype + '<html><title proprietary="1">h</title></head><body><p>a para</p></body></html>'
36
- end
16
+ 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: 0.5.0
4
+ version: 0.5.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -32,7 +32,6 @@ files:
32
32
  - html_validation.gemspec
33
33
  - lib/html_validation.rb
34
34
  - lib/html_validation/have_valid_html.rb
35
- - lib/html_validation/html_validation_matcher.rb
36
35
  - lib/html_validation/html_validation_result.rb
37
36
  - lib/html_validation/page_validations.rb
38
37
  - lib/html_validation/version.rb
@@ -1,21 +0,0 @@
1
- # the item to include to get the RSPec matcher(s)
2
-
3
- require File.expand_path(File.join(File.dirname(__FILE__), 'have_valid_html'))
4
-
5
- module HTMLValidationMatcher
6
- @@data_path = nil
7
-
8
- def self.included(base)
9
- # get path of including file, which should be in the /spec folder
10
- @@data_path, = File.expand_path(File.dirname(caller[0].partition(":")[0]))
11
- end
12
-
13
- def self.data_path
14
- @@data_path
15
- end
16
-
17
- def self.data_path=(path)
18
- @@data_path = path
19
- end
20
-
21
- end