googlereader 0.0.3 → 0.0.4
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 +2 -0
- data/config/hoe.rb +1 -1
- data/examples/labels.rb +3 -4
- data/examples/search.rb +6 -4
- data/lib/google/reader.rb +1 -1
- data/lib/google/reader/label.rb +2 -2
- data/lib/google/reader/search.rb +24 -8
- data/lib/google/reader/version.rb +1 -1
- metadata +3 -3
data/History.txt
CHANGED
data/config/hoe.rb
CHANGED
@@ -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.
|
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
|
|
data/examples/labels.rb
CHANGED
@@ -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 '', '==
|
16
|
-
# unread = Google::Reader::Label.new('
|
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==='
|
data/examples/search.rb
CHANGED
@@ -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('
|
10
|
-
search.
|
11
|
-
|
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 }
|
data/lib/google/reader.rb
CHANGED
data/lib/google/reader/label.rb
CHANGED
@@ -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
|
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)
|
data/lib/google/reader/search.rb
CHANGED
@@ -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
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
:
|
39
|
-
|
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
|
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.
|
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-
|
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.
|
22
|
+
version: 0.1.3
|
23
23
|
version:
|
24
24
|
- !ruby/object:Gem::Dependency
|
25
25
|
name: atom
|