googlebooksclient 0.1.1 → 0.1.3
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.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +2 -0
- data/README.md +7 -1
- data/googlebooksclient-0.1.2.gem +0 -0
- data/lib/googlebooksclient/client/volumes.rb +18 -2
- data/lib/googlebooksclient/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e06118baddf79ae6597c0530522f89231a038811de81abb5d5ec3dcaca78a3c1
|
|
4
|
+
data.tar.gz: 852f37c8aa46833850fcdddab72e98818f13e504311506bafc208d9002b17fdf
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 57c6a8e1e9788e244165d98cbc02c7b90c478a9f3f055610cd5457be0a75743df408e22d4bb12ecccffaea69ae30ac8d829a1b45d46a7dab480ec84daf81689c
|
|
7
|
+
data.tar.gz: 1459d5224cde2affe987b812905a4489b4c825f006a8d9b29cbfe0499839f55fb1bfaa8ef29254e50790da5437e1a40b63871afd572349f7fff6b103270a78a3
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -9,6 +9,7 @@ GEM
|
|
|
9
9
|
specs:
|
|
10
10
|
addressable (2.5.2)
|
|
11
11
|
public_suffix (>= 2.0.2, < 4.0)
|
|
12
|
+
byebug (10.0.2)
|
|
12
13
|
crack (0.4.3)
|
|
13
14
|
safe_yaml (~> 1.0.0)
|
|
14
15
|
diff-lcs (1.3)
|
|
@@ -44,6 +45,7 @@ PLATFORMS
|
|
|
44
45
|
|
|
45
46
|
DEPENDENCIES
|
|
46
47
|
bundler (~> 1.17)
|
|
48
|
+
byebug
|
|
47
49
|
googlebooksclient!
|
|
48
50
|
rake (~> 10.0)
|
|
49
51
|
rspec
|
data/README.md
CHANGED
|
@@ -30,7 +30,13 @@ And then perform a simple Volume search:
|
|
|
30
30
|
|
|
31
31
|
Which will return an array of books!
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
If you'd like to filter that search, the volumes method can also take an additional options parameter with filters. This should be in the form of a Hash, with each key a search filter made available by [Google Books](https://developers.google.com/books/docs/v1/using#PerformingSearch). The keys may be Strings or Symbols.
|
|
34
|
+
|
|
35
|
+
$ client.volumes("Harry", {"inauthor": "rowling", intitle: "Goblet"})
|
|
36
|
+
|
|
37
|
+
You may also search ONLY with filters, but then you must pass an empty string as the first argument. So using the above example would look like:
|
|
38
|
+
|
|
39
|
+
$ client.volumes("", {"inauthor": "rowling", intitle: "Goblet"})
|
|
34
40
|
|
|
35
41
|
## Development
|
|
36
42
|
|
|
Binary file
|
|
@@ -4,11 +4,27 @@ module Googlebooksclient
|
|
|
4
4
|
|
|
5
5
|
module Volumes
|
|
6
6
|
|
|
7
|
-
def volumes(
|
|
8
|
-
|
|
7
|
+
def volumes(search_term = "", options = {})
|
|
8
|
+
query = search_term.split(" ").join("+")
|
|
9
|
+
if !options.empty?
|
|
10
|
+
query += add_filters(options)
|
|
11
|
+
end
|
|
12
|
+
response = self.class.get("/volumes", {query: { q: query } })
|
|
9
13
|
response.parsed_response ? response.parsed_response["items"] : nil
|
|
10
14
|
end
|
|
11
15
|
|
|
16
|
+
def add_filters(filter_params)
|
|
17
|
+
# take a hash of search terms and format them into a string
|
|
18
|
+
query_string = ""
|
|
19
|
+
filter_params.keys.each do |filter|
|
|
20
|
+
term = filter_params[filter]
|
|
21
|
+
term = term.split(" ").join("+")
|
|
22
|
+
formatted_search_term = "+" + filter.to_s + ":" + term
|
|
23
|
+
query_string += formatted_search_term
|
|
24
|
+
end
|
|
25
|
+
query_string
|
|
26
|
+
end
|
|
27
|
+
|
|
12
28
|
end
|
|
13
29
|
|
|
14
30
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: googlebooksclient
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alex Cooper
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-
|
|
11
|
+
date: 2018-12-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -84,6 +84,7 @@ files:
|
|
|
84
84
|
- bin/console
|
|
85
85
|
- bin/setup
|
|
86
86
|
- googlebooksclient-0.1.0.gem
|
|
87
|
+
- googlebooksclient-0.1.2.gem
|
|
87
88
|
- googlebooksclient.gemspec
|
|
88
89
|
- lib/googlebooksclient.rb
|
|
89
90
|
- lib/googlebooksclient/client.rb
|