mofo 0.2.6 → 0.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +3 -0
- data/Rakefile +3 -10
- data/lib/microformat.rb +14 -3
- data/lib/mofo/hentry.rb +1 -1
- data/site/index.html +6 -4
- data/test/ext_test.rb +11 -0
- data/test/subclass_test.rb +34 -0
- metadata +3 -2
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rake'
|
3
3
|
|
4
|
-
version = '0.2.
|
5
|
-
|
4
|
+
version = '0.2.8'
|
5
|
+
|
6
|
+
ENV['RUBY_FLAGS'] = ""
|
6
7
|
|
7
8
|
begin
|
8
9
|
require 'echoe'
|
@@ -22,11 +23,3 @@ rescue LoadError => boom
|
|
22
23
|
puts "You are missing a dependency required for meta-operations on this gem."
|
23
24
|
puts "#{boom.to_s.capitalize}."
|
24
25
|
end
|
25
|
-
|
26
|
-
desc "Tag the current trunk with the current release version"
|
27
|
-
task :tag do
|
28
|
-
warn "WARNING: this will tag #{svn_repo}/trunk using the tag REL_#{version.gsub!('.','_')}"
|
29
|
-
warn "If you do not wish to continue, you have 5 seconds to cancel by pressing CTRL-C..."
|
30
|
-
5.times { |i| print "#{5-i} "; $stdout.flush; sleep 1 }
|
31
|
-
system %[svn copy #{svn_repo}/trunk #{svn_repo}/tags/REL_#{version} -m "Tagging the #{version} release"]
|
32
|
-
end
|
data/lib/microformat.rb
CHANGED
@@ -4,6 +4,7 @@ gem 'hpricot', '>=0.4.59'
|
|
4
4
|
class Microformat
|
5
5
|
module Base
|
6
6
|
@@subclasses = Set.new
|
7
|
+
@@timeout = 5
|
7
8
|
|
8
9
|
##
|
9
10
|
# The Gateway
|
@@ -58,6 +59,10 @@ class Microformat
|
|
58
59
|
end
|
59
60
|
end
|
60
61
|
|
62
|
+
def timeout=(timeout)
|
63
|
+
@@timeout = timeout
|
64
|
+
end
|
65
|
+
|
61
66
|
protected
|
62
67
|
##
|
63
68
|
# DSL Related
|
@@ -72,8 +77,11 @@ class Microformat
|
|
72
77
|
def inherited(klass)
|
73
78
|
@@subclasses << klass
|
74
79
|
define_cute_class_name(klass)
|
75
|
-
|
76
|
-
klass.
|
80
|
+
current_container = @container
|
81
|
+
klass.class_eval do
|
82
|
+
@container = current_container || name.downcase
|
83
|
+
@attributes = Hash.new { |h,k| h[k] = [] }
|
84
|
+
end
|
77
85
|
end
|
78
86
|
|
79
87
|
def define_cute_class_name(klass)
|
@@ -130,7 +138,7 @@ class Microformat
|
|
130
138
|
case source
|
131
139
|
when String, File, StringIO
|
132
140
|
result = ''
|
133
|
-
Timeout
|
141
|
+
Timeout.timeout(@@timeout) { result = open(source) }
|
134
142
|
Hpricot(result)
|
135
143
|
when Hpricot, Hpricot::Elements
|
136
144
|
source
|
@@ -304,6 +312,9 @@ end
|
|
304
312
|
class InvalidMicroformat < Exception; end
|
305
313
|
class MicroformatNotFound < Exception; end
|
306
314
|
|
315
|
+
# oh what the hell, let's do it
|
316
|
+
Mofo = Microformat
|
317
|
+
|
307
318
|
# type & id are used a lot in uformats and deprecated in ruby. no loss.
|
308
319
|
OpenStruct.class_eval { undef :type, :id }
|
309
320
|
Symbol.class_eval { def no_bang() to_s.sub('!','').to_sym end }
|
data/lib/mofo/hentry.rb
CHANGED
data/site/index.html
CHANGED
@@ -22,6 +22,7 @@
|
|
22
22
|
<h3>mofo</h3>
|
23
23
|
|
24
24
|
<ul class="xoxo">
|
25
|
+
<!-- <li><a href="/try">Try It!</a></li> -->
|
25
26
|
<li><a href="#" onclick="sc('get_started')">Get Started</a></li>
|
26
27
|
<li><a href="#" onclick="sc('microwhozit')">Microwhozit?</a></li>
|
27
28
|
<li><a href="#" onclick="sc('find')">Mofo#find</a></li>
|
@@ -363,16 +364,17 @@ $ ./script/plugin install -x svn://errtheblog.com/svn/projects/mofo
|
|
363
364
|
<h3 id="touch">Get in Touch</h3>
|
364
365
|
|
365
366
|
<ul>
|
366
|
-
<li>
|
367
|
-
<li>
|
368
|
-
<li>
|
367
|
+
<li><strong>Google Group:</strong> <a href="http://groups.google.com/group/mofo-rb">http://groups.google.com/group/mofo-rb</a></li>
|
368
|
+
<li><strong>Me:</strong> chris[at]ozmm[dot]org (chris wanstrath)</li>
|
369
|
+
<li><strong>Trac:</strong> <a href="http://require.errtheblog.com/projects/browser/mofo">http://require.errtheblog.com/projects/browser/mofo</a></li>
|
370
|
+
<li><strong>SVN:</strong> svn://errtheblog.com/svn/projects/mofo</li>
|
369
371
|
</ul>
|
370
372
|
</div>
|
371
373
|
|
372
374
|
<div id="footer">
|
373
375
|
<hr />
|
374
376
|
<p class="left">| <a href="http://jigsaw.w3.org/css-validator/">CSS</a> | <a href="http://validator.w3.org/check?uri=referer">XHTML 1.1</a> |</p>
|
375
|
-
<p class="right">Designed by <a href="mailto:support@syndicateme.net">syndicateme.net</a>.
|
377
|
+
<p class="right">Designed by <a href="mailto:support@syndicateme.net">syndicateme.net</a>. Logo'd by <a href="http://seaofclouds.com/">seaofclouds</a>. Hosted by <a href="http://rubyforge.org">Rubyforge</a>. Birthed by <a href="http://errtheblog.com">Err</a>.</p>
|
376
378
|
<p> </p>
|
377
379
|
</div>
|
378
380
|
</div>
|
data/test/ext_test.rb
CHANGED
@@ -67,3 +67,14 @@ context "Searching a page with multiple uformats using Microformat.find" do
|
|
67
67
|
classes.should.include HCard
|
68
68
|
end
|
69
69
|
end
|
70
|
+
|
71
|
+
context "Mofo's timeout duration" do
|
72
|
+
specify "should be alterable" do
|
73
|
+
Timeout.expects(:timeout).at_least_once.with(5)
|
74
|
+
Microformat.find('random_file.html')
|
75
|
+
|
76
|
+
Microformat.timeout = 11
|
77
|
+
Timeout.expects(:timeout).at_least_once.with(11)
|
78
|
+
Microformat.find('random_file.html')
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
require 'mofo/hcard'
|
3
|
+
|
4
|
+
module Formats
|
5
|
+
class Card < HCard
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
context "Subclassing an hCard" do
|
10
|
+
specify "should parse a page with an hcard" do
|
11
|
+
proc { Formats::Card.find(fixture(:fauxtank)) }.should.not.raise MicroformatNotFound
|
12
|
+
end
|
13
|
+
|
14
|
+
specify "should raise an error if no hcard is found in strict mode" do
|
15
|
+
proc { Formats::Card.find(fixture(:fake), :strict => true) }.should.raise MicroformatNotFound
|
16
|
+
end
|
17
|
+
|
18
|
+
specify "should return an empty array if no hcard is found" do
|
19
|
+
Formats::Card.find(fixture(:fake)).should.equal []
|
20
|
+
end
|
21
|
+
|
22
|
+
specify "should return nil if no hcard is found with :first" do
|
23
|
+
Formats::Card.find(:first => fixture(:fake)).should.equal nil
|
24
|
+
end
|
25
|
+
|
26
|
+
specify "should return nil if no hcard is found with :all" do
|
27
|
+
Formats::Card.find(:all => fixture(:fake)).should.equal []
|
28
|
+
end
|
29
|
+
|
30
|
+
specify "should accept a :text option" do
|
31
|
+
Formats::Card.find(:text => open(fixture(:fauxtank)).read).should.not.equal []
|
32
|
+
Formats::Card.find(:text => open(fixture(:fauxtank)).read).should.not.equal nil
|
33
|
+
end
|
34
|
+
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
3
3
|
specification_version: 1
|
4
4
|
name: mofo
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.2.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.2.8
|
7
|
+
date: 2007-08-03 00:00:00 -07:00
|
8
8
|
summary: mofo is a ruby microformat parser
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -94,6 +94,7 @@ test_files:
|
|
94
94
|
- test/hreview_test.rb
|
95
95
|
- test/include_pattern_test.rb
|
96
96
|
- test/reltag_test.rb
|
97
|
+
- test/subclass_test.rb
|
97
98
|
- test/xfn_test.rb
|
98
99
|
- test/xoxo_test.rb
|
99
100
|
rdoc_options: []
|