onewheel-google 0.0.4 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/onewheel-google.rb +25 -9
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dd50010369603dadb1a513a54d79457721413777
4
- data.tar.gz: a2db12412f7c78d1294faa7d88594ad6b81b9ac2
3
+ metadata.gz: 0de6d9eb1ac31174576f8b4de1f760f2564494cd
4
+ data.tar.gz: a63f75fa7ffe35cbb3e640871ed0c848bf2e43f0
5
5
  SHA512:
6
- metadata.gz: f8613b3d47a64f3476f9cfff705e1ca0bb2a5cab1b4d7ef2a7a4ffbcbc3f10442fd78dfcea7dfe819bb1be678c0720f0eabc1dbae03b20aa4dbdeddf500625c5
7
- data.tar.gz: 6eb50b1fdc2daf949d60635ab5fd316bb83cc49f9612288e4f3ba9e01a2f18508fc4fe69f4072eed9bb0fa0378955ab95f957f31de444bbece66f4519fc37b04
6
+ metadata.gz: d92a5549478513006479ecb5febb7ca97f8c2b60ea6e75e2f2ea62c41dfcd924adb21aee1fc5fe974800ec78a983684dfdda016219ab13d8fe3ac298d23cae05
7
+ data.tar.gz: eb03283bfbbf5ec2411bd8c86de2092d2222d6f2745c8a3a4971bde5ef2ebc86f4d79f52ee6cdc94e58ce6e0f736fc7b2840d64c8e2f6415fbade9b866ab0105
@@ -2,7 +2,7 @@ require 'rest-client'
2
2
  require 'addressable'
3
3
 
4
4
  class OnewheelGoogle
5
- def self.search(query, cse_id, api_key, safe_search = 'high')
5
+ def self.search(query, cse_id, api_key, safe_search, image = false)
6
6
  if query.empty?
7
7
  puts 'Query blank, cannot continue.'
8
8
  return
@@ -18,17 +18,33 @@ class OnewheelGoogle
18
18
  return
19
19
  end
20
20
 
21
+ if safe_search.empty?
22
+ puts 'safe_search blank, cannot continue.'
23
+ return
24
+ end
25
+
21
26
  uri = Addressable::URI.new
22
- uri.query_values = {
23
- q: query,
24
- cx: cse_id,
25
- # searchType: 'image',
26
- num: 10,
27
- key: api_key,
28
- safe: safe_search}
27
+
28
+ if image
29
+ uri.query_values = {
30
+ q: query,
31
+ cx: cse_id,
32
+ num: 10,
33
+ key: api_key,
34
+ safe: safe_search,
35
+ searchType: 'image'
36
+ }
37
+ else
38
+ uri.query_values = {
39
+ q: query,
40
+ cx: cse_id,
41
+ num: 10,
42
+ key: api_key,
43
+ safe: safe_search,
44
+ }
45
+ end
29
46
 
30
47
  response = RestClient.get "https://www.googleapis.com/customsearch/v1?#{uri.query}"
31
48
  JSON.parse response
32
49
  end
33
-
34
50
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onewheel-google
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kreps