Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Support for other default lists

  • Loading branch information...
commit 020842be1c140613b8a80c799df6c9b765a7969b 1 parent 603b759
Wynn Netherland authored
Showing with 33 additions and 4 deletions.
  1. +32 −3 lib/readernaut.rb
  2. +1 −1  test/test_readernaut.rb
View
35 lib/readernaut.rb
@@ -12,13 +12,42 @@ class Readernaut
format :json
def self.books(username, options={})
- Mash.new self.get("/#{username}/books/", :query => options)
+ path = "/#{username}/books/"
+ list = options.delete(:list)
+ path += "#{list}/" unless list.blank?
+ Mash.new self.get(path, :query => options)
+ end
+
+ def self.books_finished(username, options={})
+ opts = options.merge({:list => 'finished'})
+ self.books(username, opts)
+ end
+
+ def self.books_reading(username, options={})
+ opts = options.merge({:list => 'reading'})
+ self.books(username, opts)
+ end
+
+ def self.books_plan_to_read(username, options={})
+ opts = options.merge({:list => 'plan-to-read'})
+ self.books(username, opts)
+ end
+
+ def self.books_reference(username, options={})
+ opts = options.merge({:list => 'reference'})
+ self.books(username, opts)
end
- def self.books_currently_reading(username, options={})
- Mash.new self.get("/#{username}/books/reading/", :query => options)
+ def self.books_wishlist(username, options={})
+ opts = options.merge({:list => 'wishlist'})
+ self.books(username, opts)
end
+ def self.books_abandoned(username, options={})
+ opts = options.merge({:list => 'abandoned'})
+ self.books(username, opts)
+ end
+
def self.notes(username, options={})
Mash.new self.get("/#{username}/notes/", :query => options)
end
View
2  test/test_readernaut.rb
@@ -29,7 +29,7 @@ class TestReadernaut < Test::Unit::TestCase
should "retrieve a list of books being read for a user" do
stub_get "http://readernaut.com/api/v1/json/nathan/books/reading/", "books_currently_reading.json"
- results = Readernaut.books_currently_reading('nathan')
+ results = Readernaut.books_reading('nathan')
edition = results.reader_books.first.book_edition
edition.title.should == "Towards a New Architecture"
edition.isbn.should == '0486250237'
Please sign in to comment.
Something went wrong with that request. Please try again.