lita-onewheel-google 0.0.1 → 0.0.3

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: cdc3245dde9fb77de3457d98598f37fa1d1a444d
4
- data.tar.gz: 850fcf11d7b812496be7bef367f636bfb7decc2c
3
+ metadata.gz: 9d3d208a78023bc3a907dbde312361046e4df308
4
+ data.tar.gz: 5944c6626441b810aeb5435f752cdfb3402fa4b4
5
5
  SHA512:
6
- metadata.gz: 3af942e52d78316f6ce2a64edfcd9be1c58b7807146565e00a1683d8548468f90b71b3c0e39a5a94024ebfc82410d701d53bcf3968bf64ce0fa65047fd0aa564
7
- data.tar.gz: 7d34d6385ea64ef7af3f564b3a1b0723758892f5ba8a95772a54be21664d97258cb293f28bc2f289e0690dedf3ddbd5710f2c1beef6de03e367a18c5ba4ed1c4
6
+ metadata.gz: 5c7df0b76b314c1f9e5d36a4cd21103a433f61afb7048f85bf4e14d69679a2fcdb6af006fa91bc20265fba028af5b55a0bac0aeaf391e79c3b053978e1301034
7
+ data.tar.gz: eef2fe8c96b82dd720bb74d9bb79b76e782e0bf52213fcb8c242466129d72a38066e2a7847fad67b5ae23a8bcc6c6632e1367141d3a3b9208e19091f5fc03f36
@@ -1,6 +1,7 @@
1
1
  require 'rest-client'
2
2
  require 'json'
3
3
  require 'addressable/uri'
4
+ require 'onewheel-google'
4
5
 
5
6
  module Lita
6
7
  module Handlers
@@ -13,24 +14,9 @@ module Lita
13
14
 
14
15
  def search(response)
15
16
  query = response.matches[0][0]
16
- search_result = get_results query
17
- puts search_result.inspect
18
- response.reply "#{search_result['items'][0]['link']} #{search_result['items'][0]['title']}: #{search_result['items'][0]['snippet']}"
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 = RestClient.get "https://www.googleapis.com/customsearch/v1?#{uri.query}"
33
- JSON.parse response
17
+ search_result = ::OnewheelGoogle::search(query, config.custom_search_engine_id, config.google_api_key, config.safe_search)
18
+ result = JSON.parse(search_result)
19
+ response.reply "#{result['items'][0]['link']} #{result['items'][0]['title']}: #{result['items'][0]['snippet']}"
34
20
  end
35
21
 
36
22
  Lita.register_handler(self)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'lita-onewheel-google'
3
- spec.version = '0.0.1'
3
+ spec.version = '0.0.3'
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 searching in chat.'
@@ -17,6 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.add_runtime_dependency 'lita', '~> 4'
18
18
  spec.add_runtime_dependency 'rest-client', '~> 1.8'
19
19
  spec.add_runtime_dependency 'addressable', '~> 2.4'
20
+ spec.add_runtime_dependency 'onewheel-google', '~> 0'
20
21
 
21
22
  spec.add_development_dependency 'bundler', '~> 1.3'
22
23
  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::OnewheelGoogle, 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(RestClient).to receive(:get).and_return(mock_result_json)
8
+ allow(OnewheelGoogle).to receive(:search).and_return(mock_result_json)
8
9
 
9
10
  registry.configure do |config|
10
11
  config.handlers.onewheel_google.custom_search_engine_id = ''
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-onewheel-google
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
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-05-30 00:00:00.000000000 Z
11
+ date: 2016-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: onewheel-google
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
70
  name: bundler
57
71
  requirement: !ruby/object:Gem::Requirement