public
Description: Ruby PostRank Wrapper
Homepage: http://github.com/dj2/ruby-postrank/wikis
Clone URL: git://github.com/dj2/ruby-postrank.git
joshbuddy (author)
Wed Jan 07 09:44:46 -0800 2009
dj2 (committer)
Sat Jan 10 08:02:41 -0800 2009
ruby-postrank / examples / api_example.rb
100644 49 lines (37 sloc) 1.247 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env ruby
 
require 'rubygems'
require 'postrank'
 
include PostRank
 
conn = Connection.instance
conn.appkey = "everburning.com/ruby-postrank"
 
# Retrieve the feed for everburning.com
eb = Feed.find_by_url("http://everburning.com")
perplex = Feed.find_by_url("http://perplexity.org")
 
puts eb
 
# Retrieve the first 15 Great level entries
puts "Getting GREAT entries"
eb.entries(:level => Level::GREAT).each do |entry|
  puts entry.title
end
 
# Retrieve items 15-45 of the All feed
puts "\nGetting ALL entries between 15 and 45"
eb.entries(:count => 30, :start => 15).each do |entry|
  puts entry.title
end
 
# Retrieve the first 15 top posts in the last week
puts "\nGetting top 15 posts from last week"
eb.topposts(:period => Period::WEEK).each do |entry|
  puts entry.title
end
 
# Retrieve the thematic postrank
puts "\nGetting thematic postrank"
PostRank::PostRank.calculate(['http://everburning.com/as',
             'http://blah.com']).each do |post|
  puts "#{post.original_link} #{post.postrank}"
end
 
# Retrieve the postrank
puts "\nGetting postrank"
PostRank::PostRank.calculate(['http://everburning.com', 'http://blah.com'],
            :feeds => [eb, perplex]).each do |post|
  puts "#{post.original_link} #{post.postrank}"
end