diff --git a/Rakefile b/Rakefile
index 2995527..4d0bc70 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1 +1,44 @@
require "bundler/gem_tasks"
+require "nokogiri"
+require "open-uri"
+require "pp"
+
+task :update_spec_cases do
+ sources = [
+ { urls: ["http://microformats.org/wiki/microformats-2"],
+ html_selector: ".source-html4strict",
+ json_selector: ".source-javascript",
+ html_method: "inner_text"
+ },
+ { urls: ["http://microformat2-node.jit.su/h-adr.html"],
+ html_selector: ".e-x-microformat",
+ json_selector: ".language-json",
+ html_method: "inner_html"
+ }
+ ]
+
+ sources.each do |source|
+ source[:urls].each do |url|
+ document = Nokogiri::HTML(open(url).read)
+ html = document.css(source[:html_selector]).map { |e| e.send(source[:html_method]) }
+ json = document.css(source[:json_selector]).map { |e| e.inner_text }
+
+ filename = url.split("/").last.gsub(/[.]\w+/, "")
+ filepath = "spec/support/cases/"
+
+ ([html.length, json.length].min).times do |index|
+
+ File.open("#{filepath}#{filename}-#{index}.html", "w") do |f|
+ f.write "\n"
+ f.write html[index]
+ end
+
+ File.open("#{filepath}#{filename}-#{index}.js", "w") do |f|
+ f.write "// #{url}\n"
+ f.write json[index]
+ end
+ end
+
+ end
+ end
+end
diff --git a/spec/support/cases/h-adr-0.html b/spec/support/cases/h-adr-0.html
new file mode 100644
index 0000000..0bbac88
--- /dev/null
+++ b/spec/support/cases/h-adr-0.html
@@ -0,0 +1,3 @@
+
+
+
665 3rd St. Suite 207 San Francisco, CA 94107 U.S.A.
diff --git a/spec/support/cases/h-adr-0.js b/spec/support/cases/h-adr-0.js
new file mode 100644
index 0000000..cc74c4f
--- /dev/null
+++ b/spec/support/cases/h-adr-0.js
@@ -0,0 +1,10 @@
+// http://microformat2-node.jit.su/h-adr.html
+
+{
+ "items": [{
+ "type": ["h-adr"],
+ "properties": {
+ "name": ["665 3rd St. Suite 207 San Francisco, CA 94107 U.S.A."]
+ }
+ }]
+}
diff --git a/spec/support/cases/h-adr-1.html b/spec/support/cases/h-adr-1.html
new file mode 100644
index 0000000..03cd52d
--- /dev/null
+++ b/spec/support/cases/h-adr-1.html
@@ -0,0 +1,10 @@
+
+
+
+ 665 3rd St.
+ Suite 207
+ San Francisco,
+ CA
+ 94107
+ U.S.A.
+
diff --git a/spec/support/cases/h-adr-1.js b/spec/support/cases/h-adr-1.js
new file mode 100644
index 0000000..4ae31dc
--- /dev/null
+++ b/spec/support/cases/h-adr-1.js
@@ -0,0 +1,16 @@
+// http://microformat2-node.jit.su/h-adr.html
+
+{
+ "items": [{
+ "type": ["h-adr"],
+ "properties": {
+ "street-address": ["665 3rd St."],
+ "extended-address": ["Suite 207"],
+ "locality": ["San Francisco"],
+ "region": ["CA"],
+ "postal-code": ["94107"],
+ "country-name": ["U.S.A."],
+ "name": ["665 3rd St. Suite 207 San Francisco, CA 94107 U.S.A."]
+ }
+ }]
+}
diff --git a/spec/support/cases/h-adr-2.html b/spec/support/cases/h-adr-2.html
new file mode 100644
index 0000000..5c29bb8
--- /dev/null
+++ b/spec/support/cases/h-adr-2.html
@@ -0,0 +1,12 @@
+
+
+
+ Bricklayer's Arms
+
+ 3 Charlotte Road,
+ City of London,
+ EC2A 3PE,
+ UK
+ –
+ Geo:(51.526421;-0.081067)
+
diff --git a/spec/support/cases/h-adr-2.js b/spec/support/cases/h-adr-2.js
new file mode 100644
index 0000000..ad127bd
--- /dev/null
+++ b/spec/support/cases/h-adr-2.js
@@ -0,0 +1,16 @@
+// http://microformat2-node.jit.su/h-adr.html
+
+{
+ "items": [{
+ "type": ["h-adr"],
+ "properties": {
+ "name": ["Bricklayer's Arms"],
+ "label": ["3 Charlotte Road, City of London, EC2A 3PE, UK"],
+ "street-address": ["3 Charlotte Road"],
+ "locality": ["City of London"],
+ "postal-code": ["EC2A 3PE"],
+ "country-name": ["UK"],
+ "geo": ["51.526421;-0.081067"]
+ }
+ }]
+}
diff --git a/spec/support/cases/h-adr-3.html b/spec/support/cases/h-adr-3.html
new file mode 100644
index 0000000..a41a7bd
--- /dev/null
+++ b/spec/support/cases/h-adr-3.html
@@ -0,0 +1,6 @@
+
+
+
+ Bricklayer's Arms,
+ London
+
diff --git a/spec/support/cases/h-adr-3.js b/spec/support/cases/h-adr-3.js
new file mode 100644
index 0000000..bacb02f
--- /dev/null
+++ b/spec/support/cases/h-adr-3.js
@@ -0,0 +1,12 @@
+// http://microformat2-node.jit.su/h-adr.html
+
+{
+ "items": [{
+ "type": ["h-adr"],
+ "properties": {
+ "name": ["Bricklayer's Arms"],
+ "geo": ["geo:51.526421;-0.081067;crs=wgs84;u=40"],
+ "locality": ["London"]
+ }
+ }]
+}
diff --git a/spec/support/cases/microformats-2-0.html b/spec/support/cases/microformats-2-0.html
new file mode 100644
index 0000000..8b05a7c
--- /dev/null
+++ b/spec/support/cases/microformats-2-0.html
@@ -0,0 +1,2 @@
+
+Frances Berriman
\ No newline at end of file
diff --git a/spec/support/cases/microformats-2-0.js b/spec/support/cases/microformats-2-0.js
new file mode 100644
index 0000000..9056a82
--- /dev/null
+++ b/spec/support/cases/microformats-2-0.js
@@ -0,0 +1,9 @@
+// http://microformats.org/wiki/microformats-2
+{
+ "items": [{
+ "type": ["h-card"],
+ "properties": {
+ "name": ["Frances Berriman"]
+ }
+ }]
+}
\ No newline at end of file
diff --git a/spec/support/cases/microformats-2-1.html b/spec/support/cases/microformats-2-1.html
new file mode 100644
index 0000000..c2a65ad
--- /dev/null
+++ b/spec/support/cases/microformats-2-1.html
@@ -0,0 +1,2 @@
+
+Ben Ward
\ No newline at end of file
diff --git a/spec/support/cases/microformats-2-1.js b/spec/support/cases/microformats-2-1.js
new file mode 100644
index 0000000..36b9b43
--- /dev/null
+++ b/spec/support/cases/microformats-2-1.js
@@ -0,0 +1,10 @@
+// http://microformats.org/wiki/microformats-2
+{
+ "items": [{
+ "type": ["h-card"],
+ "properties": {
+ "name": ["Ben Ward"],
+ "url": ["http://benward.me"]
+ }
+ }]
+}
\ No newline at end of file
diff --git a/spec/support/cases/microformats-2-2.html b/spec/support/cases/microformats-2-2.html
new file mode 100644
index 0000000..520b5f4
--- /dev/null
+++ b/spec/support/cases/microformats-2-2.html
@@ -0,0 +1,5 @@
+
+
+
+
\ No newline at end of file
diff --git a/spec/support/cases/microformats-2-2.js b/spec/support/cases/microformats-2-2.js
new file mode 100644
index 0000000..cd00683
--- /dev/null
+++ b/spec/support/cases/microformats-2-2.js
@@ -0,0 +1,11 @@
+// http://microformats.org/wiki/microformats-2
+{
+ "items": [{
+ "type": ["h-card"],
+ "properties": {
+ "name": ["Rohit Khare"],
+ "url": ["http://rohit.khare.org"],
+ "photo": ["https://s3.amazonaws.com/twitter_production/profile_images/53307499/180px-Rohit-sq_bigger.jpg"]
+ }
+ }]
+}
\ No newline at end of file
diff --git a/spec/support/cases/microformats-2-3.html b/spec/support/cases/microformats-2-3.html
new file mode 100644
index 0000000..be49408
--- /dev/null
+++ b/spec/support/cases/microformats-2-3.html
@@ -0,0 +1,17 @@
+
+
+

+
Mitchell Baker
+ (
@MitchellBaker)
+
Mozilla Foundation
+
+ Mitchell is responsible for setting the direction and scope of the Mozilla Foundation and its activities.
+
+
Strategy
+
Leadership
+
\ No newline at end of file
diff --git a/spec/support/cases/microformats-2-3.js b/spec/support/cases/microformats-2-3.js
new file mode 100644
index 0000000..cb16f5d
--- /dev/null
+++ b/spec/support/cases/microformats-2-3.js
@@ -0,0 +1,20 @@
+// http://microformats.org/wiki/microformats-2
+{
+ "items": [{
+ "type": ["h-card"],
+ "properties": {
+ "photo": ["https://webfwd.org/content/about-experts/300.mitchellbaker/mentor_mbaker.jpg"],
+ "name": ["Mitchell Baker"],
+ "url": [
+ "http://blog.lizardwrangler.com/",
+ "https://twitter.com/MitchellBaker"
+ ],
+ "org": ["Mozilla Foundation"],
+ "note": ["Mitchell is responsible for setting the direction and scope of the Mozilla Foundation and its activities."],
+ "category": [
+ "Strategy",
+ "Leadership"
+ ]
+ }
+ }]
+}
\ No newline at end of file
diff --git a/spec/support/cases/microformats-2-4.html b/spec/support/cases/microformats-2-4.html
new file mode 100644
index 0000000..0325007
--- /dev/null
+++ b/spec/support/cases/microformats-2-4.html
@@ -0,0 +1,16 @@
+
+
\ No newline at end of file
diff --git a/spec/support/cases/microformats-2-4.js b/spec/support/cases/microformats-2-4.js
new file mode 100644
index 0000000..5d0276f
--- /dev/null
+++ b/spec/support/cases/microformats-2-4.js
@@ -0,0 +1,24 @@
+// http://microformats.org/wiki/microformats-2
+{
+ "items": [{
+ "type": ["h-event"],
+ "properties": {
+ "name": ["IndieWebCamp 2012"],
+ "url": ["http://indiewebcamp.com/2012"],
+ "start": ["2012-06-30"],
+ "end": ["2012-07-01"],
+ "location": [{
+ "value": "Geoloqi, 920 SW 3rd Ave. Suite 400, Portland, OR",
+ "type": ["h-card"],
+ "properties": {
+ "name": ["Geoloqi"],
+ "org": ["Geoloqi"],
+ "url": ["http://geoloqi.com/"],
+ "street-address": ["920 SW 3rd Ave. Suite 400"],
+ "locality": ["Portland"],
+ "region": ["Oregon"]
+ }
+ }]
+ }
+ }]
+}
\ No newline at end of file
diff --git a/spec/support/cases/microformats-2-5.html b/spec/support/cases/microformats-2-5.html
new file mode 100644
index 0000000..1460f97
--- /dev/null
+++ b/spec/support/cases/microformats-2-5.html
@@ -0,0 +1,7 @@
+
+
\ No newline at end of file
diff --git a/spec/support/cases/microformats-2-5.js b/spec/support/cases/microformats-2-5.js
new file mode 100644
index 0000000..7cf9458
--- /dev/null
+++ b/spec/support/cases/microformats-2-5.js
@@ -0,0 +1,11 @@
+// http://microformats.org/wiki/microformats-2
+{
+ "items": [{
+ "type": ["h-card"],
+ "properties": {
+ "name": ["Mitchell Baker"],
+ "url": ["http://blog.lizardwrangler.com/"],
+ "org": ["Mozilla Foundation"]
+ }
+ }]
+}
\ No newline at end of file
diff --git a/spec/support/cases/microformats-2-6.html b/spec/support/cases/microformats-2-6.html
new file mode 100644
index 0000000..cacd398
--- /dev/null
+++ b/spec/support/cases/microformats-2-6.html
@@ -0,0 +1,9 @@
+
+
\ No newline at end of file
diff --git a/spec/support/cases/microformats-2-6.js b/spec/support/cases/microformats-2-6.js
new file mode 100644
index 0000000..6865969
--- /dev/null
+++ b/spec/support/cases/microformats-2-6.js
@@ -0,0 +1,18 @@
+// http://microformats.org/wiki/microformats-2
+{
+ "items": [{
+ "type": ["h-card"],
+ "properties": {
+ "name": ["Mitchell Baker"],
+ "url": ["http://blog.lizardwrangler.com/"],
+ "org": [{
+ "value": "Mozilla Foundation",
+ "type": ["h-card"],
+ "properties": {
+ "name": ["Mozilla Foundation"],
+ "url": ["http://mozilla.org/"]
+ }
+ }]
+ }
+ }]
+}
\ No newline at end of file
diff --git a/spec/support/cases/microformats-2-7.html b/spec/support/cases/microformats-2-7.html
new file mode 100644
index 0000000..00e6951
--- /dev/null
+++ b/spec/support/cases/microformats-2-7.html
@@ -0,0 +1,9 @@
+
+
\ No newline at end of file
diff --git a/spec/support/cases/microformats-2-7.js b/spec/support/cases/microformats-2-7.js
new file mode 100644
index 0000000..633d466
--- /dev/null
+++ b/spec/support/cases/microformats-2-7.js
@@ -0,0 +1,18 @@
+// http://microformats.org/wiki/microformats-2
+{
+ "items": [{
+ "type": ["h-card"],
+ "properties": {
+ "name": ["Mitchell Baker"],
+ "url": ["http://blog.lizardwrangler.com/"],
+ "org": [{
+ "value": "Mozilla Foundation",
+ "type": ["h-card", "h-org"],
+ "properties": {
+ "name": ["Mozilla Foundation"],
+ "url": ["http://mozilla.org/"]
+ }
+ }]
+ }
+ }]
+}
\ No newline at end of file
diff --git a/spec/support/cases/microformats-2-8.html b/spec/support/cases/microformats-2-8.html
new file mode 100644
index 0000000..ccf3c58
--- /dev/null
+++ b/spec/support/cases/microformats-2-8.html
@@ -0,0 +1,9 @@
+
+
\ No newline at end of file
diff --git a/spec/support/cases/microformats-2-8.js b/spec/support/cases/microformats-2-8.js
new file mode 100644
index 0000000..7a6189a
--- /dev/null
+++ b/spec/support/cases/microformats-2-8.js
@@ -0,0 +1,17 @@
+// http://microformats.org/wiki/microformats-2
+{
+ "items": [{
+ "type": ["h-card"],
+ "properties": {
+ "name": ["Mitchell Baker"],
+ "url": ["http://blog.lizardwrangler.com/"]
+ },
+ "children": [{
+ "type": ["h-card","h-org"],
+ "properties": {
+ "name": ["Mozilla Foundation"],
+ "url": ["http://mozilla.org/"]
+ }
+ }]
+ }]
+}
\ No newline at end of file
diff --git a/spec/support/cases/microformats-2-9.html b/spec/support/cases/microformats-2-9.html
new file mode 100644
index 0000000..4afe112
--- /dev/null
+++ b/spec/support/cases/microformats-2-9.html
@@ -0,0 +1,9 @@
+
+
\ No newline at end of file
diff --git a/spec/support/cases/microformats-2-9.js b/spec/support/cases/microformats-2-9.js
new file mode 100644
index 0000000..469f247
--- /dev/null
+++ b/spec/support/cases/microformats-2-9.js
@@ -0,0 +1,17 @@
+// http://microformats.org/wiki/microformats-2
+{
+ "items": [{
+ "type": ["h-card"],
+ "properties": {
+ "name": ["Mitchell Baker"],
+ "url": ["http://blog.lizardwrangler.com/"]
+ },
+ "children": [{
+ "type": ["h-card"],
+ "properties": {
+ "name": ["Mozilla Foundation"],
+ "url": ["http://mozilla.org/"]
+ }
+ }]
+ }]
+}
\ No newline at end of file