Sha256: 86c84c4f600670762f9c81867d0e5f6943feefb7bdee9b3a6b7f8c501413af20

Contents?: true

Size: 617 Bytes

Versions: 22

Compression:

Stored size: 617 Bytes

Contents

def post_file_to_w3c_validator(file_path, doc_type)
  query = MultipartPost.build_form_data(
        :uploaded_file  => File.new(file_path, 'r'),
        :charset        => '(detect automatically)',
        :doctype        => doc_type,   
        :group          => '1'
        )

  Net::HTTP.start('validator.w3.org') do |http|
    http.post2("/check", query, MultipartPost::REQ_HEADER)
  end
end

def valid_response?(w3c_response)
  html = w3c_response.read_body
  html.include? "[Valid]"
end

def w3c_valid?(file_path)
  resp = post_file_to_w3c_validator(file_path, 'HTML 4.01 Strict')
  valid_response?(resp)
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
ymdp-0.1.6 lib/ymdp/processor/w3c.rb
ymdp-0.1.4 lib/ymdp/processor/w3c.rb
ymdp-0.1.3.2 lib/ymdp/support/w3c.rb
ymdp-0.1.3.1 lib/ymdp/support/w3c.rb
ymdp-0.1.3 lib/ymdp/support/w3c.rb
ymdp-0.1.1 lib/ymdp/support/w3c.rb
ymdp-0.1.0 lib/ymdp/support/w3c.rb
ymdp-0.0.17 lib/application_view/support/w3c.rb
ymdp-0.0.16 lib/application_view/support/w3c.rb
ymdp-0.0.15 lib/application_view/support/w3c.rb
ymdp-0.0.14 lib/application_view/support/w3c.rb
ymdp-0.0.13 lib/application_view/support/w3c.rb
ymdp-0.0.12 lib/application_view/support/w3c.rb
ymdp-0.0.11 lib/application_view/support/w3c.rb
ymdp-0.0.10 lib/application_view/support/w3c.rb
ymdp-0.0.9 lib/application_view/support/w3c.rb
ymdp-0.0.8 lib/application_view/support/w3c.rb
ymdp-0.0.7 lib/application_view/support/w3c.rb
ymdp-0.0.6 lib/application_view/support/w3c.rb
ymdp-0.0.5 lib/application_view/support/w3c.rb