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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e3d05bca883f478111bdfa7f037f306397c990e717ca70b4d84ab7bd361230b6
4
- data.tar.gz: 2711cb66ad2a4db0e1c4795c33889f419b43461264d7fa748a2ce8eae02b7af0
3
+ metadata.gz: e06118baddf79ae6597c0530522f89231a038811de81abb5d5ec3dcaca78a3c1
4
+ data.tar.gz: 852f37c8aa46833850fcdddab72e98818f13e504311506bafc208d9002b17fdf
5
5
  SHA512:
6
- metadata.gz: deb0a02d62c777876f656db39f60b347e759b83817f1625170b9d2671dcc289b075b087b228c6722d21ac866c9215c2d294d8e445aed1bdc4e36b4205542717d
7
- data.tar.gz: 27ab78e017a0b87a34cc22c34048a6153e4fbd34d184871fe8df1fbd3d651035afe4b8751b56bd32d968ad5955280d9cc3189203d872a63501cdf27d161a7182
6
+ metadata.gz: 57c6a8e1e9788e244165d98cbc02c7b90c478a9f3f055610cd5457be0a75743df408e22d4bb12ecccffaea69ae30ac8d829a1b45d46a7dab480ec84daf81689c
7
+ data.tar.gz: 1459d5224cde2affe987b812905a4489b4c825f006a8d9b29cbfe0499839f55fb1bfaa8ef29254e50790da5437e1a40b63871afd572349f7fff6b103270a78a3
data/.gitignore CHANGED
@@ -9,3 +9,5 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+
13
+ .byebug_history
data/Gemfile CHANGED
@@ -9,3 +9,7 @@ group :test do
9
9
  gem 'rspec'
10
10
  gem 'webmock'
11
11
  end
12
+
13
+ group :development do
14
+ gem 'byebug'
15
+ end
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
- Very simple so start, but hopefully I will build off of this base in the next version.
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(options = "")
8
- response = self.class.get("/volumes", {query: { q: options.split(" ").join("+") } })
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
@@ -1,3 +1,3 @@
1
1
  module Googlebooksclient
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.3"
3
3
  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.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-16 00:00:00.000000000 Z
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