Class: GoogleReader
Instance Attribute Summary
Attributes inherited from Site
#posts
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Site
#balance, #credentials, #credentials=, #date, #identifier, #imported_links, #initialize, #save!, #to_post, #to_s, #undo_import!
Constructor Details
This class inherits a constructor from Site
Class Method Details
.scrape_link_from_profile(profile) ⇒ Object
6
7
8
|
# File 'lib/googlereader.rb', line 6
def self.scrape_link_from_profile(profile)
Nokogiri(open(profile)).search("link[rel='alternate']")[0]["href"]
end
|
Instance Method Details
#ask_for_credentials ⇒ Object
41
42
43
44
45
46
|
# File 'lib/googlereader.rb', line 41
def ask_for_credentials
puts "URL of google reader shared links:"
url = STDIN.gets.strip
url = GoogleReader.scrape_link_from_profile(url) unless url =~ /atom/
self.credentials = {"url" => url}
end
|
#initialise(gourmand) ⇒ Object
10
11
12
13
|
# File 'lib/googlereader.rb', line 10
def initialise(gourmand)
super
@gourmand = gourmand
end
|
#name ⇒ Object
15
16
17
|
# File 'lib/googlereader.rb', line 15
def name
"google-reader"
end
|
#update! ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/googlereader.rb', line 19
def update!
balance
feed = Nokogiri(open(credentials["url"]))
entries = feed.search("entry")
new_posts = entries.map{|x| {
"description" => x.search("title")[0].text,
"url" => x.search("link")[0]["href"],
"tag" => x.search("category").text + " via:google-reader",
"dt" => x.search("published").text
}
}
@posts += new_posts
@posts.
select{|x| !@ids.include?(x["url"])}.
map{|x| to_post(x)}
end
|