lita-google-images 1.0.5 → 2.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/lita/handlers/google_images.rb +10 -12
- data/lita-google-images.gemspec +3 -3
- data/spec/lita/handlers/google_images_spec.rb +4 -4
- data/spec/spec_helper.rb +2 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3d9a71b531642fd0dbf1a9e84488fd8474c8e1a
|
4
|
+
data.tar.gz: 8a479aa429d9217b6c32786dfcfa48d0a80899a5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31884376917a510d9682a390861a65ed6e950cf640197d6240dc11018708df8e7c844b90577d40efa7dafaf050d355db11d828042d134fa06db594a6bb9467ca
|
7
|
+
data.tar.gz: 34ef2fde97127a128d0f661180b51ad1eb13ae500e398049db911831abc117dabc5bd3748eaa0a4082f4e5b2e5822e5d5ffb9c67c96c754da1cba17626b76b0b
|
@@ -4,15 +4,20 @@ module Lita
|
|
4
4
|
module Handlers
|
5
5
|
class GoogleImages < Handler
|
6
6
|
URL = "https://ajax.googleapis.com/ajax/services/search/images"
|
7
|
+
VALID_SAFE_VALUES = %w(active moderate off)
|
8
|
+
|
9
|
+
config :safe_search, types: [String, Symbol], default: :active do
|
10
|
+
validate do |value|
|
11
|
+
unless VALID_SAFE_VALUES.include?(value.to_s.strip)
|
12
|
+
"valid values are :active, :moderate, or :off"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
7
16
|
|
8
17
|
route(/(?:image|img)(?:\s+me)? (.+)/, :fetch, command: true, help: {
|
9
18
|
"image QUERY" => "Displays a random image from Google Images matching the query."
|
10
19
|
})
|
11
20
|
|
12
|
-
def self.default_config(handler_config)
|
13
|
-
handler_config.safe_search = :active
|
14
|
-
end
|
15
|
-
|
16
21
|
def fetch(response)
|
17
22
|
query = response.matches[0][0]
|
18
23
|
|
@@ -20,7 +25,7 @@ module Lita
|
|
20
25
|
URL,
|
21
26
|
v: "1.0",
|
22
27
|
q: query,
|
23
|
-
safe:
|
28
|
+
safe: config.safe_search,
|
24
29
|
rsz: 8
|
25
30
|
)
|
26
31
|
|
@@ -50,13 +55,6 @@ module Lita
|
|
50
55
|
"#{url}#.png"
|
51
56
|
end
|
52
57
|
end
|
53
|
-
|
54
|
-
def safe_value
|
55
|
-
safe = Lita.config.handlers.google_images.safe_search || "active"
|
56
|
-
safe = safe.to_s.downcase
|
57
|
-
safe = "active" unless ["active", "moderate", "off"].include?(safe)
|
58
|
-
safe
|
59
|
-
end
|
60
58
|
end
|
61
59
|
|
62
60
|
Lita.register_handler(GoogleImages)
|
data/lita-google-images.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "lita-google-images"
|
3
|
-
spec.version = "
|
3
|
+
spec.version = "2.0.0"
|
4
4
|
spec.authors = ["Jimmy Cuadra"]
|
5
5
|
spec.email = ["jimmy@jimmycuadra.com"]
|
6
6
|
spec.description = %q{A Lita handler for fetching images from Google.}
|
@@ -14,11 +14,11 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
15
15
|
spec.require_paths = ["lib"]
|
16
16
|
|
17
|
-
spec.add_runtime_dependency "lita", ">=
|
17
|
+
spec.add_runtime_dependency "lita", ">= 4.0"
|
18
18
|
|
19
19
|
spec.add_development_dependency "bundler", "~> 1.3"
|
20
20
|
spec.add_development_dependency "rake"
|
21
|
-
spec.add_development_dependency "rspec", ">= 3.0.0
|
21
|
+
spec.add_development_dependency "rspec", ">= 3.0.0"
|
22
22
|
spec.add_development_dependency "simplecov"
|
23
23
|
spec.add_development_dependency "coveralls"
|
24
24
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Lita::Handlers::GoogleImages, lita_handler: true do
|
4
|
-
it {
|
5
|
-
it {
|
6
|
-
it {
|
7
|
-
it {
|
4
|
+
it { is_expected.to route_command("image me foo").to(:fetch) }
|
5
|
+
it { is_expected.to route_command("image foo").to(:fetch) }
|
6
|
+
it { is_expected.to route_command("img foo").to(:fetch) }
|
7
|
+
it { is_expected.to route_command("img me foo").to(:fetch) }
|
8
8
|
|
9
9
|
describe "#foo" do
|
10
10
|
let(:response) { double("Faraday::Response") }
|
data/spec/spec_helper.rb
CHANGED
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:
|
4
|
+
version: 2.0.0
|
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-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '4.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '4.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 3.0.0
|
61
|
+
version: 3.0.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 3.0.0
|
68
|
+
version: 3.0.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: simplecov
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|