ruboty-google_image 0.0.7 → 0.1.0
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/CHANGELOG.md +3 -0
- data/README.md +15 -0
- data/lib/ruboty/google_image/client.rb +9 -9
- data/lib/ruboty/google_image/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ed6973ac9a39495dfebcb57abedb2018ce870085
|
4
|
+
data.tar.gz: f3ffea6d9ed22d16b76b5e6ebb5f8e273d253834
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21057cc67f83cf3a28f21c3a824f1a7c283e3848c4d3bce07e604d6af65341aac4625099bed6ebf4b1508bb5ddefecc60eff8fe578fb076102fbcf65ad01bedc
|
7
|
+
data.tar.gz: 3fc5384f046a5ec08b98232b2aa21c435de3f9267264f9a90dc78c8a17006d427a2db70ec92ca0c86c04684356b2be8073eb40988019014449a71a2cc1a21d49
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,21 @@
|
|
1
1
|
# Ruboty::GoogleImage
|
2
2
|
An ruboty handler to search images from Google.
|
3
3
|
|
4
|
+
## Install
|
5
|
+
|
6
|
+
This gem needs two environment variables.
|
7
|
+
|
8
|
+
- GOOGLE_CSE_ID
|
9
|
+
- GOOGLE_CSE_KEY
|
10
|
+
|
11
|
+
### CSE setup
|
12
|
+
|
13
|
+
1. Create a CSE via these [instructions](https://developers.google.com/custom-search/docs/tutorial/creatingcse).
|
14
|
+
1. Turn on images in Edit Search Engine > Setup > Basic > Image Search
|
15
|
+
1. Get the CSE ID in Edit Search Engine > Setup > Basic > Details (via [these instructions](https://support.google.com/customsearch/answer/2649143?hl=en))
|
16
|
+
1. Get the CSE KEY [here](https://code.google.com/apis/console)
|
17
|
+
1. Update your env
|
18
|
+
|
4
19
|
## Usage
|
5
20
|
```
|
6
21
|
@ruboty image <keyword> - Search image from Google
|
@@ -4,7 +4,7 @@ require "faraday_middleware"
|
|
4
4
|
module Ruboty
|
5
5
|
module GoogleImage
|
6
6
|
class Client
|
7
|
-
GOOGLE_IMAGE_API_URL = "
|
7
|
+
GOOGLE_IMAGE_API_URL = "https://www.googleapis.com/customsearch/v1"
|
8
8
|
|
9
9
|
attr_reader :options
|
10
10
|
|
@@ -13,7 +13,7 @@ module Ruboty
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def get
|
16
|
-
resource["
|
16
|
+
resource["link"] if resource
|
17
17
|
rescue => exception
|
18
18
|
Ruboty.logger.error("Error: #{self}##{__method__} - #{exception}")
|
19
19
|
nil
|
@@ -23,10 +23,8 @@ module Ruboty
|
|
23
23
|
|
24
24
|
def resource
|
25
25
|
@resource ||= begin
|
26
|
-
if
|
27
|
-
|
28
|
-
results.sample
|
29
|
-
end
|
26
|
+
if items = response.body["items"]
|
27
|
+
items.sample
|
30
28
|
end
|
31
29
|
end
|
32
30
|
end
|
@@ -51,9 +49,11 @@ module Ruboty
|
|
51
49
|
|
52
50
|
def default_params
|
53
51
|
{
|
54
|
-
|
55
|
-
safe:
|
56
|
-
|
52
|
+
searchType: 'image',
|
53
|
+
safe: 'high',
|
54
|
+
fields: 'items(link)',
|
55
|
+
cx: ENV['GOOGLE_CSE_ID'],
|
56
|
+
key: ENV['GOOGLE_CSE_KEY']
|
57
57
|
}
|
58
58
|
end
|
59
59
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruboty-google_image
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruboty
|
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
133
|
version: '0'
|
134
134
|
requirements: []
|
135
135
|
rubyforge_project:
|
136
|
-
rubygems_version: 2.
|
136
|
+
rubygems_version: 2.4.5
|
137
137
|
signing_key:
|
138
138
|
specification_version: 4
|
139
139
|
summary: An ruboty handler to search images from Google.
|