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.
- checksums.yaml +4 -4
- data/lib/onewheel-google.rb +25 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0de6d9eb1ac31174576f8b4de1f760f2564494cd
|
4
|
+
data.tar.gz: a63f75fa7ffe35cbb3e640871ed0c848bf2e43f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d92a5549478513006479ecb5febb7ca97f8c2b60ea6e75e2f2ea62c41dfcd924adb21aee1fc5fe974800ec78a983684dfdda016219ab13d8fe3ac298d23cae05
|
7
|
+
data.tar.gz: eb03283bfbbf5ec2411bd8c86de2092d2222d6f2745c8a3a4971bde5ef2ebc86f4d79f52ee6cdc94e58ce6e0f736fc7b2840d64c8e2f6415fbade9b866ab0105
|
data/lib/onewheel-google.rb
CHANGED
@@ -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 =
|
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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|