html5_validator 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MTc2OTg0ZmNiNmVmOGViMDMxMzM1MzIyZDk4NzAyMGIyZDkwOWQxNw==
5
+ data.tar.gz: !binary |-
6
+ ZTBkYzU2MTA1NjIyY2IzODA0ZjE1ZDEzYThjMDBmZGEyYmZjOTFiMw==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NWFjNGM3NDI0MzVmMzAxZjA2M2ZhMzJjZThhOGE3NmYwMDczNTM3NWFlMGIy
10
+ ZDc4ZjNjOTMxYzBkM2UzOTE4N2I5YjZiYjA3MWRjMGIyMWEyNjQ0OTBkY2I1
11
+ YWJmNTkyNTYxMWFkOTYwMzhmN2FkNzNlM2Y3MzFmM2RmNzdjMjA=
12
+ data.tar.gz: !binary |-
13
+ NDc1MWZjNDQ3ZGJmMmY4NzBjZGNjNDhkNzk5YjFkZTljMDI0YTJkMzljOTk0
14
+ NjY3OWM1ZDJmM2E0ZTNkMWY2YjZlOTJjNjY0ZGYwNmUyNTAxYWEyZjZkYTY5
15
+ NDg3YTVjZWE1MWI3ZjIzNjIzOWYwM2UwYjZkNzFjMmU5NTE2OWQ=
data/.gitignore CHANGED
@@ -1,4 +1,17 @@
1
1
  *.gem
2
+ *.rbc
2
3
  .bundle
4
+ .config
5
+ .yardoc
3
6
  Gemfile.lock
4
- pkg/*
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- # Specify your gem's dependencies in html5_validator.gemspec
4
3
  gemspec
data/README.rdoc CHANGED
@@ -11,6 +11,7 @@ Ruby gem to test for valid HTML5 markup with RSpec. It also provides an interfac
11
11
  * gem install html5_validator
12
12
 
13
13
  == MAIN USAGE:
14
+ require 'html5_validator/matchers'
14
15
 
15
16
  describe TestController do
16
17
  render_views
@@ -24,6 +25,7 @@ Ruby gem to test for valid HTML5 markup with RSpec. It also provides an interfac
24
25
  If your spec fails it outputs the validation error in your console.
25
26
 
26
27
  == OTHER USAGE:
28
+ require 'html5_validator/validator'
27
29
 
28
30
  @validator = Html5Validator::Validator.new
29
31
 
@@ -46,7 +48,7 @@ See more examples in the spec folder.
46
48
 
47
49
  (The MIT License)
48
50
 
49
- Copyright (c) 2011 Damian Nicholson
51
+ Copyright (c) 2013 Damian Nicholson
50
52
 
51
53
  Permission is hereby granted, free of charge, to any person obtaining
52
54
  a copy of this software and associated documentation files (the
@@ -16,8 +16,8 @@ Gem::Specification.new do |s|
16
16
  s.files = `git ls-files`.split("\n")
17
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
- s.add_dependency "json"
20
- s.add_dependency "rest-client"
19
+ s.add_dependency "json", "1.8.0"
20
+ s.add_dependency "rest-client", "1.6.7"
21
21
  s.add_dependency "rspec", "~> 2.6.0"
22
22
  s.require_paths = ["lib"]
23
23
  end
@@ -1,54 +1,3 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- Bundler.require
4
- require 'json'
5
- require 'rest_client'
6
- require 'rspec'
7
- require 'html5_validator/rspec'
8
-
9
1
  module Html5Validator
10
- class Validator
11
- BASE_URI = 'http://html5.validator.nu'
12
- HEADERS = { 'Content-Type' => 'text/html; charset=utf-8', 'Content-Encoding' => 'UTF-8' }
13
- attr_reader :errors
14
-
15
- def initialize(proxy = nil)
16
- RestClient.proxy = proxy unless proxy.nil?
17
- end
18
-
19
- # Validate the markup of a String
20
- def validate_text(text)
21
- response = RestClient.post "#{BASE_URI}/?out=json", text, HEADERS
22
- @json = JSON.parse(response.body)
23
- @errors = retrieve_errors
24
- end
25
-
26
- # Validate the markup of a URI
27
- def validate_uri(uri)
28
- response = RestClient.get BASE_URI, :params => { :doc => uri, :out => 'json' }
29
- @json = JSON.parse(response.body)
30
- @errors = retrieve_errors
31
- end
32
-
33
- # TODO - Flesh out the file upload method
34
- # Validate the markup of a file
35
- def validate_file(file)
36
- end
37
-
38
- def inspect
39
- @errors.map do |err|
40
- "- Error: #{err['message']}"
41
- end.join("\n")
42
- end
43
-
44
- def valid?
45
- @errors.length == 0
46
- end
47
-
48
- private
49
-
50
- def retrieve_errors
51
- @json['messages'].select { |mssg| mssg['type'] == 'error' }
52
- end
53
- end
2
+ autoload :Validator, 'html5_validator/validator'
54
3
  end
@@ -1,3 +1,5 @@
1
+ require 'html5_validator/validator'
2
+
1
3
  # Assert that the response is valid HTML5
2
4
  RSpec::Matchers.define :be_valid_html5 do
3
5
  validator = nil
@@ -0,0 +1,49 @@
1
+ require 'json'
2
+ require 'rest_client'
3
+
4
+ module Html5Validator
5
+ class Validator
6
+ BASE_URI = 'http://validator.nu'
7
+ HEADERS = { 'Content-Type' => 'text/html; charset=utf-8', 'Content-Encoding' => 'UTF-8' }
8
+ attr_reader :errors
9
+
10
+ def initialize(proxy = nil)
11
+ RestClient.proxy = proxy unless proxy.nil?
12
+ end
13
+
14
+ # Validate the markup of a String
15
+ def validate_text(text)
16
+ response = RestClient.post "#{BASE_URI}/?out=json", text, HEADERS
17
+ @json = JSON.parse(response.body)
18
+ @errors = retrieve_errors
19
+ end
20
+
21
+ # Validate the markup of a URI
22
+ def validate_uri(uri)
23
+ response = RestClient.get BASE_URI, :params => { :doc => uri, :out => 'json' }
24
+ @json = JSON.parse(response.body)
25
+ @errors = retrieve_errors
26
+ end
27
+
28
+ # TODO - Flesh out the file upload method
29
+ # Validate the markup of a file
30
+ def validate_file(file)
31
+ end
32
+
33
+ def inspect
34
+ @errors.map do |err|
35
+ "- Error: #{err['message']}"
36
+ end.join("\n")
37
+ end
38
+
39
+ def valid?
40
+ @errors.length == 0
41
+ end
42
+
43
+ private
44
+
45
+ def retrieve_errors
46
+ @json['messages'].select { |mssg| mssg['type'] == 'error' }
47
+ end
48
+ end
49
+ end
@@ -1,3 +1,3 @@
1
1
  module Html5Validator
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -1,7 +1,11 @@
1
- require 'html5_validator'
1
+ require 'html5_validator/matchers'
2
+ require 'spec_helper'
3
+
4
+ describe Html5Validator::Validator do
5
+ it "should be an instance of Html5Validator::Validator" do
6
+ subject.should be_an_instance_of Html5Validator::Validator
7
+ end
2
8
 
3
- describe "Html5Validator" do
4
-
5
9
  describe "when using the custom matcher" do
6
10
  it "should not be valid html5 when supplied with invalid content" do
7
11
  @html = File.open('spec/fixtures/invalid_html.html').read
@@ -14,83 +18,69 @@ describe "Html5Validator" do
14
18
  end
15
19
  end
16
20
 
17
- before do
18
- @validator = Html5Validator::Validator.new
19
- end
20
-
21
- it "should be an instance of Html5Validator::Validator" do
22
- @validator.should be_an_instance_of Html5Validator::Validator
23
- end
24
-
25
21
  context "validating a uri" do
26
22
  describe "when supplied with an invalid url" do
27
-
28
23
  before do
29
- @validator.validate_uri('http://google.co.uk')
24
+ subject.validate_uri('http://google.co.uk')
30
25
  end
31
26
 
32
27
  it "should not be valid html5" do
33
- @validator.valid?.should be_false
28
+ subject.valid?.should be_false
34
29
  end
35
30
 
36
- it "should return thirty-nine errors" do
37
- @validator.errors.should have(39).items
31
+ it "should return at least 1 error" do
32
+ subject.should have_at_least(1).errors
38
33
  end
39
34
  end
40
35
 
41
36
  describe "when supplied with a valid url" do
42
-
43
37
  before do
44
- @validator.validate_uri('http://damiannicholson.com')
38
+ subject.validate_uri('http://damiannicholson.com')
45
39
  end
46
40
 
47
41
  it "should be valid html5" do
48
- @validator.valid?.should be_true
42
+ subject.valid?.should be_true
49
43
  end
50
44
 
51
45
  it "should return zero errors" do
52
- @validator.errors.should have(0).items
46
+ subject.errors.should have(0).items
53
47
  end
54
48
  end
55
49
  end
56
50
 
57
51
  context "validating text" do
58
52
  describe "when supplied with invalid html" do
59
-
60
53
  before do
61
54
  @html = File.open('spec/fixtures/invalid_html.html').read
62
- @validator.validate_text(@html)
55
+ subject.validate_text(@html)
63
56
  end
64
57
 
65
58
  it "should not be valid html5" do
66
- @validator.valid?.should be_false
59
+ subject.valid?.should be_false
67
60
  end
68
61
 
69
62
  it "should return two errors" do
70
- @validator.errors.should have(2).items
63
+ subject.errors.should have(2).items
71
64
  end
72
65
 
73
66
  it "should include an error complaining about the lack of a closing section tag" do
74
- @validator.inspect.should include('Unclosed element')
67
+ subject.inspect.should include('Unclosed element')
75
68
  end
76
-
77
69
  end
78
70
 
79
71
  describe "when supplied with valid html" do
80
-
81
72
  before do
82
73
  @html = File.open('spec/fixtures/valid_html.html').read
83
- @validator.validate_text(@html)
74
+ subject.validate_text(@html)
84
75
  end
85
76
 
86
77
  it "should be valid html5" do
87
- @validator.valid?.should be_true
78
+ subject.valid?.should be_true
88
79
  end
89
80
 
90
81
  it "should return no errors" do
91
- @validator.errors.should have(0).items
82
+ subject.errors.should have(0).items
92
83
  end
93
-
94
84
  end
95
85
  end
96
86
  end
@@ -0,0 +1,5 @@
1
+ RSpec.configure do |config|
2
+ config.treat_symbols_as_metadata_keys_with_true_values = true
3
+ config.run_all_when_everything_filtered = true
4
+ config.color_enabled = true
5
+ end
metadata CHANGED
@@ -1,122 +1,103 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: html5_validator
3
- version: !ruby/object:Gem::Version
4
- hash: 29
5
- prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 1
10
- version: 0.0.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Damian Nicholson
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2011-09-03 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
11
+ date: 2013-09-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
21
14
  name: json
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 3
29
- segments:
30
- - 0
31
- version: "0"
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.8.0
32
20
  type: :runtime
33
- version_requirements: *id001
34
- - !ruby/object:Gem::Dependency
35
- name: rest-client
36
21
  prerelease: false
37
- requirement: &id002 !ruby/object:Gem::Requirement
38
- none: false
39
- requirements:
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- hash: 3
43
- segments:
44
- - 0
45
- version: "0"
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.8.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rest-client
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 1.6.7
46
34
  type: :runtime
47
- version_requirements: *id002
48
- - !ruby/object:Gem::Dependency
49
- name: rspec
50
35
  prerelease: false
51
- requirement: &id003 !ruby/object:Gem::Requirement
52
- none: false
53
- requirements:
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 1.6.7
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
54
45
  - - ~>
55
- - !ruby/object:Gem::Version
56
- hash: 23
57
- segments:
58
- - 2
59
- - 6
60
- - 0
46
+ - !ruby/object:Gem::Version
61
47
  version: 2.6.0
62
48
  type: :runtime
63
- version_requirements: *id003
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 2.6.0
64
55
  description: Ruby gem to test for valid HTML5 markup with RSpec
65
- email:
56
+ email:
66
57
  - damian.nicholson21@gmail.com
67
58
  executables: []
68
-
69
59
  extensions: []
70
-
71
60
  extra_rdoc_files: []
72
-
73
- files:
61
+ files:
74
62
  - .gitignore
75
- - .rspec
76
63
  - Gemfile
77
64
  - README.rdoc
78
65
  - Rakefile
79
66
  - html5_validator.gemspec
80
67
  - lib/html5_validator.rb
81
- - lib/html5_validator/rspec.rb
68
+ - lib/html5_validator/matchers.rb
69
+ - lib/html5_validator/validator.rb
82
70
  - lib/html5_validator/version.rb
83
71
  - spec/fixtures/invalid_html.html
84
72
  - spec/fixtures/valid_html.html
85
73
  - spec/html5_validator_spec.rb
74
+ - spec/spec_helper.rb
86
75
  homepage: http://github.com/damian/html5_validator
87
76
  licenses: []
88
-
77
+ metadata: {}
89
78
  post_install_message:
90
79
  rdoc_options: []
91
-
92
- require_paths:
80
+ require_paths:
93
81
  - lib
94
- required_ruby_version: !ruby/object:Gem::Requirement
95
- none: false
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- hash: 3
100
- segments:
101
- - 0
102
- version: "0"
103
- required_rubygems_version: !ruby/object:Gem::Requirement
104
- none: false
105
- requirements:
106
- - - ">="
107
- - !ruby/object:Gem::Version
108
- hash: 3
109
- segments:
110
- - 0
111
- version: "0"
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ! '>='
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ! '>='
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
112
92
  requirements: []
113
-
114
93
  rubyforge_project: html5_validator
115
- rubygems_version: 1.8.10
94
+ rubygems_version: 2.0.6
116
95
  signing_key:
117
- specification_version: 3
96
+ specification_version: 4
118
97
  summary: Ruby gem to test for valid HTML5 markup with RSpec
119
- test_files:
98
+ test_files:
120
99
  - spec/fixtures/invalid_html.html
121
100
  - spec/fixtures/valid_html.html
122
101
  - spec/html5_validator_spec.rb
102
+ - spec/spec_helper.rb
103
+ has_rdoc:
data/.rspec DELETED
@@ -1 +0,0 @@
1
- --color