Sha256: ae004966bb4a0ff8eba49fdd1604d692fb231c6bcd34a91e6f67e2fb8c721a39

Contents?: true

Size: 586 Bytes

Versions: 7

Compression:

Stored size: 586 Bytes

Contents

module Microformats2
  class Parser
    attr_reader :http_headers, :http_body

    def initialize
      @http_headers = {}
    end

    def parse(html, headers={})
      html = read_html(html, headers)
      document = Nokogiri::HTML(html)
      Collection.new(document).parse
    end

    def read_html(html, headers={})
      open(html, headers) do |response|
        @http_headers = response.meta if response.respond_to?(:meta)
        @http_body = response.read
      end
      @http_body
    rescue Errno::ENOENT, Errno::ENAMETOOLONG => e
      @http_body = html
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
microformats2-2.9.0 lib/microformats2/parser.rb
microformats2-2.1.0 lib/microformats2/parser.rb
microformats2-2.0.3 lib/microformats2/parser.rb
microformats2-2.0.2 lib/microformats2/parser.rb
microformats2-2.0.1 lib/microformats2/parser.rb
microformats2-2.0.0 lib/microformats2/parser.rb
microformats2-2.0.0.pre5 lib/microformats2/parser.rb