lita-google_search 0.1.1 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3411b9cd31723f0ef57c0cbde99bc6cb0c502fe9
4
- data.tar.gz: b1b940a271cb4e154631d037b122700f902d3eb0
3
+ metadata.gz: ecb9df59b56f6ffe29dee61ad7a3feb709d08240
4
+ data.tar.gz: c3d8f5d65a525aacf618bc29264c0d4da61ee5b9
5
5
  SHA512:
6
- metadata.gz: 8959984bc93a65a036d64cd703a4b89cb9d7184507a7a61aecd8e05c084b94fa9c93d579d82c4716fdc79395c0b11d1672b74e00f9183f7a9c583b37af7421ac
7
- data.tar.gz: 5911103daf368c953d43349ce9753b31925deea7752e761d063ebc2345e1b8ec5f0f71bdea2f23e8ac3b8b76abd6f1f2fa3cf2829ea32d2e01292ba0177190f2
6
+ metadata.gz: b32c2817db28c15a786a82401abf555ea3162e045aac9f3d1c519facaa5c1b572e204042f9202f2d1d522421e52a9f7a5f5edd971fc5840012806f972d23f9dd
7
+ data.tar.gz: 21575f0962967ece854924739fd200572c4ac67a6a0f2edf8d87756d91f8cb5bf1fe19827a677681ad578555c86f07529fa3386c17c432c5c2784182ccd78b41
@@ -1,4 +1,5 @@
1
1
  require 'google-search'
2
+ require 'htmlentities'
2
3
 
3
4
  module Lita
4
5
  module Handlers
@@ -34,9 +35,10 @@ module Lita
34
35
  private
35
36
 
36
37
  def print_search(r, clazz)
38
+ htmlentities = HTMLEntities.new
37
39
  result = clazz.new(:query => r.match_data[:terms]).first
38
- r.send(answering_method(r), "#{r.user.name}: #{result.title.gsub(/<[^>]*>/,"").gsub(/\s\s+/," ")} ( #{result.uri} )")
39
- r.send(answering_method(r), result.content.gsub(/<[^>]*>/,"").gsub(/\s\s+/," "))
40
+ r.send(answering_method(r), "#{r.user.name}: #{htmlentities.decode(result.title).gsub(/<[^>]*>/,"").gsub(/\s\s+/," ")} ( #{result.uri} )")
41
+ r.send(answering_method(r), htmlentities.decode(result.content).gsub(/<[^>]*>/,"").gsub(/\s\s+/," "))
40
42
  end
41
43
 
42
44
  def answering_method(r)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-google_search"
3
- spec.version = "0.1.1"
3
+ spec.version = "0.1.2"
4
4
  spec.authors = ["Zaratan"]
5
5
  spec.email = ["denis.pasin@gmail.com"]
6
6
  spec.description = "A lita plugin to do all the type of google search"
@@ -13,6 +13,7 @@ Gem::Specification.new do |spec|
13
13
  spec.require_paths = ["lib"]
14
14
 
15
15
  spec.add_dependency "google-search"
16
+ spec.add_dependency "htmlentities"
16
17
 
17
18
  spec.add_runtime_dependency "lita", ">= 4.6"
18
19
 
@@ -30,6 +30,15 @@ describe Lita::Handlers::GoogleSearch, lita_handler: true do
30
30
  send_command("g me test", as: user)
31
31
  expect(replies.last).to match(/\S+/)
32
32
  end
33
+
34
+ it "should unparse special html char" do
35
+ allow_any_instance_of(Google::Search::Web).to receive(:first).and_return(double("result", title: "lol&#39;d", uri: "", content: "onoes &#39;ll"))
36
+ subject
37
+ expect(replies.last).not_to include("&#39;")
38
+ expect(replies.last).to include("'")
39
+ expect(replies.last(2).first).not_to include("&#39;")
40
+ expect(replies.last(2).first).to include("'")
41
+ end
33
42
  end
34
43
 
35
44
  describe "image" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-google_search
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zaratan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-29 00:00:00.000000000 Z
11
+ date: 2015-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-search
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: htmlentities
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: lita
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -146,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
146
160
  version: '0'
147
161
  requirements: []
148
162
  rubyforge_project:
149
- rubygems_version: 2.4.8
163
+ rubygems_version: 2.2.2
150
164
  signing_key:
151
165
  specification_version: 4
152
166
  summary: A lita plugin to do all the type of google search