googlebooks 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/googlebooks.rb +7 -5
- data/lib/version.rb +1 -1
- metadata +6 -6
data/lib/googlebooks.rb
CHANGED
@@ -20,19 +20,21 @@ module GoogleBooks
|
|
20
20
|
# 2nd param passes options hash:
|
21
21
|
# * :count passes number of results to display per page (default=5)
|
22
22
|
# * :page passes the page number (default=1)
|
23
|
+
# * :api_key passes the application specific Google API key
|
23
24
|
#
|
24
25
|
# 3rd parameter optionally passes user's IP address
|
25
26
|
# * User IP may be require in order for request to be made to the
|
26
27
|
# Google API from applications residing on decentralized cloud servers
|
27
28
|
# See http://www.google.com/support/forum/p/booksearch-apis/thread?tid=2034bed9a98c15cb&hl=en
|
28
29
|
|
29
|
-
def search(query,
|
30
|
+
def search(query, options = {}, remote_ip = nil)
|
30
31
|
(headers 'X-Forwarded-For' => remote_ip.to_s) unless remote_ip.nil?
|
31
32
|
self.parameters = { 'q' => query }
|
32
|
-
|
33
|
-
|
34
|
-
parameters['startIndex'] =
|
35
|
-
parameters['maxResults'] =
|
33
|
+
options[:page] ||= 1
|
34
|
+
options[:count] ||= 5
|
35
|
+
parameters['startIndex'] = options[:count] * (options[:page] - 1)
|
36
|
+
parameters['maxResults'] = options[:count]
|
37
|
+
parameters['key'] = options[:api_key] if options[:api_key]
|
36
38
|
|
37
39
|
Response.new(get(url.to_s))
|
38
40
|
end
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: googlebooks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-02-03 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
16
|
-
requirement: &
|
16
|
+
requirement: &16730940 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *16730940
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &16729860 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *16729860
|
36
36
|
description: GoogleBooks is a lightweight Ruby wrapper that queries the Google API
|
37
37
|
to search for publications in the Google Books repository. It is inspired by the
|
38
38
|
google-book gem which relies on the deprecated Google GData Books API, but is updated
|