goodreads 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/goodreads/client/reviews.rb +12 -0
- data/lib/goodreads/version.rb +1 -1
- data/spec/client_spec.rb +37 -0
- data/spec/fixtures/reviews.xml +135 -0
- data/spec/fixtures/reviews_empty.xml +10 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a55562550afaad324257b5662c49cd4b5795348
|
4
|
+
data.tar.gz: 3153d5c577af053de337def0170680c22dbbf6f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9cbcece870be588b5f0769cd7806ab13a8538aaf7a7c54fd3188cac999aedc782ccfe0309b1c0dceacc7f2fefa39415c78b3594493eb65b4ac4b58d796ae6386
|
7
|
+
data.tar.gz: b79e4f95f116fa25a1c4da5e188a8ac15e62deceac3ffaeb5b7f404bc37b9599b225a57e22994ab00beb47c25fee8eeacbc0cff750aa3f8fa8314c658b2b60a3
|
@@ -20,5 +20,17 @@ module Goodreads
|
|
20
20
|
data = request('/review/show', :id => id)
|
21
21
|
Hashie::Mash.new(data['review'])
|
22
22
|
end
|
23
|
+
|
24
|
+
# Get list of reviews
|
25
|
+
#
|
26
|
+
def reviews(params={})
|
27
|
+
data = request('/review/list', params.merge(:v => '2'))
|
28
|
+
reviews = data['reviews']['review']
|
29
|
+
if reviews.present?
|
30
|
+
reviews.map { |review| Hashie::Mash.new(review) }
|
31
|
+
else
|
32
|
+
[]
|
33
|
+
end
|
34
|
+
end
|
23
35
|
end
|
24
36
|
end
|
data/lib/goodreads/version.rb
CHANGED
data/spec/client_spec.rb
CHANGED
@@ -116,6 +116,43 @@ describe 'Client' do
|
|
116
116
|
end
|
117
117
|
end
|
118
118
|
|
119
|
+
describe '#reviews' do
|
120
|
+
subject { client.reviews(id: user_id, shelf: shelf) }
|
121
|
+
let(:user_id) { '5076380' }
|
122
|
+
let(:shelf) { 'to-read' }
|
123
|
+
|
124
|
+
before { stub_with_key_get('/review/list', {:v => '2', :id => user_id, :shelf => shelf}, response_fixture) }
|
125
|
+
let(:response_fixture) { 'reviews.xml' }
|
126
|
+
|
127
|
+
it 'returns a list of reviews' do
|
128
|
+
subject.should be_a Array
|
129
|
+
subject.count.should eq 2
|
130
|
+
subject.first.should be_a Hashie::Mash
|
131
|
+
subject.first.keys.should include(*['book', 'rating', 'started_at', 'read_at'])
|
132
|
+
subject.map(&:id).should eq(['1371624338', '1371623371'])
|
133
|
+
end
|
134
|
+
|
135
|
+
context 'when there are no more reviews' do
|
136
|
+
let(:response_fixture) { 'reviews_empty.xml' }
|
137
|
+
|
138
|
+
it 'returns an empty array' do
|
139
|
+
subject.should be_a Array
|
140
|
+
subject.count.should eq 0
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
context 'when user does not exist' do
|
145
|
+
before do
|
146
|
+
stub_request(:get, "http://www.goodreads.com/review/list?v=2&format=xml&id=#{user_id}&key=SECRET_KEY&shelf=#{shelf}").
|
147
|
+
to_return(:status => 404, :body => "", :headers => {})
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'raises Goodreads::NotFound' do
|
151
|
+
expect { subject }.to raise_error Goodreads::NotFound
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
119
156
|
describe '#author' do
|
120
157
|
before { stub_with_key_get('/author/show', {:id => '18541'}, 'author.xml') }
|
121
158
|
|
@@ -0,0 +1,135 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<GoodreadsResponse>
|
3
|
+
<Request>
|
4
|
+
<authentication>true</authentication>
|
5
|
+
<key><![CDATA[SECRET_KEY]]></key>
|
6
|
+
<method><![CDATA[review_list]]></method>
|
7
|
+
</Request>
|
8
|
+
<reviews start="1" end="2" total="2">
|
9
|
+
<review>
|
10
|
+
<id>1371624338</id>
|
11
|
+
<book>
|
12
|
+
<id type="integer">77507</id>
|
13
|
+
<isbn>0553560735</isbn>
|
14
|
+
<isbn13>9780553560732</isbn13>
|
15
|
+
<text_reviews_count type="integer">1442</text_reviews_count>
|
16
|
+
<title>Red Mars (Mars Trilogy, #1)</title>
|
17
|
+
<image_url>https://s.gr-assets.com/assets/nophoto/book/111x148-bcc042a9c91a29c1d680899eff700a03.png</image_url>
|
18
|
+
<small_image_url>https://s.gr-assets.com/assets/nophoto/book/50x75-a91bf249278a81aabab721ef782c4a74.png</small_image_url>
|
19
|
+
<large_image_url/>
|
20
|
+
<link>https://www.goodreads.com/book/show/77507.Red_Mars</link>
|
21
|
+
<num_pages>572</num_pages>
|
22
|
+
<format>Mass Market Paperback</format>
|
23
|
+
<edition_information/>
|
24
|
+
<publisher>Spectra</publisher>
|
25
|
+
<publication_day>1</publication_day>
|
26
|
+
<publication_year>1993</publication_year>
|
27
|
+
<publication_month>10</publication_month>
|
28
|
+
<average_rating>3.81</average_rating>
|
29
|
+
<ratings_count>36620</ratings_count>
|
30
|
+
<description>In his most ambitious project to date, award-winning author Kim Stanley Robinson utilizes years of research and cutting-edge science in the first of three novels that will chronicle the colonization of Mars.<br><br>For eons, sandstorms have swept the barren desolate landscape of the red planet. For centuries, Mars has beckoned to mankind to come and conquer its hostile climate. Now, in the year 2026, a group of one hundred colonists is about to fulfill that destiny.<br><br>John Boone, Maya Toitavna, Frank Chalmers, and Arkady Bogdanov lead a mission whose ultimate goal is the terraforming of Mars. For some, Mars will become a passion driving them to daring acts of courage and madness; for others it offers and opportunity to strip the planet of its riches. And for the genetic "alchemists, " Mars presents a chance to create a biomedical miracle, a breakthrough that could change all we know about life...and death.<br><br>The colonists place giant satellite mirrors in Martian orbit to reflect light to the planets surface. Black dust sprinkled on the polar caps will capture warmth and melt the ice. And massive tunnels, kilometers in depth, will be drilled into the Martian mantle to create stupendous vents of hot gases. Against this backdrop of epic upheaval, rivalries, loves, and friendships will form and fall to pieces--for there are those who will fight to the death to prevent Mars from ever being changed.<br><br>Brilliantly imagined, breathtaking in scope and ingenuity, <em>Red Mars</em> is an epic scientific saga, chronicling the next step in human evolution and creating a world in its entirety. <em>Red Mars</em> shows us a future, with both glory and tarnish, that awes with complexity and inspires with vision.</description>
|
31
|
+
<authors>
|
32
|
+
<author>
|
33
|
+
<id>1858</id>
|
34
|
+
<name>Kim Stanley Robinson</name>
|
35
|
+
<role></role>
|
36
|
+
<image_url>
|
37
|
+
<![CDATA[https://d.gr-assets.com/authors/1376955089p5/1858.jpg]]>
|
38
|
+
</image_url>
|
39
|
+
<small_image_url>
|
40
|
+
<![CDATA[https://d.gr-assets.com/authors/1376955089p2/1858.jpg]]>
|
41
|
+
</small_image_url>
|
42
|
+
<link><![CDATA[https://www.goodreads.com/author/show/1858.Kim_Stanley_Robinson]]></link>
|
43
|
+
<average_rating>3.78</average_rating>
|
44
|
+
<ratings_count>112948</ratings_count>
|
45
|
+
<text_reviews_count>7090</text_reviews_count>
|
46
|
+
</author>
|
47
|
+
</authors>
|
48
|
+
<published>1993</published>
|
49
|
+
</book>
|
50
|
+
<rating>0</rating>
|
51
|
+
<votes>0</votes>
|
52
|
+
<spoiler_flag>false</spoiler_flag>
|
53
|
+
<spoilers_state>none</spoilers_state>
|
54
|
+
<shelves>
|
55
|
+
<shelf name="to-read" exclusive="true" review_shelf_id="1066952249" sortable="true" />
|
56
|
+
</shelves>
|
57
|
+
<recommended_for></recommended_for>
|
58
|
+
<recommended_by></recommended_by>
|
59
|
+
<started_at></started_at>
|
60
|
+
<read_at></read_at>
|
61
|
+
<date_added>Sun Aug 23 09:25:13 -0700 2015</date_added>
|
62
|
+
<date_updated>Sun Aug 23 09:25:14 -0700 2015</date_updated>
|
63
|
+
<read_count></read_count>
|
64
|
+
<body>
|
65
|
+
</body>
|
66
|
+
<comments_count>0</comments_count>
|
67
|
+
<url><![CDATA[https://www.goodreads.com/review/show/1371624338]]></url>
|
68
|
+
<link><![CDATA[https://www.goodreads.com/review/show/1371624338]]></link>
|
69
|
+
<owned>0</owned>
|
70
|
+
</review>
|
71
|
+
|
72
|
+
<review>
|
73
|
+
<id>1371623371</id>
|
74
|
+
<book>
|
75
|
+
<id type="integer">48002</id>
|
76
|
+
<isbn>0061031321</isbn>
|
77
|
+
<isbn13>9780061031328</isbn13>
|
78
|
+
<text_reviews_count type="integer">626</text_reviews_count>
|
79
|
+
<title>Thief of Time (Discworld, #26; Death, #5)</title>
|
80
|
+
<image_url>https://s.gr-assets.com/assets/nophoto/book/111x148-bcc042a9c91a29c1d680899eff700a03.png</image_url>
|
81
|
+
<small_image_url>https://s.gr-assets.com/assets/nophoto/book/50x75-a91bf249278a81aabab721ef782c4a74.png</small_image_url>
|
82
|
+
<large_image_url/>
|
83
|
+
<link>https://www.goodreads.com/book/show/48002.Thief_of_Time</link>
|
84
|
+
<num_pages>378</num_pages>
|
85
|
+
<format>Paperback</format>
|
86
|
+
<edition_information/>
|
87
|
+
<publisher>Harper</publisher>
|
88
|
+
<publication_day/>
|
89
|
+
<publication_year>2008</publication_year>
|
90
|
+
<publication_month/>
|
91
|
+
<average_rating>4.21</average_rating>
|
92
|
+
<ratings_count>38369</ratings_count>
|
93
|
+
<description>Time is a resource. Everyone knows it has to be managed.<br>And on Discworld that is the job of the Monks of History, who store it and pump it from the places where it's wasted (like underwater -- how much time does a codfish need?) to places like cities, where there's never enough time.<br>But the construction of the world's first truly accurate clock starts a race against, well, time, for Lu Tze and his apprentice Lobsang Ludd. Because it will stop time. And that will only be the start of everyone's problems.<br>Thief of Time comes complete with a full supporting cast of heroes and villains, yetis, martial artists and Ronnie, the fifth Horseman of the Apocalypse (who left before they became famous).</description>
|
94
|
+
<authors>
|
95
|
+
<author>
|
96
|
+
<id>1654</id>
|
97
|
+
<name>Terry Pratchett</name>
|
98
|
+
<role></role>
|
99
|
+
<image_url>
|
100
|
+
<![CDATA[https://d.gr-assets.com/authors/1235562205p5/1654.jpg]]>
|
101
|
+
</image_url>
|
102
|
+
<small_image_url>
|
103
|
+
<![CDATA[https://d.gr-assets.com/authors/1235562205p2/1654.jpg]]>
|
104
|
+
</small_image_url>
|
105
|
+
<link><![CDATA[https://www.goodreads.com/author/show/1654.Terry_Pratchett]]></link>
|
106
|
+
<average_rating>4.11</average_rating>
|
107
|
+
<ratings_count>2442891</ratings_count>
|
108
|
+
<text_reviews_count>73518</text_reviews_count>
|
109
|
+
</author>
|
110
|
+
</authors>
|
111
|
+
<published>2008</published>
|
112
|
+
</book>
|
113
|
+
<rating>0</rating>
|
114
|
+
<votes>0</votes>
|
115
|
+
<spoiler_flag>false</spoiler_flag>
|
116
|
+
<spoilers_state>none</spoilers_state>
|
117
|
+
<shelves>
|
118
|
+
<shelf name="to-read" exclusive="true" review_shelf_id="1066951362" sortable="true" />
|
119
|
+
</shelves>
|
120
|
+
<recommended_for></recommended_for>
|
121
|
+
<recommended_by></recommended_by>
|
122
|
+
<started_at></started_at>
|
123
|
+
<read_at></read_at>
|
124
|
+
<date_added>Sun Aug 23 09:23:51 -0700 2015</date_added>
|
125
|
+
<date_updated>Sun Aug 23 09:23:52 -0700 2015</date_updated>
|
126
|
+
<read_count></read_count>
|
127
|
+
<body>
|
128
|
+
</body>
|
129
|
+
<comments_count>0</comments_count>
|
130
|
+
<url><![CDATA[https://www.goodreads.com/review/show/1371623371]]></url>
|
131
|
+
<link><![CDATA[https://www.goodreads.com/review/show/1371623371]]></link>
|
132
|
+
<owned>0</owned>
|
133
|
+
</review>
|
134
|
+
</reviews>
|
135
|
+
</GoodreadsResponse>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<GoodreadsResponse>
|
3
|
+
<Request>
|
4
|
+
<authentication>true</authentication>
|
5
|
+
<key><![CDATA[SECRET_KEY]]></key>
|
6
|
+
<method><![CDATA[review_list]]></method>
|
7
|
+
</Request>
|
8
|
+
<reviews start="0" end="0" total="2">
|
9
|
+
</reviews>
|
10
|
+
</GoodreadsResponse>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: goodreads
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Sosedoff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: webmock
|
@@ -191,6 +191,8 @@ files:
|
|
191
191
|
- spec/fixtures/oauth_response.xml
|
192
192
|
- spec/fixtures/recent_reviews.xml
|
193
193
|
- spec/fixtures/review.xml
|
194
|
+
- spec/fixtures/reviews.xml
|
195
|
+
- spec/fixtures/reviews_empty.xml
|
194
196
|
- spec/fixtures/search_books_by_name.xml
|
195
197
|
- spec/fixtures/to-read-p2.xml
|
196
198
|
- spec/fixtures/to-read.xml
|
@@ -234,6 +236,8 @@ test_files:
|
|
234
236
|
- spec/fixtures/oauth_response.xml
|
235
237
|
- spec/fixtures/recent_reviews.xml
|
236
238
|
- spec/fixtures/review.xml
|
239
|
+
- spec/fixtures/reviews.xml
|
240
|
+
- spec/fixtures/reviews_empty.xml
|
237
241
|
- spec/fixtures/search_books_by_name.xml
|
238
242
|
- spec/fixtures/to-read-p2.xml
|
239
243
|
- spec/fixtures/to-read.xml
|