rack-valid-html 0.1 → 0.1.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/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('rack-valid-html', '0.1') do |p|
5
+ Echoe.new('rack-valid-html', '0.1.1') do |p|
6
6
  p.description = "A Rack app that runs Tidy on your html and prepends any errors to the response"
7
7
  p.url = "http://github.com/kid80/rack-validator"
8
8
  p.author = "Felix Clack"
@@ -1,33 +1,35 @@
1
1
  require 'tidy'
2
2
 
3
- class TidyResponse
3
+ module Rack
4
+ class TidyResponse
4
5
 
5
- def initialize(body)
6
- @body = body
7
- ::Tidy.path = '/usr/lib/libtidy.A.dylib'
8
- end
6
+ def initialize(body)
7
+ @body = body
8
+ ::Tidy.path = '/usr/lib/libtidy.A.dylib'
9
+ end
9
10
 
10
- def to_s
11
- tidy = Tidy.open
11
+ def to_s
12
+ tidy = Tidy.open
12
13
 
13
- tidy.clean(@body)
14
+ tidy.clean(@body)
14
15
 
15
- tidy.errors.join("<br />") + @body
16
- end
16
+ tidy.errors.join("<br />") + @body
17
+ end
17
18
 
18
- def w3c_errors
19
- response = Net::HTTP.post_form(
20
- URI.parse("http://validator.w3.org/check"),
21
- {
22
- 'ss'=>0,
23
- 'fragment'=>@body
24
- }
25
- )
26
- status = response['x-w3c-validator-status']
27
- if status != 'Valid'
28
- response.body
29
- else
30
- nil
19
+ def w3c_errors
20
+ response = Net::HTTP.post_form(
21
+ URI.parse("http://validator.w3.org/check"),
22
+ {
23
+ 'ss'=>0,
24
+ 'fragment'=>@body
25
+ }
26
+ )
27
+ status = response['x-w3c-validator-status']
28
+ if status != 'Valid'
29
+ response.body
30
+ else
31
+ nil
32
+ end
31
33
  end
32
34
  end
33
35
  end
@@ -1,4 +1,4 @@
1
- require 'lib/rack/tidy_response'
1
+ require File.expand_path('./', 'lib/rack/tidy_response')
2
2
 
3
3
  module Rack
4
4
  class Validator
@@ -10,7 +10,7 @@ module Rack
10
10
  def call(env)
11
11
  status, headers, response = @app.call(env)
12
12
 
13
- @response = response.respond_to?(:body) ? ::TidyResponse.new(response.body).to_s : response
13
+ @response = response.respond_to?(:body) ? Rack::TidyResponse.new(response.body).to_s : response
14
14
  [status, headers, @response]
15
15
  end
16
16
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{rack-valid-html}
5
- s.version = "0.1"
5
+ s.version = "0.1.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Felix Clack"]
@@ -13,8 +13,8 @@ class RackValidatorTest < Test::Unit::TestCase
13
13
  context "Rack::Validator" do
14
14
  context "with html" do
15
15
  should "pass it to TidyResponse" do
16
- ::TidyResponse.expects(:new)
17
- ::TidyResponse.any_instance.expects(:to_s)
16
+ Rack::TidyResponse.expects(:new)
17
+ Rack::TidyResponse.any_instance.expects(:to_s)
18
18
  @response = get_response(invalid_html)
19
19
  end
20
20
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-valid-html
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- version: "0.1"
9
+ - 1
10
+ version: 0.1.1
10
11
  platform: ruby
11
12
  authors:
12
13
  - Felix Clack
metadata.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
- �����@�:Vx.2�8�GSX�ҘI����"&~��<�� {2�m'���7��l���y7�'.f�"���El��Ǚ�����[o��"��������� ��!��ڵ��_�?�y��sw5�g���"��N�+�����J2�<���_���ZѲ�4��%�ѩY���
2
- F�|?�9PT2��l��߬)��P�:L_yWn�B�������b��
1
+ w7[���( ��.�
2
+ C�x���)ӂ�2lj���|w���¯`��a���1g����Y7+��p(��I�|J�&�?zӾ�Q���Y��7r�� s�?