diff --git a/lib/microformats2.rb b/lib/microformats2.rb index bbf8533..03e1ac8 100644 --- a/lib/microformats2.rb +++ b/lib/microformats2.rb @@ -1,5 +1,16 @@ +require "nokogiri" +require "open-uri" require "microformats2/version" module Microformats2 - # Your code goes here... + def self.parse(html) + html = read_html(html) + Nokogiri::HTML(html) + end + + def self.read_html(html) + open(html).read + rescue Errno::ENOENT => e + html + end end diff --git a/spec/lib/microformats2_spec.rb b/spec/lib/microformats2_spec.rb new file mode 100644 index 0000000..8e54335 --- /dev/null +++ b/spec/lib/microformats2_spec.rb @@ -0,0 +1,23 @@ +require "spec_helper" +require "microformats2" + +describe Microformats2 do + describe "::read_html" do + before do + @html = <<-HTML.strip +
Jessica Lynn Suttles
Jessica Lynn Suttles