rbuzz 0.2 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +8 -3
- data/lib/rbuzz.rb +1 -0
- data/lib/rbuzz/feed.rb +23 -3
- data/lib/rbuzz/feed_entry.rb +7 -3
- metadata +31 -8
data/README.md
CHANGED
@@ -6,21 +6,21 @@ A simple Ruby wrapper to help retrieve and parse the Google Buzz Atom Feed.
|
|
6
6
|
Coming soon - subscribing to updates, posting to feed
|
7
7
|
|
8
8
|
Note: This library was renamed from Buzzr to Ruby Buzz. Buzzr.com sent me a friendly trademark
|
9
|
-
infringement notice and threatened a lawsuit
|
9
|
+
infringement notice and threatened a lawsuit.
|
10
10
|
|
11
11
|
Install
|
12
12
|
-------
|
13
13
|
|
14
14
|
gem install rbuzz
|
15
15
|
|
16
|
-
Ruby Buzz is hosted on the Gemcutter repository. It depends on the RAtom library - http://github.com/seangeo/ratom
|
17
|
-
|
18
16
|
Example
|
19
17
|
-------
|
20
18
|
|
21
19
|
require 'rbuzz'
|
22
20
|
|
23
21
|
feed_url = Rbuzz::Feed.discover("conorhunt")
|
22
|
+
# Or, using webfinger (see https://groups.google.com/group/webfinger/browse_thread/thread/fb56537a0ed36964/c51e559c8f8d5455)
|
23
|
+
# Rbuzz::Feed.discover_by_email("bradfitz@gmail.com")
|
24
24
|
feed = Rbuzz::Feed.retrieve(feed_url)
|
25
25
|
|
26
26
|
feed.entries.each do |entry|
|
@@ -62,6 +62,11 @@ Example
|
|
62
62
|
puts
|
63
63
|
end
|
64
64
|
|
65
|
+
CONTRIBUTORS
|
66
|
+
------------
|
67
|
+
|
68
|
+
Alexandr Zykov (github: alexandrz)
|
69
|
+
|
65
70
|
COPYRIGHT
|
66
71
|
---------
|
67
72
|
|
data/lib/rbuzz.rb
CHANGED
data/lib/rbuzz/feed.rb
CHANGED
@@ -14,14 +14,34 @@ module Rbuzz
|
|
14
14
|
feed.fetch
|
15
15
|
feed
|
16
16
|
end
|
17
|
+
|
18
|
+
# Extract the feed url from the users's google profile name
|
19
|
+
def self.discover(profile_name)
|
20
|
+
self.discover_by_url "http://www.google.com/profiles/#{profile_name}"
|
21
|
+
end
|
22
|
+
|
23
|
+
# Extract the feed url from the users's e-mail using the webfinger protocol
|
24
|
+
def self.discover_by_email(email)
|
25
|
+
resource = Net::HTTP.get(URI.parse("http://www.google.com/s2/webfinger/?q=acct:#{email}"))
|
26
|
+
begin
|
27
|
+
doc = XML::Document.string(resource)
|
28
|
+
rescue XML::Error => e
|
29
|
+
raise FeedError, "Could not find google profile for #{email}"
|
30
|
+
end
|
31
|
+
if profile_url = doc.find('//XRD:Alias', 'XRD:http://docs.oasis-open.org/ns/xri/xrd-1.0').first
|
32
|
+
self.discover_by_url profile_url.content
|
33
|
+
else
|
34
|
+
raise FeedError, "Could not find google profile page for #{email}"
|
35
|
+
end
|
36
|
+
end
|
17
37
|
|
18
38
|
# Extract the feed url from the users's google profile page
|
19
|
-
def self.
|
39
|
+
def self.discover_by_url(profile_url)
|
20
40
|
begin
|
21
|
-
page = open(
|
41
|
+
page = open(profile_url).read
|
22
42
|
rescue OpenURI::HTTPError => e
|
23
43
|
if e.io.status[0] == '404'
|
24
|
-
raise FeedError, "Could not find profile
|
44
|
+
raise FeedError, "Could not find profile at #{profile_url}"
|
25
45
|
end
|
26
46
|
end
|
27
47
|
|
data/lib/rbuzz/feed_entry.rb
CHANGED
@@ -34,19 +34,23 @@ module Rbuzz
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def urls
|
37
|
-
@links ||= @atom_entry.links.find_all {|l| l.type =~ %r{text/html}i }.collect {|l| l.href}
|
37
|
+
@links ||= @atom_entry.links.find_all {|l| l.type =~ %r{text/html}i }.collect {|l| l.href}.uniq
|
38
38
|
end
|
39
39
|
|
40
40
|
def images
|
41
|
-
@images ||= @atom_entry.links.find_all {|l| l.type =~ /image/i }.collect {|l| l.href}
|
41
|
+
@images ||= @atom_entry.links.find_all {|l| l.type =~ /image/i }.collect {|l| l.href}.uniq
|
42
42
|
end
|
43
43
|
|
44
44
|
def videos
|
45
|
-
@videos ||= @atom_entry.links.find_all {|l| l.type =~ %r{application/x-shockwave-flash}i }.collect {|l| l.href}
|
45
|
+
@videos ||= @atom_entry.links.find_all {|l| l.type =~ %r{application/x-shockwave-flash}i }.collect {|l| l.href}.uniq
|
46
46
|
end
|
47
47
|
|
48
48
|
def author
|
49
49
|
@atom_entry.authors[0] if @atom_entry.respond_to?(:authors)
|
50
50
|
end
|
51
|
+
|
52
|
+
def id
|
53
|
+
@atom_entry.id
|
54
|
+
end
|
51
55
|
end
|
52
56
|
end
|
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbuzz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 3
|
8
|
+
- 1
|
9
|
+
version: 0.3.1
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- Conor Hunt
|
@@ -14,14 +19,30 @@ default_executable:
|
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: ratom
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
- 6
|
30
|
+
- 3
|
23
31
|
version: 0.6.3
|
24
|
-
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: libxml-ruby
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
version: "0"
|
44
|
+
type: :runtime
|
45
|
+
version_requirements: *id002
|
25
46
|
description: Ruby wrapper for Google Buzz atom feeds
|
26
47
|
email: conor.hunt@gmail.com
|
27
48
|
executables: []
|
@@ -51,18 +72,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
51
72
|
requirements:
|
52
73
|
- - ">="
|
53
74
|
- !ruby/object:Gem::Version
|
75
|
+
segments:
|
76
|
+
- 0
|
54
77
|
version: "0"
|
55
|
-
version:
|
56
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
79
|
requirements:
|
58
80
|
- - ">="
|
59
81
|
- !ruby/object:Gem::Version
|
82
|
+
segments:
|
83
|
+
- 0
|
60
84
|
version: "0"
|
61
|
-
version:
|
62
85
|
requirements: []
|
63
86
|
|
64
87
|
rubyforge_project:
|
65
|
-
rubygems_version: 1.3.
|
88
|
+
rubygems_version: 1.3.6
|
66
89
|
signing_key:
|
67
90
|
specification_version: 3
|
68
91
|
summary: Ruby wrapper for Google Buzz atom feeds
|