<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[610] trunk/alexandria: - Fixes for [#8719] worldcat and webster can take muliple authors now.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd>610</dd>
<dt>Author</dt> <dd>method</dd>
<dt>Date</dt> <dd>2007-02-19 16:44:33 -0500 (Mon, 19 Feb 2007)</dd>
</dl>

<h3>Log Message</h3>
<pre>- Fixes for [#8719] worldcat and webster can take muliple authors now. 
&quot;&quot;.scan(/regex/) is the key.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkalexandrialibalexandriabook_providerswebster_itrb">trunk/alexandria/lib/alexandria/book_providers/webster_it.rb</a></li>
<li><a href="#trunkalexandrialibalexandriabook_providersworldcatrb">trunk/alexandria/lib/alexandria/book_providers/worldcat.rb</a></li>
<li><a href="#trunkalexandriateststest_providersrb">trunk/alexandria/tests/test_providers.rb</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkalexandrialibalexandriabook_providerswebster_itrb"></a>
<div class="modfile"><h4>Modified: trunk/alexandria/lib/alexandria/book_providers/webster_it.rb (609 => 610)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/alexandria/lib/alexandria/book_providers/webster_it.rb        2007-02-19 10:50:31 UTC (rev 609)
+++ trunk/alexandria/lib/alexandria/book_providers/webster_it.rb        2007-02-19 21:44:33 UTC (rev 610)
</span><span class="lines">@@ -96,8 +96,12 @@
</span><span class="cx">             end
</span><span class="cx"> 
</span><span class="cx">             authors = []
</span><del>-            if md = /&lt;li&gt;&lt;span class=&quot;product_label&quot;&gt;Autor([ei]):&lt;\/span&gt; &lt;span class=&quot;product_text&quot;&gt;&lt;a href=&quot;([^&gt;]+)&gt;([^&lt;]+)/.match(data)
-                 authors = [CGI.unescape(md[3].strip)]
</del><ins>+            if md = /&lt;li&gt;&lt;span class=&quot;product_label&quot;&gt;Autor[ei]:&lt;\/span&gt; &lt;span class=&quot;product_text&quot;&gt;(&lt;a href=&quot;[^&gt;]+&quot;&gt;([^&lt;]+)&lt;\/a&gt;,? ?)+&lt;\/span&gt;&lt;li&gt;/.match(data) 
+                    this = CGI.unescape(md[0].strip)
+                    authors = this.scan(/&lt;a href=&quot;[^&gt;]+&quot;&gt;([^&lt;]+)&lt;\/a&gt;,?/)
+                    authors = authors.collect {|author| author[0]}
+                    #puts this
+                    
</ins><span class="cx"> #                 md[1].strip.split(', ').each { |a| authors &lt;&lt; CGI.unescape(a.strip) }
</span><span class="cx">             end
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkalexandrialibalexandriabook_providersworldcatrb"></a>
<div class="modfile"><h4>Modified: trunk/alexandria/lib/alexandria/book_providers/worldcat.rb (609 => 610)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/alexandria/lib/alexandria/book_providers/worldcat.rb        2007-02-19 10:50:31 UTC (rev 609)
+++ trunk/alexandria/lib/alexandria/book_providers/worldcat.rb        2007-02-19 21:44:33 UTC (rev 610)
</span><span class="lines">@@ -90,11 +90,15 @@
</span><span class="cx">             raise unless md = /&lt;h1 class=&quot;title&quot;&gt; (&lt;div class=vernacular lang=&quot;[^&quot;]+&quot;&gt;)?([^&lt;]+)/.match(data)
</span><span class="cx">             title = CGI.unescape(md[2].strip)
</span><span class="cx"> 
</span><del>-            authors = []
-            if md = /title=&quot;Search for more by this author&quot;&gt;([^&lt;]+)/.match(data)
-                 authors = [CGI.unescape(md[1].strip)]
</del><ins>+                    authors = []
+                    md = data.scan(/title=&quot;Search for more by this author&quot;&gt;([^&lt;]+)/)
+            raise &quot;No authors&quot; unless md.length &gt; 0
+            md = md.collect {|match| match[0]} 
+            md.each {|match|
+                            CGI.unescape(match.strip)
+                            authors &lt;&lt; match                  
+                             }
</ins><span class="cx"> #                 md[1].strip.split(', ').each { |a| authors &lt;&lt; CGI.unescape(a.strip) }
</span><del>-            end
</del><span class="cx"> 
</span><span class="cx">             raise unless md = /&lt;strong&gt;ISBN: &lt;\/strong&gt;\w+\W+(\d+)\D/.match(data)
</span><span class="cx">             isbn = md[1].strip
</span></span></pre></div>
<a id="trunkalexandriateststest_providersrb"></a>
<div class="modfile"><h4>Modified: trunk/alexandria/tests/test_providers.rb (609 => 610)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/alexandria/tests/test_providers.rb        2007-02-19 10:50:31 UTC (rev 609)
+++ trunk/alexandria/tests/test_providers.rb        2007-02-19 21:44:33 UTC (rev 610)
</span><span class="lines">@@ -23,6 +23,7 @@
</span><span class="cx">                 end
</span><span class="cx">                 assert(results.first.isbn == query, &quot;Result's isbn #{results.first.isbn} is not the same as requested isbn #{query}&quot;)
</span><span class="cx">                  assert_kind_of(Alexandria::Book, results.first, &quot;Result is not a Book&quot;)
</span><ins>+                 results.first
</ins><span class="cx">                else
</span><span class="cx">                         assert_kind_of(Alexandria::Book, results.first.first, &quot;Result item is not a Book&quot;)
</span><span class="cx">         end   
</span><span class="lines">@@ -115,6 +116,14 @@
</span><span class="cx">         __test_provider(Alexandria::BookProviders::Webster_itProvider,
</span><span class="cx">                         '9783442460878') 
</span><span class="cx">     end
</span><ins>+    
+    def test_webster_multiple_authors
+            this_book = __test_provider(Alexandria::BookProviders::Webster_itProvider,
+                        '9788804559016')
+        assert_kind_of(Array, this_book.authors, &quot;Not an array!&quot;)
+        #puts this_book.authors
+        assert(this_book.authors.length == 3, &quot;Wrong number of authors for this book!&quot;)
+    end
</ins><span class="cx"> 
</span><span class="cx">     def test_renaud
</span><span class="cx">         __test_provider(Alexandria::BookProviders::RENAUDProvider,
</span><span class="lines">@@ -128,5 +137,13 @@
</span><span class="cx">         __test_provider(Alexandria::BookProviders::WorldcatProvider,
</span><span class="cx">                         '9785941454136') 
</span><span class="cx">     end
</span><del>-
</del><ins>+    
+    def test_worldcat_multiple_authors
+                this_book = __test_provider(Alexandria::BookProviders::WorldcatProvider,
+                        '9785941454136')
+        assert_kind_of(Array, this_book.authors, &quot;Not an array!&quot;)
+        #puts this_book.authors
+        assert(this_book.authors.length == 2, &quot;Wrong number of authors for this book!&quot;)
+        
+        end
</ins><span class="cx"> end
</span></span></pre>
</div>
</div>

</body>
</html>