6. Ruby SOAP Library:
Your Friend
• Creates methods on the fly
• Seems to work pretty well
• Transparently converts Ruby types to SOAP
definitions
7. Ruby SOAP Library:
Your Enemy
• Hard to debug (dump req/res to file)
• No one has ever used it
• There are not any alternatives
• The code is a jungle
22. hReview
<div id="review_16873" class="hreview">
<h5 class="item"><span class="fn">Beringer California Collection White Merlot 20
<abbr class="dtreviewed" title="20070420">(1 day ago)</abbr>
<span class="reviewer vcard">
<img class="photo" src="/assets/avatars/c19d1b2080f73765d420b461d3133ffa.jpg"
<a class="url fn" href="/people/garyvaynerchuk">garyvaynerchuk</a>
</span>
<abbr class="rating" title="50.0">50.0<em>/100</em></abbr>
<blockquote class="description">Had this in an industry event the other day, man
<p class="tags">Tasting Tags:
<a href="/tags/pink" rel="tag" class="rel-tag" title="view all wines with this t
<a href="/tags/sugar" rel="tag" class="rel-tag" title="view all wines with this
</p>
</div>
23. hReview
<div id="review_16873" class="hreview">
<h5 class="item"><span class="fn">Beringer California Collection White Merlot 20
<abbr class="dtreviewed" title="20070420">(1 day ago)</abbr>
<span class="reviewer vcard">
<img class="photo" src="/assets/avatars/c19d1b2080f73765d420b461d3133ffa.jpg"
<a class="url fn" href="/people/garyvaynerchuk">garyvaynerchuk</a>
</span>
<abbr class="rating" title="50.0">50.0<em>/100</em></abbr>
<blockquote class="description">Had this in an industry event the other day, man
<p class="tags">Tasting Tags:
<a href="/tags/pink" rel="tag" class="rel-tag" title="view all wines with this t
<a href="/tags/sugar" rel="tag" class="rel-tag" title="view all wines with this
</p>
</div>
25. mofo/hreview.rb
class HReview < Microformat
one :version, :summary, :type, :dtreviewed,
:rating, :description
one :reviewer => HCard
one :item! do
one :fn
end
end
26. microformat.rb
def collector
collector = Hash.new([])
def collector.method_missing(method, *classes)
super unless %w(one many).include? method.to_s
self[method] += Microformat.send(:break_out_hashes, classes)
end
collector
end
40. Oh, you can use Hpricot
for XML, too.
<Export>
<Product>
<SKU>403276</SKU>
<ItemName>Trivet</ItemName>
<CollectionNo>0</CollectionNo>
<Pages>0</Pages>
</Product>
</Export>
41. Oh, you can use Hpricot
for XML, too.
fields = %w(SKU ItemName CollectionNo Pages)
doc = Hpricot(open("my.xml"))
(doc/:product).each do |xml_product|
attributes = fields.inject({}) do |hash, field|
hash.merge(field => xml_product.at(field).innerHTML)
end
Product.create(attributes)
end
( also there’s Hpricot::XML() )