lita-google-images 1.0.4 → 1.0.5
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/lib/lita/handlers/google_images.rb +9 -1
- data/lita-google-images.gemspec +1 -1
- data/spec/lita/handlers/google_images_spec.rb +21 -1
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70de47b530e136b71b4cc669084d261366860c42
|
4
|
+
data.tar.gz: 326ee33d20ebfeb13276ab39036cd3bb13de1a11
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ffdffd8175cf3bde9e0fc3df978824ac39b7f24c596e19f68f78cb59ebdb802be9ecdc15e14976128f3a14ab576f7d534e9653298e166b33ddf2707e88813aa
|
7
|
+
data.tar.gz: 91eb3377b4dfb204225be6c71334cd68285ce0c5bb462c2a86d1de4be304db257b66c18a9f550eac179fb199ebb4838ca653227a3e6dda519f4b9fc1c11caa98
|
@@ -29,7 +29,7 @@ module Lita
|
|
29
29
|
if data["responseStatus"] == 200
|
30
30
|
choice = data["responseData"]["results"].sample
|
31
31
|
if choice
|
32
|
-
response.reply
|
32
|
+
response.reply ensure_extension(choice["unescapedUrl"])
|
33
33
|
else
|
34
34
|
response.reply %{No images found for "#{query}".}
|
35
35
|
end
|
@@ -43,6 +43,14 @@ module Lita
|
|
43
43
|
|
44
44
|
private
|
45
45
|
|
46
|
+
def ensure_extension(url)
|
47
|
+
if [".gif", ".jpg", ".jpeg", ".png"].any? { |ext| url.end_with?(ext) }
|
48
|
+
url
|
49
|
+
else
|
50
|
+
"#{url}#.png"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
46
54
|
def safe_value
|
47
55
|
safe = Lita.config.handlers.google_images.safe_search || "active"
|
48
56
|
safe = safe.to_s.downcase
|
data/lita-google-images.gemspec
CHANGED
@@ -17,6 +17,26 @@ describe Lita::Handlers::GoogleImages, lita_handler: true do
|
|
17
17
|
|
18
18
|
it "replies with a matching image URL on success" do
|
19
19
|
allow(response).to receive(:body).and_return(<<-JSON.chomp
|
20
|
+
{
|
21
|
+
"responseStatus": 200,
|
22
|
+
"responseData": {
|
23
|
+
"results": [
|
24
|
+
{
|
25
|
+
"unescapedUrl": "http://www.example.com/path/to/an/image"
|
26
|
+
}
|
27
|
+
]
|
28
|
+
}
|
29
|
+
}
|
30
|
+
JSON
|
31
|
+
)
|
32
|
+
send_command("image carl")
|
33
|
+
expect(replies.last).to eq(
|
34
|
+
"http://www.example.com/path/to/an/image#.png"
|
35
|
+
)
|
36
|
+
end
|
37
|
+
|
38
|
+
it "doesn't append a fake file extension if the image URL has a common image extension" do
|
39
|
+
allow(response).to receive(:body).and_return(<<-JSON.chomp
|
20
40
|
{
|
21
41
|
"responseStatus": 200,
|
22
42
|
"responseData": {
|
@@ -31,7 +51,7 @@ JSON
|
|
31
51
|
)
|
32
52
|
send_command("image carl")
|
33
53
|
expect(replies.last).to eq(
|
34
|
-
"http://www.example.com/path/to/an/image.jpg
|
54
|
+
"http://www.example.com/path/to/an/image.jpg"
|
35
55
|
)
|
36
56
|
end
|
37
57
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-google-images
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jimmy Cuadra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -140,4 +140,3 @@ summary: A Lita handler for fetching images from Google.
|
|
140
140
|
test_files:
|
141
141
|
- spec/lita/handlers/google_images_spec.rb
|
142
142
|
- spec/spec_helper.rb
|
143
|
-
has_rdoc:
|