<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,10 +1,9 @@
 $:.unshift File.join(File.dirname(__FILE__), '/../lib')
 require 'google/reader'
-
 require 'pp'
 require 'yaml'
-config = YAML::load(open(&quot;#{ENV['HOME']}/.google&quot;))
 
+config = YAML::load(open(&quot;#{ENV['HOME']}/.google&quot;))
 Google::Base.establish_connection(config[:email], config[:password])
 # Google::Base.set_connection(Google::Base.new(config[:email], config[:password]))
 
@@ -12,8 +11,8 @@ puts '', '=Labels='
 labels = Google::Reader::Label.all
 pp labels
 
-# puts '', '==Links=='
-# unread = Google::Reader::Label.new('links').entries(:unread, :n =&gt; 5)
+# puts '', '==Ruby on Rails=='
+# unread = Google::Reader::Label.new('ruby-on-rails').entries(:unread, :n =&gt; 5)
 # pp unread.first
 # 
 # puts '', '===Using Continuation==='</diff>
      <filename>examples/labels.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,11 +1,13 @@
 $:.unshift File.join(File.dirname(__FILE__), '/../lib')
 require 'google/reader'
-require 'pp'
 require 'yaml'
+require 'pp'
 
 config = YAML::load(open(&quot;#{ENV['HOME']}/.google&quot;))
 Google::Base.establish_connection(config[:email], config[:password])
 
-search = Google::Reader::Search.new('test')
-search.execute
-pp search.results
\ No newline at end of file
+search = Google::Reader::Search.new('john nunemaker')
+results = search.results(:start =&gt; 0)
+puts results.total
+results.each { |r| puts r.title }
+search.results(:start =&gt; 20).each { |r| puts r.title }
\ No newline at end of file</diff>
      <filename>examples/search.rb</filename>
    </modified>
    <modified>
      <diff>@@ -59,8 +59,8 @@ module Google
       def entries(which=nil, o={})
         options = {:n =&gt; 15,}.merge(o)
         query_str = valid_keys_to_query_string(o)
-        url = case which
-        when :unread
+        url = case which.to_s
+        when 'unread'
           sprintf(LABEL_URL, @name) + &quot;?xt=#{State::READ}&amp;#{query_str}&quot;
         else
           sprintf(LABEL_URL, @name)</diff>
      <filename>lib/google/reader/label.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,6 +1,7 @@
 # This is getting the ids fine but I haven't figured out how 
 # to post multiple elements of the same name yet in ruby so 
 # don't use it unless you want to fix it.
+require 'ostruct'
 module Google #:nodoc:
   module Reader #:nodoc:
     class Search &lt; Base #:nodoc:
@@ -22,22 +23,37 @@ module Google #:nodoc:
       end
       
       def results(o={})
+        execute unless @executed
         options = {
           :token =&gt; nil,
           :start =&gt; 0,
           :num   =&gt; 20,
         }.merge(o)
-        
         options[:token] ||= self.class.get_token
         
         if ids.size &gt; 0
-          i_str = ids[options[:start]] + '&amp;'
-          i_str += ids[(options[:start]+1)..options[:num]].collect { |id| [&quot;i=#{id}&amp;&quot;] unless id.nil? }.join('')
-          
-          self.class.post(SEARCH_CONTENTS_URL, :form_data =&gt; {
-            :T =&gt; options[:token],
-            :i =&gt; i_str,
-          })
+          raw_data  = ids[(options[:start]), options[:num]].collect { |id| &quot;i=#{id}&quot; unless id.nil? }.join('&amp;')
+          raw_data += &quot;&amp;T=#{options[:token]}&quot;
+          json_results = self.class.parse_json(self.class.post(SEARCH_CONTENTS_URL, :raw_data =&gt; raw_data))
+          results = json_results['items'].inject([]) do |acc, r|
+            result = OpenStruct.new(:google_id =&gt; r['id'], :title =&gt; r['title'], 
+                                    :published =&gt; Time.at(r['published']), :author =&gt; r['author'], 
+                                    :categories =&gt; r['categories'])
+            if r['alternate'].size &gt; 0
+              result.alternate_href = r['alternate'].first['href']
+              result.alternate_type = r['alternate'].first['type']
+            end
+            result.origin_title     = r['origin']['title']
+            result.origin_url       = r['origin']['htmlUrl']
+            result.origin_stream_id = r['origin']['streamId']
+            result.content = r['content'] ? r['content']['content'] : ''
+            acc &lt;&lt; result
+          end
+          results.class.class_eval &quot;attr_accessor :total&quot;
+          results.total = ids.size
+          results
+        else
+          []
         end
       end
     end</diff>
      <filename>lib/google/reader/search.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>b75922bac192453144b21e604fd42d1ef09fd1f8</id>
    </parent>
  </parents>
  <author>
    <name>jnunemaker</name>
    <email>jnunemaker@fe7eae16-9a24-0410-a59d-9e59979e88be</email>
  </author>
  <url>http://github.com/jnunemaker/googlereader/commit/e159492438b2774ef80848d26dcc2c0ba29192b4</url>
  <id>e159492438b2774ef80848d26dcc2c0ba29192b4</id>
  <committed-date>2007-12-26T12:30:45-08:00</committed-date>
  <authored-date>2007-12-26T12:30:45-08:00</authored-date>
  <message>search seems to be working pretty well


git-svn-id: http://svn.addictedtonew.com/public/gems/googlereader@149 fe7eae16-9a24-0410-a59d-9e59979e88be</message>
  <tree>811720650e2c556e0c595e2c8bdd69c489e1cd55</tree>
  <committer>
    <name>jnunemaker</name>
    <email>jnunemaker@fe7eae16-9a24-0410-a59d-9e59979e88be</email>
  </committer>
</commit>
