readme and version bump

This commit is contained in:
Shane Becker 2011-06-28 21:16:21 -07:00
parent 06d175b525
commit c8123de14b
4 changed files with 28 additions and 21 deletions

View file

@ -14,7 +14,7 @@ Generic Microformats 2 Extractor
## SYNOPSIS ## SYNOPSIS
Microformats2.parse(File.open("http://iamshane.html")) Microformats2.parse(File.open("example.html"))
## REQUIREMENTS ## REQUIREMENTS
@ -36,6 +36,6 @@ run the tests/specs, and generate the RDoc.
## LICENSE ## LICENSE
PUBLIC DOMAIN. **PUBLIC DOMAIN.**
Your heart is as free as the air you breathe. Your heart is as free as the air you breathe.
The ground you stand on is liberated territory. The ground you stand on is liberated territory.

View file

@ -6,6 +6,7 @@ require 'hoe'
Hoe.spec 'microformats2' do Hoe.spec 'microformats2' do
developer('Shane Becker', 'veganstraightedge@gmail.com') developer('Shane Becker', 'veganstraightedge@gmail.com')
extra_deps << ['nokogiri', ">= 0"] extra_deps << ['nokogiri', ">= 0"]
self.readme_file = "README.md"
end end

View file

@ -3,7 +3,7 @@ require 'time'
require 'date' require 'date'
module Microformats2 module Microformats2
VERSION = "1.0.0" VERSION = "1.0.1"
class LoadError < StandardError; end class LoadError < StandardError; end

View file

@ -7,12 +7,12 @@ class TestMicroformats2 < Test::Unit::TestCase
Microformats2.parse(nil) Microformats2.parse(nil)
end end
end end
def test_returns_hash_of_microformat_objects def test_returns_hash_of_microformat_objects
result = Microformats2.parse("A String") result = Microformats2.parse("A String")
assert_equal Hash, result.class assert_equal Hash, result.class
end end
def test_only_parse_microformats def test_only_parse_microformats
result = Microformats2.parse("<html><body><p>Something</p></body></html>") result = Microformats2.parse("<html><body><p>Something</p></body></html>")
assert_equal 0, result.size assert_equal 0, result.size
@ -23,19 +23,25 @@ class TestMicroformats2 < Test::Unit::TestCase
assert_equal HCard, result[:hcard].first.class assert_equal HCard, result[:hcard].first.class
assert_equal 2, result[:hcard].length assert_equal 2, result[:hcard].length
end end
def test_extracts_name_from_tag_with_multiple_classes def test_extracts_name_from_tag_with_multiple_classes
result = Microformats2.parse(File.open(File.join(File.dirname(__FILE__), "simple.html"))) result = Microformats2.parse(File.open(File.join(File.dirname(__FILE__), "simple.html")))
assert_equal "Chris", result[:hcard].first.given_name assert_equal "Chris", result[:hcard].first.given_name
end end
def test_extracts_hcalendar_from_an_html_file
result = Microformats2.parse(File.open(File.join(File.dirname(__FILE__), "IndieWebCamp.html")))
assert_equal 1, result[:hevent].length
assert result[:hcard].map { |h| h.name }.include?("Urban Airship")
end
def test_extracts_hcard_from_html def test_extracts_hcard_from_html
hcard = <<-END hcard = <<-END
<html> <html>
<head> <head>
<title>Simple hCard</title> <title>Simple hCard</title>
</head> </head>
<body> <body>
<h1 class="h-card">Chris</h1> <h1 class="h-card">Chris</h1>
</body> </body>
@ -44,14 +50,14 @@ class TestMicroformats2 < Test::Unit::TestCase
result = Microformats2.parse(hcard) result = Microformats2.parse(hcard)
assert_equal HCard, result[:hcard].first.class assert_equal HCard, result[:hcard].first.class
end end
def test_constructs_properties_from_hcard def test_constructs_properties_from_hcard
hcard = <<-END hcard = <<-END
<html> <html>
<head> <head>
<title>Simple hCard</title> <title>Simple hCard</title>
</head> </head>
<body> <body>
<h1 class="h-card"> <h1 class="h-card">
<a class="p-fn u-url" href="http://factoryjoe.com/"> <a class="p-fn u-url" href="http://factoryjoe.com/">
@ -65,20 +71,20 @@ class TestMicroformats2 < Test::Unit::TestCase
END END
result = Microformats2.parse(hcard) result = Microformats2.parse(hcard)
mycard = result[:hcard].first mycard = result[:hcard].first
assert_equal "Chris", mycard.given_name assert_equal "Chris", mycard.given_name
assert_equal "R.", mycard.additional_name assert_equal "R.", mycard.additional_name
assert_equal "Messina", mycard.family_name assert_equal "Messina", mycard.family_name
assert_equal "Chris R. Messina", mycard.fn assert_equal "Chris R. Messina", mycard.fn
end end
def test_constructs_dates def test_constructs_dates
hcard = <<-END hcard = <<-END
<html> <html>
<head> <head>
<title>Simple hCard</title> <title>Simple hCard</title>
</head> </head>
<body> <body>
<h1 class="h-card"> <h1 class="h-card">
<span class="d-bday">1979-09-18</span> <span class="d-bday">1979-09-18</span>
@ -89,18 +95,18 @@ class TestMicroformats2 < Test::Unit::TestCase
END END
result = Microformats2.parse(hcard) result = Microformats2.parse(hcard)
mycard = result[:hcard].first mycard = result[:hcard].first
assert_equal DateTime.parse("1979-09-18"), mycard.bday assert_equal DateTime.parse("1979-09-18"), mycard.bday
assert_equal DateTime.parse("1970-01-01"), mycard.epoch assert_equal DateTime.parse("1970-01-01"), mycard.epoch
end end
def test_constructs_times def test_constructs_times
hcard = <<-END hcard = <<-END
<html> <html>
<head> <head>
<title>Simple hCard</title> <title>Simple hCard</title>
</head> </head>
<body> <body>
<h1 class="h-card"> <h1 class="h-card">
<span class="t-start">09:30</span> <span class="t-start">09:30</span>
@ -111,18 +117,18 @@ class TestMicroformats2 < Test::Unit::TestCase
END END
result = Microformats2.parse(hcard) result = Microformats2.parse(hcard)
mycard = result[:hcard].first mycard = result[:hcard].first
assert_equal Time.parse("09:30"), mycard.start assert_equal Time.parse("09:30"), mycard.start
assert_equal Time.parse("06:00"), mycard.end assert_equal Time.parse("06:00"), mycard.end
end end
def test_ignores_pattern_matches_not_at_the_beginning_of_class def test_ignores_pattern_matches_not_at_the_beginning_of_class
hcard = <<-END hcard = <<-END
<html> <html>
<head> <head>
<title>Simple hCard</title> <title>Simple hCard</title>
</head> </head>
<body> <body>
<h1 class="h-card"> <h1 class="h-card">
<span class="p-n-x">Chris</span> <span class="p-n-x">Chris</span>
@ -132,18 +138,18 @@ class TestMicroformats2 < Test::Unit::TestCase
END END
result = Microformats2.parse(hcard) result = Microformats2.parse(hcard)
mycard = result[:hcard].first mycard = result[:hcard].first
assert_equal "Chris", mycard.n_x assert_equal "Chris", mycard.n_x
assert mycard.n_x.is_a?(String) assert mycard.n_x.is_a?(String)
end end
def test_constructs_urls_from_hcard def test_constructs_urls_from_hcard
hcard = <<-END hcard = <<-END
<html> <html>
<head> <head>
<title>Simple hCard</title> <title>Simple hCard</title>
</head> </head>
<body> <body>
<h1 class="h-card"> <h1 class="h-card">
<a class="p-fn u-url" href="http://factoryjoe.com/">Chris</a> <a class="p-fn u-url" href="http://factoryjoe.com/">Chris</a>