markauskas-googlereader 0.1.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.
- data/History.txt +10 -0
- data/License.txt +20 -0
- data/README.txt +37 -0
- data/Rakefile +18 -0
- data/Todo.txt +7 -0
- data/examples/base.rb +10 -0
- data/examples/counts.rb +12 -0
- data/examples/labels.rb +20 -0
- data/examples/preferences.rb +14 -0
- data/examples/search.rb +13 -0
- data/examples/subscriptions.rb +9 -0
- data/lib/google/reader/base.rb +49 -0
- data/lib/google/reader/count.rb +41 -0
- data/lib/google/reader/label.rb +80 -0
- data/lib/google/reader/preference.rb +50 -0
- data/lib/google/reader/search.rb +61 -0
- data/lib/google/reader/subscription.rb +17 -0
- data/lib/google/reader/version.rb +11 -0
- data/lib/google/reader.rb +50 -0
- data/markauskas-googlereader.gemspec +70 -0
- data/test/test_googlereader.rb +11 -0
- data/test/test_helper.rb +2 -0
- metadata +93 -0
data/History.txt
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
* 0.0.4
|
2
|
+
- got search working by using a raw post instead of a fancy set_form_data
|
3
|
+
* 0.0.3
|
4
|
+
- updated manifest to include all files, 0.0.2 release was not up to date
|
5
|
+
* 0.0.2
|
6
|
+
- added wrapper for subscriptions
|
7
|
+
- added wrapper for preferences
|
8
|
+
- added Base#get_token for retrieving tokens from google
|
9
|
+
* 0.0.1
|
10
|
+
- labels and counts are working
|
data/License.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2007 John Nunemaker
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.txt
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
= Installation
|
2
|
+
|
3
|
+
sudo gem install markauskas-googlereader --source http://gemcutter.org/
|
4
|
+
|
5
|
+
= Usage
|
6
|
+
|
7
|
+
require 'google/reader'
|
8
|
+
Google::Reader::Base.establish_connection('username', 'password')
|
9
|
+
|
10
|
+
# => all feeds and labels unread counts
|
11
|
+
pp Google::Reader::Count.all
|
12
|
+
|
13
|
+
# => all unread counts for labels
|
14
|
+
pp Google::Reader::Count.labels
|
15
|
+
|
16
|
+
# => all unread counts for feeds
|
17
|
+
pp Google::Reader::Count.feeds
|
18
|
+
|
19
|
+
# => all items for a label
|
20
|
+
pp Google::Reader::Label.all
|
21
|
+
|
22
|
+
puts 'Links'
|
23
|
+
# 5 latest unread items
|
24
|
+
unread = Google::Reader::Label.new('links').entries(:unread, :n => 5)
|
25
|
+
unread.each { |p| puts p.title }
|
26
|
+
|
27
|
+
puts 'Using Continuation'
|
28
|
+
# next 5 latest items after the unread above
|
29
|
+
more_unread = Google::Reader::Label.new('links').entries(:unread, :n => 5, :c => unread.continuation)
|
30
|
+
more_unread.each { |p| puts p.title }
|
31
|
+
|
32
|
+
= Notes
|
33
|
+
|
34
|
+
I'm using the following links below as documentation (and also a bit of reverse engineering with Firebug) until google releases an official and documented api:
|
35
|
+
|
36
|
+
* http://code.google.com/p/pyrfeed/wiki/GoogleReaderAPI
|
37
|
+
* http://blog.gpowered.net/2007/08/google-reader-api-functions.html
|
data/Rakefile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.dirname(__FILE__) + "/lib/google/reader/version.rb"
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'jeweler'
|
5
|
+
Jeweler::Tasks.new do |gemspec|
|
6
|
+
gemspec.version = Google::Reader::VERSION::STRING
|
7
|
+
gemspec.name = "markauskas-googlereader"
|
8
|
+
gemspec.summary = "Ruby wrapper for Google Reader"
|
9
|
+
gemspec.email = "info@tamole.net"
|
10
|
+
gemspec.homepage = "http://github.com/markauskas/googlereader"
|
11
|
+
gemspec.authors = ["Tomas Markauskas", "John Nunemaker"]
|
12
|
+
gemspec.add_dependency('markauskas-googlebase', '>= 0.3.0')
|
13
|
+
end
|
14
|
+
|
15
|
+
Jeweler::GemcutterTasks.new
|
16
|
+
rescue LoadError
|
17
|
+
puts "Jeweler not available. Install it with: gem install jeweler"
|
18
|
+
end
|
data/Todo.txt
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
* 0.0.5 Feed (ie: Feed.new('http://feeds.feedburner.com/johnnunemaker'))
|
2
|
+
* 0.0.6 State (ie: State.new('read').entries)
|
3
|
+
|
4
|
+
== Edit API
|
5
|
+
** 0.0.8 Subscription-Edit (add and remove subscriptions)
|
6
|
+
** 0.1.0 Edit-Tag (mark items as read, starred, shared, etc.)
|
7
|
+
** Disable-Tag (no idea what this is)
|
data/examples/base.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '/../lib')
|
2
|
+
require 'google/reader'
|
3
|
+
require 'pp'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
config = YAML::load(open("#{ENV['HOME']}/.google"))
|
7
|
+
Google::Base.establish_connection(config[:email], config[:password])
|
8
|
+
|
9
|
+
pp Google::Reader::Base.get_token
|
10
|
+
pp Google::Reader::Base.user_info
|
data/examples/counts.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '/../lib')
|
2
|
+
require 'google/reader'
|
3
|
+
|
4
|
+
require 'pp'
|
5
|
+
require 'yaml'
|
6
|
+
config = YAML::load(open("#{ENV['HOME']}/.google"))
|
7
|
+
|
8
|
+
Google::Base.establish_connection(config[:email], config[:password])
|
9
|
+
|
10
|
+
# pp Google::Reader::Count.all
|
11
|
+
pp Google::Reader::Count.labels
|
12
|
+
# pp Google::Reader::Count.feeds
|
data/examples/labels.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '/../lib')
|
2
|
+
require 'google/reader'
|
3
|
+
require 'pp'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
config = YAML::load(open("#{ENV['HOME']}/.google"))
|
7
|
+
Google::Base.establish_connection(config[:email], config[:password])
|
8
|
+
# Google::Base.set_connection(Google::Base.new(config[:email], config[:password]))
|
9
|
+
|
10
|
+
puts '', '=Labels='
|
11
|
+
labels = Google::Reader::Label.all
|
12
|
+
pp labels
|
13
|
+
|
14
|
+
# puts '', '==Ruby on Rails=='
|
15
|
+
# unread = Google::Reader::Label.new('ruby-on-rails').entries(:unread, :n => 5)
|
16
|
+
# pp unread.first
|
17
|
+
#
|
18
|
+
# puts '', '===Using Continuation==='
|
19
|
+
# more_unread = Google::Reader::Label.new('links').entries(:unread, :n => 5, :c => unread.continuation)
|
20
|
+
# more_unread.each { |p| puts p.title }
|
@@ -0,0 +1,14 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '/../lib')
|
2
|
+
require 'google/reader'
|
3
|
+
require 'pp'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
config = YAML::load(open("#{ENV['HOME']}/.google"))
|
7
|
+
Google::Base.establish_connection(config[:email], config[:password])
|
8
|
+
|
9
|
+
pp Google::Reader::Preference.available
|
10
|
+
pp Google::Reader::Preference[:design]
|
11
|
+
pp Google::Reader::Preference[:mobile_use_transcoder]
|
12
|
+
pp Google::Reader::Preference[:mobile_num_entries]
|
13
|
+
|
14
|
+
pp Google::Reader::Preference.stream
|
data/examples/search.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '/../lib')
|
2
|
+
require 'google/reader'
|
3
|
+
require 'yaml'
|
4
|
+
require 'pp'
|
5
|
+
|
6
|
+
config = YAML::load(open("#{ENV['HOME']}/.google"))
|
7
|
+
Google::Base.establish_connection(config[:email], config[:password])
|
8
|
+
|
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 }
|
@@ -0,0 +1,9 @@
|
|
1
|
+
$:.unshift File.join(File.dirname(__FILE__), '/../lib')
|
2
|
+
require 'google/reader'
|
3
|
+
require 'pp'
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
config = YAML::load(open("#{ENV['HOME']}/.google"))
|
7
|
+
Google::Base.establish_connection(config[:email], config[:password])
|
8
|
+
|
9
|
+
pp Google::Reader::Subscription.all.detect { |s| s.categories.size > 1 }
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Google
|
2
|
+
module Reader
|
3
|
+
class Base < Base
|
4
|
+
class << self
|
5
|
+
def parse(atom_feed)
|
6
|
+
Atom::Feed.new(atom_feed)
|
7
|
+
end
|
8
|
+
|
9
|
+
def parse_json(json_str)
|
10
|
+
JSON.parse(json_str)
|
11
|
+
end
|
12
|
+
|
13
|
+
def get_entries(url, o={})
|
14
|
+
options = {:continuation => true,}.merge(o)
|
15
|
+
body = get(url)
|
16
|
+
if options[:continuation]
|
17
|
+
entries = parse(body).entries
|
18
|
+
entries.class.class_eval "attr_accessor :continuation"
|
19
|
+
entries.continuation = extract_continuation(body)
|
20
|
+
entries
|
21
|
+
else
|
22
|
+
parse(body).entries
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Gets a new token which can be used with all non-get requests.
|
27
|
+
def get_token
|
28
|
+
get(TOKEN_URL)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Last time I checked this returns a hash like:
|
32
|
+
# {"isBloggerUser": true, "userId": "<user id number>", "userEmail": "nunemaker@gmail.com"}
|
33
|
+
def user_info
|
34
|
+
parse_json(get(USER_INFO_URL))
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
# atom parser doesn't bring in google's custom atom fields
|
39
|
+
# this method grabs the continuation so that i can instantly
|
40
|
+
# grab the next set of items
|
41
|
+
# <gr:continuation>CO3urYix4Y8C</gr:continuation>
|
42
|
+
def extract_continuation(body)
|
43
|
+
matches = body.match(/<gr:continuation>(.*)<\/gr:continuation>/)
|
44
|
+
matches.nil? ? nil : matches[0].gsub(/<\/?gr:continuation>/, '')
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
module Google
|
3
|
+
module Reader
|
4
|
+
class Count < Base
|
5
|
+
class << self
|
6
|
+
# Gets all the unread counts
|
7
|
+
# Usage:
|
8
|
+
# Google::Reader::Count.all
|
9
|
+
#
|
10
|
+
# Returns and array of open structs with each entry looking like one of the following:
|
11
|
+
# #<OpenStruct google_id="feed/http://feeds.feedburner.com/johnnunemaker", count=0> # => feed
|
12
|
+
# #<OpenStruct google_id="user/{user_id}/label/friends", count=0> # => label
|
13
|
+
def all
|
14
|
+
parse_json(get(UNREAD_COUNT_URL))['unreadcounts'].inject([]) do |counts, c|
|
15
|
+
counts << OpenStruct.new(:google_id => c['id'], :count => c['count'])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# Gets all the unread counts, selects all the labels and converts them to Label objects
|
20
|
+
# Usage:
|
21
|
+
# Google::Reader::Count.labels
|
22
|
+
#
|
23
|
+
# Returns an array of these:
|
24
|
+
# #<Google::Reader::Label:0x14923ec @count=0, @name="friends", @shared=false>
|
25
|
+
def labels
|
26
|
+
all.select { |c| c.google_id =~ /^user/ }.collect { |c| Label.new(c.google_id, nil, c.count) }
|
27
|
+
end
|
28
|
+
|
29
|
+
# Gets all the unread counts and selects all the feeds
|
30
|
+
# Usage:
|
31
|
+
# Google::Reader::Count.feeds
|
32
|
+
#
|
33
|
+
# Returns and array of these:
|
34
|
+
# #<OpenStruct google_id="feed/http://feeds.feedburner.com/johnnunemaker", count=0>
|
35
|
+
def feeds
|
36
|
+
all.select { |c| c.google_id =~ /^feed/ }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module Google
|
2
|
+
module Reader
|
3
|
+
class Label < Base
|
4
|
+
class << self
|
5
|
+
# Usage:
|
6
|
+
# Google::Reader::Label.all
|
7
|
+
def all
|
8
|
+
parse_json(get(LABELS_URL))['tags'].inject([]) do |labels, l|
|
9
|
+
labels << new(l['id'], l['shared'])
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
VALID_KEYS = [:n, :c]
|
15
|
+
|
16
|
+
attr_reader :shared
|
17
|
+
attr_accessor :count
|
18
|
+
|
19
|
+
# Usage:
|
20
|
+
# Google::Reader::Label.new('friends')
|
21
|
+
# Google::Reader::Label.new('friends', false)
|
22
|
+
# Google::Reader::Label.new('friends', false, 3)
|
23
|
+
def initialize(name, shared=false, count=0)
|
24
|
+
self.name = name
|
25
|
+
self.shared = shared
|
26
|
+
self.count = count
|
27
|
+
end
|
28
|
+
|
29
|
+
# Converts user/{user-id}/label/security to security.
|
30
|
+
def name=(new_name)
|
31
|
+
@name = new_name.split('/').last
|
32
|
+
end
|
33
|
+
|
34
|
+
# Returns name; converts broadcast label to shared to be consistent with google
|
35
|
+
def name
|
36
|
+
@name == 'broadcast' ? 'shared' : @name
|
37
|
+
end
|
38
|
+
|
39
|
+
def shared=(new_shared)
|
40
|
+
if new_shared.is_a?(String)
|
41
|
+
@shared = new_shared == 'no' ? false : true
|
42
|
+
else
|
43
|
+
@shared = new_shared.nil? ? false : true
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Usage:
|
48
|
+
# Google::Reader::Label.new('friends').entries
|
49
|
+
# Google::Reader::Label.new('friends').entries(:all, :n => 25)
|
50
|
+
# Google::Reader::Label.new('friends').entries(:unread)
|
51
|
+
# Google::Reader::Label.new('friends').entries(:unread, :n => 25)
|
52
|
+
#
|
53
|
+
# To use with continuations:
|
54
|
+
# unread = Google::Reader::Label.new('friends').entries(:unread)
|
55
|
+
# next_unread = Google::Reader::Label.new('friends').entries(:unread, :c => unread.continuation)
|
56
|
+
#
|
57
|
+
# The examples above would grab the first 15 unread entries and then using google reader's
|
58
|
+
# continuations, the next 15 unread after the first 15.
|
59
|
+
def entries(which=nil, o={})
|
60
|
+
options = {:n => 15,}.merge(o)
|
61
|
+
query_str = valid_keys_to_query_string(o)
|
62
|
+
url = case which.to_s
|
63
|
+
when 'unread'
|
64
|
+
sprintf(LABEL_URL, @name) + "?xt=#{State::READ}&#{query_str}"
|
65
|
+
else
|
66
|
+
sprintf(LABEL_URL, @name)
|
67
|
+
end
|
68
|
+
self.class.get_entries(url, :continuation => true)
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
# Converts a hash to a query string but only keys that are valid
|
73
|
+
def valid_keys_to_query_string(o)
|
74
|
+
str = ''
|
75
|
+
o.each { |k,v| str << "#{k}=#{v}&" if VALID_KEYS.include?(k) }
|
76
|
+
str
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Google
|
2
|
+
module Reader
|
3
|
+
class Preference < Base
|
4
|
+
@@greader_preferences = {}
|
5
|
+
|
6
|
+
class << self
|
7
|
+
# Returns a sorted list of all the available preference keys
|
8
|
+
#
|
9
|
+
# Usage:
|
10
|
+
# Google::Reader::Preference.available
|
11
|
+
def available
|
12
|
+
ensure_preferences_loaded
|
13
|
+
@@greader_preferences.keys.sort
|
14
|
+
end
|
15
|
+
|
16
|
+
# Gives access to an individual preference. Replace any dash
|
17
|
+
# in preference key with an underscore. (ie: mobile-num-entries
|
18
|
+
# is accessed using mobile_num_entries)
|
19
|
+
#
|
20
|
+
# Usage:
|
21
|
+
# Google::Reader::Preference[:design]
|
22
|
+
# Google::Reader::Preference[:mobile_use_transcoder]
|
23
|
+
def [](pref)
|
24
|
+
ensure_preferences_loaded
|
25
|
+
@@greader_preferences[pref.to_s.gsub('_', '-')]
|
26
|
+
end
|
27
|
+
|
28
|
+
# Returns any preferences set for each feed and label. Not sure
|
29
|
+
# what this could be helpful for so I'm not sure how to make things
|
30
|
+
# easily accessible. Right now just returns straight up hash, not
|
31
|
+
# very useful.
|
32
|
+
def stream #:nodoc:
|
33
|
+
parse_json(get(PREFERENCE_STREAM_URL))['streamprefs'].reject { |k,v| v == [] }
|
34
|
+
end
|
35
|
+
|
36
|
+
private
|
37
|
+
# Gets all the preferences from google
|
38
|
+
def load_all
|
39
|
+
parse_json(get(PREFERENCE_URL))['prefs'].each do |p|
|
40
|
+
@@greader_preferences[p['id']] = p['value']
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def ensure_preferences_loaded
|
45
|
+
load_all if @@greader_preferences.keys.size == 0
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# This is getting the ids fine but I haven't figured out how
|
2
|
+
# to post multiple elements of the same name yet in ruby so
|
3
|
+
# don't use it unless you want to fix it.
|
4
|
+
require 'ostruct'
|
5
|
+
module Google #:nodoc:
|
6
|
+
module Reader #:nodoc:
|
7
|
+
class Search < Base #:nodoc:
|
8
|
+
attr_accessor :q, :ids
|
9
|
+
|
10
|
+
def initialize(q)
|
11
|
+
self.q = q
|
12
|
+
@executed = false
|
13
|
+
end
|
14
|
+
|
15
|
+
def execute
|
16
|
+
response = self.class.get(SEARCH_IDS_URL, :query_hash => {
|
17
|
+
:num => 1000,
|
18
|
+
:output => 'json',
|
19
|
+
:q => q
|
20
|
+
})
|
21
|
+
self.ids = self.class.parse_json(response)['results'].collect { |r| r['id'] }
|
22
|
+
@executed = true
|
23
|
+
end
|
24
|
+
|
25
|
+
def results(o={})
|
26
|
+
execute unless @executed
|
27
|
+
options = {
|
28
|
+
:token => nil,
|
29
|
+
:start => 0,
|
30
|
+
:num => 20,
|
31
|
+
}.merge(o)
|
32
|
+
options[:token] ||= self.class.get_token
|
33
|
+
|
34
|
+
if ids.size > 0
|
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
|
+
[]
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
module Google
|
3
|
+
module Reader
|
4
|
+
class Subscription < Base
|
5
|
+
class << self
|
6
|
+
def all
|
7
|
+
parse_json(get(SUBSCRIPTION_LIST_URL))['subscriptions'].inject([]) do |subs, s|
|
8
|
+
subs << OpenStruct.new( :firstitemmsec => s['firstitemmsec'],
|
9
|
+
:title => s['title'],
|
10
|
+
:google_id => s['id'],
|
11
|
+
:categories => s['categories'].inject([]) { |cats, c| cats << OpenStruct.new(:google_id => c['id'], :name => c['label']) })
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'net/https'
|
3
|
+
require 'net/http'
|
4
|
+
require 'rubygems'
|
5
|
+
|
6
|
+
gem 'atom', '>= 0.3'
|
7
|
+
gem 'json', '>= 1.1.1'
|
8
|
+
gem 'googlebase', '>= 0.1.3'
|
9
|
+
|
10
|
+
require 'atom'
|
11
|
+
require 'json'
|
12
|
+
require 'google/base'
|
13
|
+
require 'google/reader/base'
|
14
|
+
require 'google/reader/count'
|
15
|
+
require 'google/reader/label'
|
16
|
+
require 'google/reader/preference'
|
17
|
+
require 'google/reader/search'
|
18
|
+
require 'google/reader/subscription'
|
19
|
+
|
20
|
+
module Google
|
21
|
+
module Reader
|
22
|
+
READER_URL = Google::URL + '/reader'
|
23
|
+
TOKEN_URL = READER_URL + "/api/0/token"
|
24
|
+
SEARCH_IDS_URL = READER_URL + "/api/0/search/items/ids"
|
25
|
+
SEARCH_CONTENTS_URL = READER_URL + "/api/0/stream/items/contents"
|
26
|
+
SUBSCRIPTION_LIST_URL = READER_URL + '/api/0/subscription/list?output=json'
|
27
|
+
SUBSCRIPTION_EDIT_URL = READER_URL + '/api/0/subscription/edit'
|
28
|
+
FEED_URL = READER_URL + '/atom/feed/%s'
|
29
|
+
LABELS_URL = READER_URL + '/api/0/tag/list?output=json'
|
30
|
+
LABEL_URL = READER_URL + '/atom/user/-/label/%s'
|
31
|
+
PREFERENCE_URL = READER_URL + '/api/0/preference/list?output=json'
|
32
|
+
PREFERENCE_STREAM_URL = READER_URL + '/api/0/preference/stream/list?output=json'
|
33
|
+
UNREAD_COUNT_URL = READER_URL + '/api/0/unread-count?all=true&output=json'
|
34
|
+
USER_INFO_URL = READER_URL + '/user-info'
|
35
|
+
PACKAGE = "user/-/state/com.google"
|
36
|
+
|
37
|
+
module State
|
38
|
+
READ = "#{PACKAGE}/read"
|
39
|
+
KEPT_UNREAD = "#{PACKAGE}/kept-unread"
|
40
|
+
FRESH = "#{PACKAGE}/fresh"
|
41
|
+
STARRED = "#{PACKAGE}/starred"
|
42
|
+
BROADCAST = "#{PACKAGE}/broadcast"
|
43
|
+
READING_LIST = "#{PACKAGE}/reading-list"
|
44
|
+
TRACKING_BODY_LINK_USED = "#{PACKAGE}/tracking-body-link-used"
|
45
|
+
TRACKING_EMAILED = "#{PACKAGE}/tracking-emailed"
|
46
|
+
TRACKING_ITEM_LINK_USED = "#{PACKAGE}/tracking-item-link-used"
|
47
|
+
TRACKING_KEPT_UNREAD = "#{PACKAGE}/tracking-kept-unread"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{markauskas-googlereader}
|
8
|
+
s.version = "0.1.0"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Tomas Markauskas", "John Nunemaker"]
|
12
|
+
s.date = %q{2010-01-12}
|
13
|
+
s.email = %q{info@tamole.net}
|
14
|
+
s.extra_rdoc_files = [
|
15
|
+
"README.txt"
|
16
|
+
]
|
17
|
+
s.files = [
|
18
|
+
"History.txt",
|
19
|
+
"License.txt",
|
20
|
+
"README.txt",
|
21
|
+
"Rakefile",
|
22
|
+
"Todo.txt",
|
23
|
+
"examples/base.rb",
|
24
|
+
"examples/counts.rb",
|
25
|
+
"examples/labels.rb",
|
26
|
+
"examples/preferences.rb",
|
27
|
+
"examples/search.rb",
|
28
|
+
"examples/subscriptions.rb",
|
29
|
+
"lib/google/reader.rb",
|
30
|
+
"lib/google/reader/base.rb",
|
31
|
+
"lib/google/reader/count.rb",
|
32
|
+
"lib/google/reader/label.rb",
|
33
|
+
"lib/google/reader/preference.rb",
|
34
|
+
"lib/google/reader/search.rb",
|
35
|
+
"lib/google/reader/subscription.rb",
|
36
|
+
"lib/google/reader/version.rb",
|
37
|
+
"markauskas-googlereader.gemspec",
|
38
|
+
"test/test_googlereader.rb",
|
39
|
+
"test/test_helper.rb"
|
40
|
+
]
|
41
|
+
s.homepage = %q{http://github.com/markauskas/googlereader}
|
42
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
43
|
+
s.require_paths = ["lib"]
|
44
|
+
s.rubygems_version = %q{1.3.5}
|
45
|
+
s.summary = %q{Ruby wrapper for Google Reader}
|
46
|
+
s.test_files = [
|
47
|
+
"test/test_googlereader.rb",
|
48
|
+
"test/test_helper.rb",
|
49
|
+
"examples/base.rb",
|
50
|
+
"examples/counts.rb",
|
51
|
+
"examples/labels.rb",
|
52
|
+
"examples/preferences.rb",
|
53
|
+
"examples/search.rb",
|
54
|
+
"examples/subscriptions.rb"
|
55
|
+
]
|
56
|
+
|
57
|
+
if s.respond_to? :specification_version then
|
58
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
59
|
+
s.specification_version = 3
|
60
|
+
|
61
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
62
|
+
s.add_runtime_dependency(%q<markauskas-googlebase>, [">= 0.3.0"])
|
63
|
+
else
|
64
|
+
s.add_dependency(%q<markauskas-googlebase>, [">= 0.3.0"])
|
65
|
+
end
|
66
|
+
else
|
67
|
+
s.add_dependency(%q<markauskas-googlebase>, [">= 0.3.0"])
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
data/test/test_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: markauskas-googlereader
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tomas Markauskas
|
8
|
+
- John Nunemaker
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2010-01-12 00:00:00 +01:00
|
14
|
+
default_executable:
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: markauskas-googlebase
|
18
|
+
type: :runtime
|
19
|
+
version_requirement:
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.3.0
|
25
|
+
version:
|
26
|
+
description:
|
27
|
+
email: info@tamole.net
|
28
|
+
executables: []
|
29
|
+
|
30
|
+
extensions: []
|
31
|
+
|
32
|
+
extra_rdoc_files:
|
33
|
+
- README.txt
|
34
|
+
files:
|
35
|
+
- History.txt
|
36
|
+
- License.txt
|
37
|
+
- README.txt
|
38
|
+
- Rakefile
|
39
|
+
- Todo.txt
|
40
|
+
- examples/base.rb
|
41
|
+
- examples/counts.rb
|
42
|
+
- examples/labels.rb
|
43
|
+
- examples/preferences.rb
|
44
|
+
- examples/search.rb
|
45
|
+
- examples/subscriptions.rb
|
46
|
+
- lib/google/reader.rb
|
47
|
+
- lib/google/reader/base.rb
|
48
|
+
- lib/google/reader/count.rb
|
49
|
+
- lib/google/reader/label.rb
|
50
|
+
- lib/google/reader/preference.rb
|
51
|
+
- lib/google/reader/search.rb
|
52
|
+
- lib/google/reader/subscription.rb
|
53
|
+
- lib/google/reader/version.rb
|
54
|
+
- markauskas-googlereader.gemspec
|
55
|
+
- test/test_googlereader.rb
|
56
|
+
- test/test_helper.rb
|
57
|
+
has_rdoc: true
|
58
|
+
homepage: http://github.com/markauskas/googlereader
|
59
|
+
licenses: []
|
60
|
+
|
61
|
+
post_install_message:
|
62
|
+
rdoc_options:
|
63
|
+
- --charset=UTF-8
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: "0"
|
71
|
+
version:
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: "0"
|
77
|
+
version:
|
78
|
+
requirements: []
|
79
|
+
|
80
|
+
rubyforge_project:
|
81
|
+
rubygems_version: 1.3.5
|
82
|
+
signing_key:
|
83
|
+
specification_version: 3
|
84
|
+
summary: Ruby wrapper for Google Reader
|
85
|
+
test_files:
|
86
|
+
- test/test_googlereader.rb
|
87
|
+
- test/test_helper.rb
|
88
|
+
- examples/base.rb
|
89
|
+
- examples/counts.rb
|
90
|
+
- examples/labels.rb
|
91
|
+
- examples/preferences.rb
|
92
|
+
- examples/search.rb
|
93
|
+
- examples/subscriptions.rb
|