validator.nu 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,18 @@
1
1
  = validator.nu
2
2
 
3
- Description goes here.
3
+ ruby client library for the validator.nu HTML5 validation API
4
+
5
+ == Installation & Usage
6
+
7
+ gem install validator.nu
8
+ require 'validator.nu'
9
+ Validator.nu("http://google.com")
10
+
11
+ == Todo
12
+
13
+ * implement POST html document functionality of the API
14
+ * transmit compressed data
15
+ * output pure JSON ?
4
16
 
5
17
  == Note on Patches/Pull Requests
6
18
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -38,23 +38,27 @@ module Validator
38
38
  class RemoteException < StandardError; end;
39
39
 
40
40
  HOST = "validator.nu"
41
- PORT = 80
41
+ PORT = 80
42
42
 
43
- def nu(url_or_document)
44
- get(url_or_document)
43
+ def nu(url_or_document, options={})
44
+ get(url_or_document, options)
45
45
  end
46
46
 
47
47
 
48
- def get(url)
48
+ # TODO - some implementation notes.
49
+ # http.set_debug_output STDERR
50
+ # http.use_ssl = true if SSL
51
+ # headers = method.to_s == 'errors' ? { 'Content-Type' => 'application/x-gzip', 'Accept' => 'application/x-gzip' } : {}
52
+ # compressed_data = CGI::escape(Zlib::Deflate.deflate(data, Zlib::BEST_SPEED))
53
+ # STDERR.puts uri
54
+ def get(url, options)
49
55
  begin
50
- http = Net::HTTP.new(HOST, PORT)
51
- # http.set_debug_output STDERR
52
- # http.use_ssl = true if SSL
56
+ host = options[:host] || HOST
57
+ port = options[:port] || PORT
58
+ http = Net::HTTP.new(host, port)
59
+ STDERR.puts host
53
60
  uri = "/?&doc=#{CGI::escape(url)}&out=json"
54
- # headers = method.to_s == 'errors' ? { 'Content-Type' => 'application/x-gzip', 'Accept' => 'application/x-gzip' } : {}
55
61
 
56
- # compressed_data = CGI::escape(Zlib::Deflate.deflate(data, Zlib::BEST_SPEED))
57
- # STDERR.puts uri
58
62
  response = http.start do |http|
59
63
  http.get(uri)
60
64
  end
@@ -63,5 +63,6 @@ describe Validator do
63
63
  "http://hsivonen.iki.fi/test/moz/messages-types/fatal.xhtml"
64
64
  ).should == fixture
65
65
  end
66
+
66
67
  end
67
68
  end
@@ -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.1"
8
+ s.version = "0.0.2"
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-06}
12
+ s.date = %q{2010-04-07}
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
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
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-06 00:00:00 +01:00
17
+ date: 2010-04-07 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies: []
20
20