googlereader 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,5 @@
1
+ * 0.0.4
2
+ - got search working by using a raw post instead of a fancy set_form_data
1
3
  * 0.0.3
2
4
  - updated manifest to include all files, 0.0.2 release was not up to date
3
5
  * 0.0.2
@@ -59,7 +59,7 @@ hoe = Hoe.new(GEM_NAME, VERS) do |p|
59
59
 
60
60
  # == Optional
61
61
  p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
62
- p.extra_deps = [['googlebase', '>= 0.1.1'], ['atom', '>= 0.3'], ['json', '>= 1.1.1']] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
62
+ p.extra_deps = [['googlebase', '>= 0.1.3'], ['atom', '>= 0.3'], ['json', '>= 1.1.1']] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
63
63
 
64
64
  #p.spec_extras = {} # A hash of extra values to set in the gemspec.
65
65
 
@@ -1,10 +1,9 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__), '/../lib')
2
2
  require 'google/reader'
3
-
4
3
  require 'pp'
5
4
  require 'yaml'
6
- config = YAML::load(open("#{ENV['HOME']}/.google"))
7
5
 
6
+ config = YAML::load(open("#{ENV['HOME']}/.google"))
8
7
  Google::Base.establish_connection(config[:email], config[:password])
9
8
  # Google::Base.set_connection(Google::Base.new(config[:email], config[:password]))
10
9
 
@@ -12,8 +11,8 @@ puts '', '=Labels='
12
11
  labels = Google::Reader::Label.all
13
12
  pp labels
14
13
 
15
- # puts '', '==Links=='
16
- # unread = Google::Reader::Label.new('links').entries(:unread, :n => 5)
14
+ # puts '', '==Ruby on Rails=='
15
+ # unread = Google::Reader::Label.new('ruby-on-rails').entries(:unread, :n => 5)
17
16
  # pp unread.first
18
17
  #
19
18
  # puts '', '===Using Continuation==='
@@ -1,11 +1,13 @@
1
1
  $:.unshift File.join(File.dirname(__FILE__), '/../lib')
2
2
  require 'google/reader'
3
- require 'pp'
4
3
  require 'yaml'
4
+ require 'pp'
5
5
 
6
6
  config = YAML::load(open("#{ENV['HOME']}/.google"))
7
7
  Google::Base.establish_connection(config[:email], config[:password])
8
8
 
9
- search = Google::Reader::Search.new('test')
10
- search.execute
11
- pp search.results
9
+ search = Google::Reader::Search.new('john nunemaker')
10
+ results = search.results(:start => 0)
11
+ puts results.total
12
+ results.each { |r| puts r.title }
13
+ search.results(:start => 20).each { |r| puts r.title }
@@ -5,7 +5,7 @@ require 'rubygems'
5
5
 
6
6
  gem 'atom', '>= 0.3'
7
7
  gem 'json', '>= 1.1.1'
8
- gem 'googlebase', '>= 0.1.1'
8
+ gem 'googlebase', '>= 0.1.3'
9
9
 
10
10
  require 'atom'
11
11
  require 'json'
@@ -59,8 +59,8 @@ module Google
59
59
  def entries(which=nil, o={})
60
60
  options = {:n => 15,}.merge(o)
61
61
  query_str = valid_keys_to_query_string(o)
62
- url = case which
63
- when :unread
62
+ url = case which.to_s
63
+ when 'unread'
64
64
  sprintf(LABEL_URL, @name) + "?xt=#{State::READ}&#{query_str}"
65
65
  else
66
66
  sprintf(LABEL_URL, @name)
@@ -1,6 +1,7 @@
1
1
  # This is getting the ids fine but I haven't figured out how
2
2
  # to post multiple elements of the same name yet in ruby so
3
3
  # don't use it unless you want to fix it.
4
+ require 'ostruct'
4
5
  module Google #:nodoc:
5
6
  module Reader #:nodoc:
6
7
  class Search < Base #:nodoc:
@@ -22,22 +23,37 @@ module Google #:nodoc:
22
23
  end
23
24
 
24
25
  def results(o={})
26
+ execute unless @executed
25
27
  options = {
26
28
  :token => nil,
27
29
  :start => 0,
28
30
  :num => 20,
29
31
  }.merge(o)
30
-
31
32
  options[:token] ||= self.class.get_token
32
33
 
33
34
  if ids.size > 0
34
- i_str = ids[options[:start]] + '&'
35
- i_str += ids[(options[:start]+1)..options[:num]].collect { |id| ["i=#{id}&"] unless id.nil? }.join('')
36
-
37
- self.class.post(SEARCH_CONTENTS_URL, :form_data => {
38
- :T => options[:token],
39
- :i => i_str,
40
- })
35
+ raw_data = ids[(options[:start]), options[:num]].collect { |id| "i=#{id}" unless id.nil? }.join('&')
36
+ raw_data += "&T=#{options[:token]}"
37
+ json_results = self.class.parse_json(self.class.post(SEARCH_CONTENTS_URL, :raw_data => raw_data))
38
+ results = json_results['items'].inject([]) do |acc, r|
39
+ result = OpenStruct.new(:google_id => r['id'], :title => r['title'],
40
+ :published => Time.at(r['published']), :author => r['author'],
41
+ :categories => r['categories'])
42
+ if r['alternate'].size > 0
43
+ result.alternate_href = r['alternate'].first['href']
44
+ result.alternate_type = r['alternate'].first['type']
45
+ end
46
+ result.origin_title = r['origin']['title']
47
+ result.origin_url = r['origin']['htmlUrl']
48
+ result.origin_stream_id = r['origin']['streamId']
49
+ result.content = r['content'] ? r['content']['content'] : ''
50
+ acc << result
51
+ end
52
+ results.class.class_eval "attr_accessor :total"
53
+ results.total = ids.size
54
+ results
55
+ else
56
+ []
41
57
  end
42
58
  end
43
59
  end
@@ -3,7 +3,7 @@ module Google #:nodoc:
3
3
  module VERSION #:nodoc:
4
4
  MAJOR = 0
5
5
  MINOR = 0
6
- TINY = 3
6
+ TINY = 4
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY].join('.')
9
9
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: googlereader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ""
6
6
  authors:
7
7
  - John Nunemaker
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2007-11-25 00:00:00 -05:00
12
+ date: 2007-12-26 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -19,7 +19,7 @@ dependencies:
19
19
  requirements:
20
20
  - - ">="
21
21
  - !ruby/object:Gem::Version
22
- version: 0.1.1
22
+ version: 0.1.3
23
23
  version:
24
24
  - !ruby/object:Gem::Dependency
25
25
  name: atom