grapi 0.4.1 → 0.5.0

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.
@@ -29,8 +29,8 @@ Public API:
29
29
 
30
30
  * initialize(verbose= false)
31
31
  * login(USERNAME, PASSWORD)
32
- * reading_list(:continuation => nil, :dump_data => false, :output => "atom/json")
33
- * subscribe(feed_url, label=test)
32
+ * reading_list(:continuation => nil, :dump_data => false, :output => "atom/json", :items => 1000, :lable => nil)
33
+ * subscribe(feed_url, label = test)
34
34
  * unsubscribe(feed_url)
35
35
  * mark_as_read( entry_google_ids ) # can pass an entry id or an array of entries id
36
36
 
@@ -48,5 +48,5 @@ h3. Links
48
48
 
49
49
  * "Friends of the Unofficial Google Reader API":http://groups.google.com/group/fougrapi
50
50
  * "pyrfeed":http://code.google.com/p/pyrfeed/wiki/GoogleReaderAPI
51
- * "Using the Google Reader API Part 2":http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/
51
+ * "Using the Google Reader API - Part 2":http://blog.martindoms.com/2009/10/16/using-the-google-reader-api-part-2/
52
52
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.1
1
+ 0.5.0
@@ -1,15 +1,15 @@
1
1
  # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{grapi}
8
- s.version = "0.4.1"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Aurelian Oancea"]
12
- s.date = %q{2010-01-04}
12
+ s.date = %q{2010-01-22}
13
13
  s.description = %q{Ruby client for unofficial Google Reader API}
14
14
  s.email = %q{oancea@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -51,4 +51,3 @@ Gem::Specification.new do |s|
51
51
  s.add_dependency(%q<curb>, [">= 0.6.1.0"])
52
52
  end
53
53
  end
54
-
@@ -29,8 +29,12 @@ module Grapi
29
29
  "service" => "reader",
30
30
  "accountType" => "HOSTED_OR_GOOGLE"
31
31
  }
32
- @client.body_str.uncompress =~ /^SID=(.*)\n/
33
- @client.headers['Cookie']= "SID=#{$1}"
32
+ if @client.body_str.uncompress =~ /^SID=(.*)\n/
33
+ @client.headers['Cookie']= "SID=#{$1}"
34
+ else
35
+ # TODO: can we handle Error=CaptchaRequired?
36
+ raise Error.new("Authentication failed with: #{@client.body_str.uncompress}")
37
+ end
34
38
  self
35
39
  end
36
40
 
@@ -56,12 +60,21 @@ module Grapi
56
60
  # :continuation (default: nil) -> continuation string
57
61
  # :dump_data (default: false) -> whether to write the response to a file in /tmp or not
58
62
  # :output (default: atom) -> desired output (atom|json)
63
+ # :items (default: 1000) -> amount of items to fetch
64
+ # :label (default: nil) -> get only the items in label, by default fetch all items
59
65
  def reading_list(options={})
60
- options= {:continuation => nil, :output => "atom", :dump_data => false}.update(options)
66
+ options= {:continuation => nil, :output => "atom", :dump_data => false, :items => 1000, :label => nil}.update(options)
67
+
68
+ base= if options[:label].nil?
69
+ "user/-/state/com.google/reading-list"
70
+ else
71
+ "user/-/label/#{options[:label]}"
72
+ end
73
+
61
74
  if options[:output] == "atom"
62
- get "http://www.google.com/reader/atom/user/-/state/com.google/reading-list?xt=user/-/state/com.google/read&ck=#{Time.now.to_i*1000}&n=1000&c=#{options[:continuation]}"
75
+ get "http://www.google.com/reader/atom/#{base}?xt=user/-/state/com.google/read&ck=#{Time.now.to_i*1000}&n=#{options[:items]}&c=#{options[:continuation]}"
63
76
  else
64
- get "http://www.google.com/reader/api/0/stream/contents/user/-/state/com.google/reading-list?output=#{options[:output]}&xt=user/-/state/com.google/read&ck=#{Time.now.to_i*1000}&n=1000&c=#{options[:continuation]}"
77
+ get "http://www.google.com/reader/api/0/stream/contents/#{base}?output=#{options[:output]}&xt=user/-/state/com.google/read&ck=#{Time.now.to_i*1000}&n=#{options[:items]}&c=#{options[:continuation]}"
65
78
  end
66
79
  response= @client.body_str.uncompress
67
80
  File.open("/tmp/#{Time.now.to_i}-reading_list.#{options[:output]}", "w"){|f|f<<response} if options[:dump_data]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aurelian Oancea
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-04 00:00:00 +01:00
12
+ date: 2010-01-22 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency