lita-onewheel-images 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +21 -0
- data/Rakefile +6 -0
- data/lib/lita/handlers/onewheel_images.rb +3 -21
- data/lita-onewheel-images.gemspec +2 -3
- data/spec/lita/handlers/onewheel_images_spec.rb +3 -5
- data/spec/spec_helper.rb +1 -1
- metadata +8 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7938f22b4fe8040623bd471a976602ff6ac51688
|
4
|
+
data.tar.gz: 727e4a036705e7ac1e0780bf7cfa7efb1226a789
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c56502c8f5cf27892c132d121724227e9fb281ebe8692f854247f1e8df3e9ea7a4dd0dc846a244e04477799a7b1421afe0c7f8e445cc5c90390d976b9c0dd6c4
|
7
|
+
data.tar.gz: 3b3a8fda591a5543442116dc82049de06474fa2626da78a83c58ff3486774055d4979c1b7b4b3eea619cb23b5c40a64d9615aeb44e9eac15ab84685dbad945e9
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Andrew Kreps
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/Rakefile
ADDED
@@ -1,6 +1,4 @@
|
|
1
|
-
require '
|
2
|
-
require 'json'
|
3
|
-
require 'addressable/uri'
|
1
|
+
require 'onewheel-google'
|
4
2
|
|
5
3
|
module Lita
|
6
4
|
module Handlers
|
@@ -13,24 +11,8 @@ module Lita
|
|
13
11
|
|
14
12
|
def image(response)
|
15
13
|
query = response.matches[0][0]
|
16
|
-
|
17
|
-
|
18
|
-
response.reply search_result['items'][0]['link']
|
19
|
-
end
|
20
|
-
|
21
|
-
def get_results(query)
|
22
|
-
puts "Searching for #{query}"
|
23
|
-
uri = Addressable::URI.new
|
24
|
-
uri.query_values = {
|
25
|
-
q: query,
|
26
|
-
cx: config.custom_search_engine_id,
|
27
|
-
searchType: 'image',
|
28
|
-
num: 10,
|
29
|
-
key: config.google_api_key,
|
30
|
-
safe: config.safe_search}
|
31
|
-
Lita.logger.debug uri.query
|
32
|
-
response = HTTParty.get "https://www.googleapis.com/customsearch/v1?#{uri.query}"
|
33
|
-
JSON.parse response.body
|
14
|
+
result = ::OnewheelGoogle::search(query, config.custom_search_engine_id, config.google_api_key, config.safe_search, image = true)
|
15
|
+
response.reply result['items'][0]['link']
|
34
16
|
end
|
35
17
|
|
36
18
|
Lita.register_handler(self)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = 'lita-onewheel-images'
|
3
|
-
spec.version = '0.1.
|
3
|
+
spec.version = '0.1.1'
|
4
4
|
spec.authors = ['Andrew Kreps']
|
5
5
|
spec.email = ['andrew.kreps@gmail.com']
|
6
6
|
spec.description = 'An implementation of Google Custom Search Engine for image searches in chat.'
|
@@ -15,8 +15,7 @@ Gem::Specification.new do |spec|
|
|
15
15
|
spec.require_paths = ['lib']
|
16
16
|
|
17
17
|
spec.add_runtime_dependency 'lita', '~> 4'
|
18
|
-
spec.add_runtime_dependency '
|
19
|
-
spec.add_runtime_dependency 'addressable', '~> 2.4'
|
18
|
+
spec.add_runtime_dependency 'onewheel-google', '~> 1'
|
20
19
|
|
21
20
|
spec.add_development_dependency 'bundler', '~> 1.3'
|
22
21
|
spec.add_development_dependency 'rake', '~> 10.4'
|
@@ -1,10 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
+
require 'onewheel-google'
|
2
3
|
|
3
4
|
describe Lita::Handlers::OnewheelImages, lita_handler: true do
|
4
5
|
|
5
6
|
before(:each) do
|
6
7
|
mock_result_json = File.open('spec/fixtures/mock_result.json').read
|
7
|
-
allow(
|
8
|
+
allow(OnewheelGoogle).to receive(:search).and_return(JSON.parse mock_result_json)
|
8
9
|
|
9
10
|
registry.configure do |config|
|
10
11
|
config.handlers.onewheel_images.custom_search_engine_id = ''
|
@@ -15,10 +16,7 @@ describe Lita::Handlers::OnewheelImages, lita_handler: true do
|
|
15
16
|
it { is_expected.to route_command('image something') }
|
16
17
|
|
17
18
|
it 'does neat imagey things' do
|
18
|
-
mock_result_json = JSON.parse File.open('spec/fixtures/mock_result.json').read
|
19
|
-
allow(Lita::Handlers::OnewheelImages).to receive(:get_results).and_return(mock_result_json)
|
20
|
-
# mock gcse response
|
21
19
|
send_command 'image yo'
|
22
|
-
|
20
|
+
expect(replies.last).to eq('https://s-media-cache-ak0.pinimg.com/736x/4a/43/a4/4a43a4b6569cf8a197b6c9217de3f412.jpg')
|
23
21
|
end
|
24
22
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-onewheel-images
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kreps
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -25,33 +25,19 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: onewheel-google
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '1'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: addressable
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '2.4'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '2.4'
|
40
|
+
version: '1'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: bundler
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -147,7 +133,9 @@ files:
|
|
147
133
|
- ".gitignore"
|
148
134
|
- ".travis.yml"
|
149
135
|
- Gemfile
|
136
|
+
- LICENSE
|
150
137
|
- README.rst
|
138
|
+
- Rakefile
|
151
139
|
- lib/lita-onewheel-images.rb
|
152
140
|
- lib/lita/handlers/onewheel_images.rb
|
153
141
|
- lita-onewheel-images.gemspec
|
@@ -175,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
163
|
version: '0'
|
176
164
|
requirements: []
|
177
165
|
rubyforge_project:
|
178
|
-
rubygems_version: 2.
|
166
|
+
rubygems_version: 2.5.1
|
179
167
|
signing_key:
|
180
168
|
specification_version: 4
|
181
169
|
summary: CSE Details to follow
|