validator.nu 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,10 +6,11 @@ ruby client library for the validator.nu HTML5 validation API
6
6
 
7
7
  gem install validator.nu
8
8
  require 'validator.nu'
9
- Validator.nu('http://bbc.co.uk')
9
+ require 'uri'
10
+ Validator.nu(URI.parse('http://bbc.co.uk'))
10
11
 
11
12
  # If you want to use a private version of the validator.nu application
12
- Validator.nu('http://bbc.co.uk', :host => 'validator.mine.com', :port => 8808)
13
+ Validator.nu(URI.parse('http://bbc.co.uk'), :host => 'validator.mine.com', :port => 8808)
13
14
 
14
15
 
15
16
  # or you can send a document to validate to the service directly
@@ -24,6 +25,7 @@ ruby client library for the validator.nu HTML5 validation API
24
25
 
25
26
  == Todo
26
27
 
28
+ * gzip Accept-Encoding to enable gzip transport of the response from the validator.
27
29
  * output pure JSON ?
28
30
 
29
31
  == Note on Patches/Pull Requests
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -45,21 +45,14 @@ module Validator
45
45
  GZIP = false
46
46
  PORT = 80
47
47
 
48
- def nu(url_or_document, options={})
49
- begin
50
- uri = URI.parse(url_or_document)
51
-
52
- if uri.class == URI::Generic
53
- post(url_or_document, options)
54
- else
55
- get(url_or_document, options)
56
- end
57
- rescue URI::InvalidURIError
58
- post(url_or_document, options)
48
+ def nu(uri_or_document, options={})
49
+ if uri_or_document.kind_of?(URI::HTTP)
50
+ get(uri_or_document, options)
51
+ else
52
+ post(uri_or_document, options)
59
53
  end
60
54
  end
61
55
 
62
-
63
56
  # TODO - some implementation notes.
64
57
  # http.set_debug_output STDERR
65
58
  # http.use_ssl = true if SSL
@@ -71,7 +64,7 @@ module Validator
71
64
  host = options[:host] || HOST
72
65
  port = options[:port] || PORT
73
66
  http = Net::HTTP.new(host, port)
74
- uri = "/?&doc=#{CGI::escape(url)}&out=json"
67
+ uri = "/?&doc=#{CGI::escape(url.to_s)}&out=json"
75
68
 
76
69
  response = http.start do |http|
77
70
  http.get(uri)
@@ -10,7 +10,7 @@ describe Validator do
10
10
  fixture = File.open("#{File.dirname(__FILE__)}/fixtures/no-message.json").read
11
11
 
12
12
  Validator.nu(
13
- "http://hsivonen.iki.fi/test/moz/messages-types/no-message.html"
13
+ URI.parse("http://hsivonen.iki.fi/test/moz/messages-types/no-message.html")
14
14
  ).should == fixture
15
15
  end
16
16
 
@@ -20,7 +20,7 @@ describe Validator do
20
20
 
21
21
 
22
22
  Validator.nu(
23
- "http://hsivonen.iki.fi/test/moz/messages-types/info.svg"
23
+ URI.parse("http://hsivonen.iki.fi/test/moz/messages-types/info.svg")
24
24
  ).should == fixture
25
25
  end
26
26
 
@@ -29,7 +29,7 @@ describe Validator do
29
29
 
30
30
 
31
31
  Validator.nu(
32
- "http://hsivonen.iki.fi/test/moz/messages-types/warning.html"
32
+ URI.parse("http://hsivonen.iki.fi/test/moz/messages-types/warning.html")
33
33
  ).should == fixture
34
34
  end
35
35
 
@@ -38,7 +38,7 @@ describe Validator do
38
38
 
39
39
 
40
40
  Validator.nu(
41
- "http://hsivonen.iki.fi/test/moz/messages-types/404.html"
41
+ URI.parse("http://hsivonen.iki.fi/test/moz/messages-types/404.html")
42
42
  ).should == fixture
43
43
  end
44
44
 
@@ -46,21 +46,21 @@ describe Validator do
46
46
  fixture = File.open("#{File.dirname(__FILE__)}/fixtures/precise-error.json").read
47
47
 
48
48
  Validator.nu(
49
- "http://hsivonen.iki.fi/test/moz/messages-types/precise-error.html"
49
+ URI.parse("http://hsivonen.iki.fi/test/moz/messages-types/precise-error.html")
50
50
  ).should == fixture
51
51
  end
52
52
 
53
53
  it "should receive a range error result" do
54
54
  fixture = File.open("#{File.dirname(__FILE__)}/fixtures/range-error.json").read
55
55
  Validator.nu(
56
- "http://hsivonen.iki.fi/test/moz/messages-types/range-error.html"
56
+ URI.parse("http://hsivonen.iki.fi/test/moz/messages-types/range-error.html")
57
57
  ).should == fixture
58
58
  end
59
59
 
60
60
  it "should receive a fatal error result" do
61
61
  fixture = File.open("#{File.dirname(__FILE__)}/fixtures/fatal-error.json").read
62
62
  Validator.nu(
63
- "http://hsivonen.iki.fi/test/moz/messages-types/fatal.xhtml"
63
+ URI.parse("http://hsivonen.iki.fi/test/moz/messages-types/fatal.xhtml")
64
64
  ).should == fixture
65
65
  end
66
66
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{validator.nu}
8
- s.version = "0.0.3"
8
+ s.version = "0.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["David Rice"]
12
- s.date = %q{2010-04-15}
12
+ s.date = %q{2010-04-16}
13
13
  s.description = %q{ruby client library for the validator.nu HTML5 validation API}
14
14
  s.email = %q{me@davidjrice.co.uk}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 3
9
- version: 0.0.3
8
+ - 4
9
+ version: 0.0.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - David Rice
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-04-15 00:00:00 +01:00
17
+ date: 2010-04-16 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies: []
20
20