xiaohuangji 0.0.3 → 0.0.5

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: 8d9e48c14dc58c48b19d433f3e23fb6c0f3f3448
4
- data.tar.gz: 1d7c9c25f931b732bdb632543925cc7776c8c4db
3
+ metadata.gz: 17df627f74a5b77c903420c7b9ecece4fe1b4b66
4
+ data.tar.gz: e51ed8aa3472e7e7eaabc5cc16bf2ea9e6a462b1
5
5
  SHA512:
6
- metadata.gz: f2ab004ccc2f4b8998636ef0c8cf36f1cd2fa196994d979d501dcffaab6c61a954c0871d8aa9efcb97bdccfc5bf8676516f4e70e7422030374fcdf9e648b2bfd
7
- data.tar.gz: 3030df79fc82565daa166a779f7b7c1d2d7a0b2919c9740e155114ff157c6cbf1c78c6dbb7df3fa6294fadc84f7a34ece4448b80e0f876958a442fae9f1d1122
6
+ metadata.gz: eec150fe66faa24bba53d0c4e12ac9e07bdf05d7df44fea16b530f9c2183846ec53a799fe4004ef4be480477a0169a975c8f87b3f45c8a46fee16b8aff323322
7
+ data.tar.gz: a5b4ffdd39143ddbbfcbf28d6c03c7a8b24a26b0fa7cd41495bfa8f01ddbf5a968b6c429f42bd538ac4e409ee1bee7d946d51eebbc53b8bd8149e7abbaebcf5c
@@ -1,10 +1,10 @@
1
- #encoding: utf-8
2
- #Copyright (c) 2013-2015 zhhailon <zhhailon@gmail.com>
1
+ # encoding: utf-8
2
+ # Copyright (c) 2013-2015 zhhailon <zhhailon@gmail.com>
3
3
 
4
4
  require 'xiaohuangji/simsimi'
5
5
 
6
6
  module Xiaohuangji
7
- def self.chat(msg='')
7
+ def self.chat(msg = '')
8
8
  SimSimi.new.chat msg
9
9
  end
10
10
  end
@@ -1,35 +1,27 @@
1
- #encoding: utf-8
2
- #Copyright (c) 2013-2015 zhhailon <zhhailon@gmail.com>
1
+ # encoding: utf-8
2
+ # Copyright (c) 2013-2015 zhhailon <zhhailon@gmail.com>
3
3
 
4
4
  require 'open-uri'
5
5
  require 'json'
6
6
 
7
7
  module Xiaohuangji
8
8
  class SimSimi
9
+ attr_accessor :chat_url
9
10
  def initialize
10
11
  self.chat_url = 'http://www.simsimi.com/requestChat?lc=ch&ft=1.0&req=%s'
11
12
  end
12
13
 
13
14
  def chat(msg)
14
- unless msg.nil? or msg.empty?
15
+ if !msg.nil? && !msg.empty?
15
16
  ans = ''
16
- open(URI.encode(chat_url % msg)) { |f|
17
+ open(URI.encode(chat_url % msg)) do |f|
17
18
  res = JSON.parse f.read
18
19
  ans = res['res']
19
- }
20
+ end
20
21
  ans
21
22
  else
22
23
  '?'
23
24
  end
24
25
  end
25
-
26
- private
27
- def chat_url
28
- @chat_url
29
- end
30
-
31
- def chat_url=(url='')
32
- @chat_url = url
33
- end
34
26
  end
35
27
  end
@@ -1,16 +1,16 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'xiaohuangji'
3
- s.version = '0.0.3'
3
+ s.version = '0.0.5'
4
4
  s.authors = ['ZHANG Hailong']
5
- s.date = '2015-07-16'
5
+ s.date = '2015-07-18'
6
6
  s.summary = 'A chatting robot based on SimSimi.'
7
7
  s.description = 'Xiaohuangji is a chatting robot based on SimSimi.'
8
8
  s.email = 'zhhailon@gmail.com'
9
9
  s.homepage = 'https://github.com/zhhailon/my-xiaohuangji'
10
10
  s.files = [
11
- 'xiaohuangji.gemspec',
12
- 'README.md',
13
- 'lib/xiaohuangji.rb',
14
- 'lib/xiaohuangji/simsimi.rb'
15
- ]
11
+ 'xiaohuangji.gemspec',
12
+ 'README.md',
13
+ 'lib/xiaohuangji.rb',
14
+ 'lib/xiaohuangji/simsimi.rb'
15
+ ]
16
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xiaohuangji
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - ZHANG Hailong
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-16 00:00:00.000000000 Z
11
+ date: 2015-07-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Xiaohuangji is a chatting robot based on SimSimi.
14
14
  email: zhhailon@gmail.com