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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 70de47b530e136b71b4cc669084d261366860c42
4
- data.tar.gz: 326ee33d20ebfeb13276ab39036cd3bb13de1a11
3
+ metadata.gz: a3d9a71b531642fd0dbf1a9e84488fd8474c8e1a
4
+ data.tar.gz: 8a479aa429d9217b6c32786dfcfa48d0a80899a5
5
5
  SHA512:
6
- metadata.gz: 0ffdffd8175cf3bde9e0fc3df978824ac39b7f24c596e19f68f78cb59ebdb802be9ecdc15e14976128f3a14ab576f7d534e9653298e166b33ddf2707e88813aa
7
- data.tar.gz: 91eb3377b4dfb204225be6c71334cd68285ce0c5bb462c2a86d1de4be304db257b66c18a9f550eac179fb199ebb4838ca653227a3e6dda519f4b9fc1c11caa98
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: safe_value,
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)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-google-images"
3
- spec.version = "1.0.5"
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", ">= 2.0"
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.beta2"
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 { routes_command("image me foo").to(:fetch) }
5
- it { routes_command("image foo").to(:fetch) }
6
- it { routes_command("img foo").to(:fetch) }
7
- it { routes_command("img me foo").to(:fetch) }
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") }
@@ -8,3 +8,5 @@ SimpleCov.start { add_filter "/spec/" }
8
8
 
9
9
  require "lita-google-images"
10
10
  require "lita/rspec"
11
+
12
+ Lita.version_3_compatibility_mode = false
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.5
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-05-08 00:00:00.000000000 Z
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: '2.0'
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: '2.0'
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.beta2
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.beta2
68
+ version: 3.0.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
71
  requirement: !ruby/object:Gem::Requirement