public
Fork of dj2/ruby-postrank
Description: Ruby PostRank Wrapper by Dan Sinclair
Homepage: http://github.com/dj2/ruby-postrank/wikis
Clone URL: git://github.com/aiderss/ruby-postrank.git
joshbuddy (author)
Tue Jan 06 09:04:57 -0800 2009
aiderss (committer)
Tue Jan 06 09:12:33 -0800 2009
commit  002db1c27dab1b5c9b70958b580a21725e9f5087
tree    f32c17d851e6af8392d5b7b631048528c48af846
parent  ac408ccef708aa2c016aaab3966578efeae6bb5b
name age message
file .gitignore Wed Jul 16 18:30:43 -0700 2008 Fix gem creation [dj2]
file COPYING Tue Jul 15 19:19:13 -0700 2008 Add copying and gemspec files. Update readme [dj2]
file README.rdoc Wed Dec 31 08:59:34 -0800 2008 fixup documentation. Thanks Igor. Signed-off-b... [dan sinclair]
file Rakefile Wed Dec 31 08:59:32 -0800 2008 nuke test entry, make gem default Signed-off-b... [dj2]
directory examples/ Tue Jan 06 09:12:33 -0800 2009 added recommend to api Signed-off-by: dj2 <dj2... [joshbuddy]
directory lib/ Tue Jan 06 09:12:33 -0800 2009 added recommend to api Signed-off-by: dj2 <dj2... [joshbuddy]
file postrank.gemspec Tue Jan 06 09:12:33 -0800 2009 added recommend to api Signed-off-by: dj2 <dj2... [joshbuddy]
README.rdoc

Ruby PostRank

A simple wrapper around the PostRank.com REST API. I’ve tried to keep the API simple without it being a bare API wrapper.

Dependencies

You will need the OAuth gem installed in order to use Ruby PostRank.

  - sudo gem install oauth

Walkthrough

I’ve tried to keep the API as simple as possible. It’s about one step above the bare PostRank API. Hopefully the added abstraction is useful. The easiest way to explain this is probably to show an example. So, here we go.

  #!/usr/bin/env ruby

  require 'rubygems'
  require 'postrank'

  include PostRank

  conn = Connection.instance
  conn.appkey = "everburning.com/ruby-postrank"
  eb = Feed.find_by_url("http://everburning.com")

  puts "The GREAT everburning feeds"
  eb.entries(:level => Level::GREAT).each do |entry|
    puts entry
  end

  puts "\nThe top 5 posts in the last week on everburning"
  eb.topposts(:period => Period::WEEK).each do |entry|
    puts "#{entry.title} -- #{entry.postrank} -- #{entry.postrank_color}"
  end

  puts "\nGet thematic PostRanked items"
  PostRank::PostRank.calculate(["http://flickr.com/photos/14009462@N00/2654539960/",
                    "http://www.flickr.com/photos/21418584@N07/2447928272/",
                    "http://www.flickr.com/photos/pilou/2655293624/"]).each do |entry|
    puts "#{entry.original_link} #{entry.postrank}"
  end

  puts "\nGet PostRanked items"
  PostRank::PostRank.calculate(['http://everburning.com/news/on-recent-media/',
                    'http://everburning.com/news/californication/',
                    'http://everburning.com/news/the-weary-traveler/'],
              :feeds => [eb]).each do |entry|
    puts "#{entry.original_link} #{entry.postrank}"
  end

That’s basically it.

Contact

If you’ve got any questions, comments or bugs, please let me know. You can contact me by email at dan at aiderss dot com.