readernaut 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,44 @@
1
+ # Readernaut
2
+
3
+ Wrapper for [Readernaut](http://readernaut.com) API, the social book site.
4
+
5
+ ## Installation
6
+
7
+ sudo gem install gemcutter
8
+ gem tumble
9
+ sudo gem install readernaut
10
+
11
+ ## Usage
12
+
13
+ # get a list of books for a user
14
+ books = Readernaut.books('pengwynn')
15
+ books.reader_books.first.book_edition.title
16
+ => 'Crush it!'
17
+
18
+ # get a list of notes for a user
19
+ notes = Readernaut.notes('pengwynn')
20
+
21
+ # get a list of contacts for a user
22
+ contacts = Readernaut.contacts('pengwynn').contacts
23
+ contacts.last.user.username
24
+ => "blankenship"
25
+
26
+ # paginate, ordering
27
+ books = Readernaut.books('pengwynn', :page => 3, :order_by => "modified")
28
+ # descending
29
+ books = Readernaut.books('pengwynn', :page => 3, :order_by => "-modified")
30
+
31
+ ## Note on Patches/Pull Requests
32
+
33
+ * Fork the project.
34
+ * Make your feature addition or bug fix.
35
+ * Add tests for it. This is important so I don't break it in a
36
+ future version unintentionally.
37
+ * Commit, do not mess with rakefile, version, or history.
38
+ (if you want to have your own version, that is fine but
39
+ bump version in a commit by itself I can ignore when I pull)
40
+ * Send me a pull request. Bonus points for topic branches.
41
+
42
+ ## Copyright
43
+
44
+ Copyright (c) 2009 [Wynn Netherland](http://wynnnetherland.com). See LICENSE for details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.2.0
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+
3
+ ## 0.2.0 - November 17, 2009
4
+
5
+ * Support for finished, reading, plan-to-read and other lists, thanks [rizwanreza](http://github.com/rizwanreza)
6
+
7
+ ## 0.1.0 - November 15, 2009
8
+
9
+ * Initial version
@@ -12,9 +12,42 @@ class Readernaut
12
12
  format :json
13
13
 
14
14
  def self.books(username, options={})
15
- Mash.new self.get("/#{username}/books/", :query => options)
15
+ path = "/#{username}/books/"
16
+ list = options.delete(:list)
17
+ path += "#{list}/" unless list.blank?
18
+ Mash.new self.get(path, :query => options)
19
+ end
20
+
21
+ def self.books_finished(username, options={})
22
+ opts = options.merge({:list => 'finished'})
23
+ self.books(username, opts)
24
+ end
25
+
26
+ def self.books_reading(username, options={})
27
+ opts = options.merge({:list => 'reading'})
28
+ self.books(username, opts)
29
+ end
30
+
31
+ def self.books_plan_to_read(username, options={})
32
+ opts = options.merge({:list => 'plan-to-read'})
33
+ self.books(username, opts)
16
34
  end
17
35
 
36
+ def self.books_reference(username, options={})
37
+ opts = options.merge({:list => 'reference'})
38
+ self.books(username, opts)
39
+ end
40
+
41
+ def self.books_wishlist(username, options={})
42
+ opts = options.merge({:list => 'wishlist'})
43
+ self.books(username, opts)
44
+ end
45
+
46
+ def self.books_abandoned(username, options={})
47
+ opts = options.merge({:list => 'abandoned'})
48
+ self.books(username, opts)
49
+ end
50
+
18
51
  def self.notes(username, options={})
19
52
  Mash.new self.get("/#{username}/notes/", :query => options)
20
53
  end
@@ -5,27 +5,29 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{readernaut}
8
- s.version = "0.1.2"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Wynn Netherland"]
12
- s.date = %q{2009-11-14}
12
+ s.date = %q{2009-11-17}
13
13
  s.description = %q{Wrapper for Readernaut, the best book social network around}
14
14
  s.email = %q{wynn.netherland@gmail.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
17
- "README.rdoc"
17
+ "README.markdown"
18
18
  ]
19
19
  s.files = [
20
20
  ".document",
21
21
  ".gitignore",
22
22
  "LICENSE",
23
- "README.rdoc",
23
+ "README.markdown",
24
24
  "Rakefile",
25
25
  "VERSION",
26
+ "changelog.markdown",
26
27
  "lib/readernaut.rb",
27
28
  "readernaut.gemspec",
28
29
  "test/fixtures/books.json",
30
+ "test/fixtures/books_currently_reading.json",
29
31
  "test/fixtures/contacts.json",
30
32
  "test/fixtures/notes.json",
31
33
  "test/helper.rb",
@@ -0,0 +1,262 @@
1
+ {
2
+ "version": "1.0",
3
+ "page": 1,
4
+ "total_pages": 2,
5
+ "reader_books": [
6
+
7
+ {
8
+ "reader_book_id": 176505,
9
+ "user": {
10
+ "user_id": 1,
11
+ "username": "nathan"
12
+ },
13
+ "book_edition": {
14
+ "title": "Towards a New Architecture",
15
+ "subtitle": "",
16
+ "authors": {
17
+ "author": "Le Corbusier"
18
+ },
19
+ "isbn": "0486250237",
20
+ "covers": {
21
+ "cover_small": "http://media.readernaut.com/book_covers/0486250237_t50.jpg",
22
+ "cover_medium": "http://media.readernaut.com/book_covers/0486250237_t100.jpg",
23
+ "cover_large": "http://media.readernaut.com/book_covers/0486250237_t150.jpg"
24
+ },
25
+ "permalink": "http://readernaut.com/nathan/books/0486250237/towards-a-new-architecture/"
26
+ },
27
+ "created": "2009-09-23 1:35 CDT",
28
+ "modified": "2009-10-28 0:34 CDT",
29
+ "permalink": "http://readernaut.com/nathan/books/0486250237/towards-a-new-architecture/"
30
+ },
31
+
32
+ {
33
+ "reader_book_id": 171886,
34
+ "user": {
35
+ "user_id": 1,
36
+ "username": "nathan"
37
+ },
38
+ "book_edition": {
39
+ "title": "From Cliche to Archetype",
40
+ "subtitle": "",
41
+ "authors": {
42
+ "author": "Marshall McLuhan",
43
+ "author": "Wilfred Watson"
44
+ },
45
+ "isbn": "B0028GH156",
46
+ "covers": {
47
+ "cover_small": "http://media.readernaut.com/book_covers/B0028GH156__t50.jpg",
48
+ "cover_medium": "http://media.readernaut.com/book_covers/B0028GH156__t100.jpg",
49
+ "cover_large": "http://media.readernaut.com/book_covers/B0028GH156__t150.jpg"
50
+ },
51
+ "permalink": "http://readernaut.com/nathan/books/B0028GH156/from-cliche-to-archetype/"
52
+ },
53
+ "created": "2009-09-13 12:25 CDT",
54
+ "modified": "2009-11-14 11:22 CST",
55
+ "permalink": "http://readernaut.com/nathan/books/B0028GH156/from-cliche-to-archetype/"
56
+ },
57
+
58
+ {
59
+ "reader_book_id": 169152,
60
+ "user": {
61
+ "user_id": 1,
62
+ "username": "nathan"
63
+ },
64
+ "book_edition": {
65
+ "title": "Frank Lloyd Wright",
66
+ "subtitle": "Essential Texts",
67
+ "authors": {
68
+ },
69
+ "isbn": "0393732614",
70
+ "covers": {
71
+ "cover_small": "http://media.readernaut.com/book_covers/0393732614_t50.jpg",
72
+ "cover_medium": "http://media.readernaut.com/book_covers/0393732614_t100.jpg",
73
+ "cover_large": "http://media.readernaut.com/book_covers/0393732614_t150.jpg"
74
+ },
75
+ "permalink": "http://readernaut.com/nathan/books/0393732614/frank-lloyd-wright/"
76
+ },
77
+ "created": "2009-09-06 20:35 CDT",
78
+ "modified": "2009-09-06 20:38 CDT",
79
+ "permalink": "http://readernaut.com/nathan/books/0393732614/frank-lloyd-wright/"
80
+ },
81
+
82
+ {
83
+ "reader_book_id": 156197,
84
+ "user": {
85
+ "user_id": 1,
86
+ "username": "nathan"
87
+ },
88
+ "book_edition": {
89
+ "title": "Utopia",
90
+ "subtitle": "Thomas More",
91
+ "authors": {
92
+ "author": "Sir",
93
+ "author": "Thomas",
94
+ "author": "Saint More"
95
+ },
96
+ "isbn": "0300084293",
97
+ "covers": {
98
+ "cover_small": "http://media.readernaut.com/book_covers/0300084293_t50.jpg",
99
+ "cover_medium": "http://media.readernaut.com/book_covers/0300084293_t100.jpg",
100
+ "cover_large": "http://media.readernaut.com/book_covers/0300084293_t150.jpg"
101
+ },
102
+ "permalink": "http://readernaut.com/nathan/books/0300084293/utopia/"
103
+ },
104
+ "created": "2009-08-06 0:18 CDT",
105
+ "modified": "2009-08-15 10:12 CDT",
106
+ "permalink": "http://readernaut.com/nathan/books/0300084293/utopia/"
107
+ },
108
+
109
+ {
110
+ "reader_book_id": 138377,
111
+ "user": {
112
+ "user_id": 1,
113
+ "username": "nathan"
114
+ },
115
+ "book_edition": {
116
+ "title": "The Pleasures and Sorrows of Work",
117
+ "subtitle": "",
118
+ "authors": {
119
+ "author": "Alain De Botton"
120
+ },
121
+ "isbn": "037542444X",
122
+ "covers": {
123
+ "cover_small": "http://media.readernaut.com/book_covers/037542444X_t50.jpg",
124
+ "cover_medium": "http://media.readernaut.com/book_covers/037542444X_t100.jpg",
125
+ "cover_large": "http://media.readernaut.com/book_covers/037542444X_t150.jpg"
126
+ },
127
+ "permalink": "http://readernaut.com/nathan/books/037542444X/the-pleasures-and-sorrows-of-work/"
128
+ },
129
+ "created": "2009-06-17 22:31 CDT",
130
+ "modified": "2009-08-24 1:34 CDT",
131
+ "permalink": "http://readernaut.com/nathan/books/037542444X/the-pleasures-and-sorrows-of-work/"
132
+ },
133
+
134
+ {
135
+ "reader_book_id": 39162,
136
+ "user": {
137
+ "user_id": 1,
138
+ "username": "nathan"
139
+ },
140
+ "book_edition": {
141
+ "title": "1776",
142
+ "subtitle": "",
143
+ "authors": {
144
+ "author": "David McCullough"
145
+ },
146
+ "isbn": "0743226720",
147
+ "covers": {
148
+ "cover_small": "http://media.readernaut.com/book_covers/0743226720_t50.jpg",
149
+ "cover_medium": "http://media.readernaut.com/book_covers/0743226720_t100.jpg",
150
+ "cover_large": "http://media.readernaut.com/book_covers/0743226720_t150.jpg"
151
+ },
152
+ "permalink": "http://readernaut.com/nathan/books/0743226720/1776/"
153
+ },
154
+ "created": "2008-12-03 21:11 CST",
155
+ "modified": "2009-08-31 1:08 CDT",
156
+ "permalink": "http://readernaut.com/nathan/books/0743226720/1776/"
157
+ },
158
+
159
+ {
160
+ "reader_book_id": 27953,
161
+ "user": {
162
+ "user_id": 1,
163
+ "username": "nathan"
164
+ },
165
+ "book_edition": {
166
+ "title": "The Adams\x2DJefferson Letters",
167
+ "subtitle": "The Complete Correspondence Between Thomas Jefferson and Abigail and John Adams",
168
+ "authors": {
169
+ "author": "John Adams",
170
+ "author": "Lester J. Cappon"
171
+ },
172
+ "isbn": "0807842303",
173
+ "covers": {
174
+ "cover_small": "http://media.readernaut.com/book_covers/0807842303_t50.jpg",
175
+ "cover_medium": "http://media.readernaut.com/book_covers/0807842303_t100.jpg",
176
+ "cover_large": "http://media.readernaut.com/book_covers/0807842303_t150.jpg"
177
+ },
178
+ "permalink": "http://readernaut.com/nathan/books/0807842303/the-adams-jefferson-letters/"
179
+ },
180
+ "created": "2008-10-05 1:34 CDT",
181
+ "modified": "2009-05-08 10:57 CDT",
182
+ "permalink": "http://readernaut.com/nathan/books/0807842303/the-adams-jefferson-letters/"
183
+ },
184
+
185
+ {
186
+ "reader_book_id": 4640,
187
+ "user": {
188
+ "user_id": 1,
189
+ "username": "nathan"
190
+ },
191
+ "book_edition": {
192
+ "title": "Programming Collective Intelligence",
193
+ "subtitle": "Building Smart Web 2.0 Applications",
194
+ "authors": {
195
+ "author": "Toby Segaran"
196
+ },
197
+ "isbn": "0596529325",
198
+ "covers": {
199
+ "cover_small": "http://media.readernaut.com/book_covers/0596529325_t50.jpg",
200
+ "cover_medium": "http://media.readernaut.com/book_covers/0596529325_t100.jpg",
201
+ "cover_large": "http://media.readernaut.com/book_covers/0596529325_t150.jpg"
202
+ },
203
+ "permalink": "http://readernaut.com/nathan/books/0596529325/programming-collective-intelligence/"
204
+ },
205
+ "created": "2008-08-16 1:19 CDT",
206
+ "modified": "2009-05-08 10:56 CDT",
207
+ "permalink": "http://readernaut.com/nathan/books/0596529325/programming-collective-intelligence/"
208
+ },
209
+
210
+ {
211
+ "reader_book_id": 1976,
212
+ "user": {
213
+ "user_id": 1,
214
+ "username": "nathan"
215
+ },
216
+ "book_edition": {
217
+ "title": "Infinite Jest",
218
+ "subtitle": "",
219
+ "authors": {
220
+ "author": "David Foster Wallace"
221
+ },
222
+ "isbn": "0316066524",
223
+ "covers": {
224
+ "cover_small": "http://media.readernaut.com/book_covers/0316066524_t50.jpg",
225
+ "cover_medium": "http://media.readernaut.com/book_covers/0316066524_t100.jpg",
226
+ "cover_large": "http://media.readernaut.com/book_covers/0316066524_t150.jpg"
227
+ },
228
+ "permalink": "http://readernaut.com/nathan/books/0316066524/infinite-jest/"
229
+ },
230
+ "created": "2008-08-11 1:53 CDT",
231
+ "modified": "2009-07-26 8:48 CDT",
232
+ "permalink": "http://readernaut.com/nathan/books/0316066524/infinite-jest/"
233
+ },
234
+
235
+ {
236
+ "reader_book_id": 1975,
237
+ "user": {
238
+ "user_id": 1,
239
+ "username": "nathan"
240
+ },
241
+ "book_edition": {
242
+ "title": "Sketching User Experiences",
243
+ "subtitle": "Getting the Design Right and the Right Design",
244
+ "authors": {
245
+ "author": "Bill Buxton"
246
+ },
247
+ "isbn": "0123740371",
248
+ "covers": {
249
+ "cover_small": "http://media.readernaut.com/book_covers/0123740371__t50.jpg",
250
+ "cover_medium": "http://media.readernaut.com/book_covers/0123740371__t100.jpg",
251
+ "cover_large": "http://media.readernaut.com/book_covers/0123740371__t150.jpg"
252
+ },
253
+ "permalink": "http://readernaut.com/nathan/books/0123740371/sketching-user-experiences/"
254
+ },
255
+ "created": "2008-08-11 1:53 CDT",
256
+ "modified": "2009-11-05 0:32 CST",
257
+ "permalink": "http://readernaut.com/nathan/books/0123740371/sketching-user-experiences/"
258
+ }
259
+
260
+ ]
261
+ }
262
+
@@ -26,6 +26,15 @@ class TestReadernaut < Test::Unit::TestCase
26
26
  results.page.should == 2
27
27
  results.contacts.first.user.username.should == 'spacecowboyian'
28
28
  end
29
+
30
+ should "retrieve a list of books being read for a user" do
31
+ stub_get "http://readernaut.com/api/v1/json/nathan/books/reading/", "books_currently_reading.json"
32
+ results = Readernaut.books_reading('nathan')
33
+ edition = results.reader_books.first.book_edition
34
+ edition.title.should == "Towards a New Architecture"
35
+ edition.isbn.should == '0486250237'
36
+ edition.covers.cover_large.should == 'http://media.readernaut.com/book_covers/0486250237_t150.jpg'
37
+ end
29
38
  end
30
39
 
31
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: readernaut
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Wynn Netherland
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-14 00:00:00 -06:00
12
+ date: 2009-11-17 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -80,17 +80,19 @@ extensions: []
80
80
 
81
81
  extra_rdoc_files:
82
82
  - LICENSE
83
- - README.rdoc
83
+ - README.markdown
84
84
  files:
85
85
  - .document
86
86
  - .gitignore
87
87
  - LICENSE
88
- - README.rdoc
88
+ - README.markdown
89
89
  - Rakefile
90
90
  - VERSION
91
+ - changelog.markdown
91
92
  - lib/readernaut.rb
92
93
  - readernaut.gemspec
93
94
  - test/fixtures/books.json
95
+ - test/fixtures/books_currently_reading.json
94
96
  - test/fixtures/contacts.json
95
97
  - test/fixtures/notes.json
96
98
  - test/helper.rb
@@ -1,18 +0,0 @@
1
- = readernaut
2
-
3
- Description goes here.
4
-
5
- == Note on Patches/Pull Requests
6
-
7
- * Fork the project.
8
- * Make your feature addition or bug fix.
9
- * Add tests for it. This is important so I don't break it in a
10
- future version unintentionally.
11
- * Commit, do not mess with rakefile, version, or history.
12
- (if you want to have your own version, that is fine but
13
- bump version in a commit by itself I can ignore when I pull)
14
- * Send me a pull request. Bonus points for topic branches.
15
-
16
- == Copyright
17
-
18
- Copyright (c) 2009 Wynn Netherland. See LICENSE for details.