cleverbot_io 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -0
  3. data/lib/cleverbot.rb +9 -13
  4. metadata +5 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: baa72db1b8644ae3cb3da7ea0bd67247f9ac8cdb
4
- data.tar.gz: 62ff76a48deb80a6f8a3dbb7178f18b2dc6af61d
3
+ metadata.gz: 44eeeb0cce1a6763a31117f2e1ce22c7544d69b0
4
+ data.tar.gz: 010a3e52ff6cd191a9104719a45a543dfd5a80c7
5
5
  SHA512:
6
- metadata.gz: 84ac7b30f4d5ed396ada526ee27106a7dbb7f1f0eb1b5f5e410f89ba1f38698653be3d31439e972d37c27ee766a1dd985de40d607b0993fd5f2051a878eb40ef
7
- data.tar.gz: f7ad9ded49e0b903edc2f699645d9ad7aeb505b14d00fb3bea92be2eb225214ae0a2cd2cdc46c95207f996a2528adcc79af91f6fee107220cbe16d0173a93e9c
6
+ metadata.gz: cf1a687301292fa6607ddf15fcc6a9ff37353453ea8f77ccafd4762f01d599bcb13a1f49bdf50018bad37e2beacf34ffe772c0e7e4a03b843291480eab3fc146
7
+ data.tar.gz: a37bf1e647a12fe59afea55ea75af16ff41940e26d35d8c4917946727358f153a426f95e3cec24a8992672dbe738fd344cd8fce3e0b2b0336c600dbcb9cadebd
@@ -1,4 +1,9 @@
1
1
  # Changelog
2
2
  ## Version 1
3
+ ### 1.1.0
4
+ * Merge `#create` into `#initialize`.
5
+ * `api_user` and `api_key` are no longer accessors, but readers.
6
+ * Fix old links and what-not.
7
+
3
8
  ### 1.0.0
4
9
  * Initial release.
@@ -2,20 +2,20 @@ require 'httpclient'
2
2
  require 'json'
3
3
 
4
4
  class Cleverbot
5
- attr_accessor :api_user
6
- attr_accessor :api_key
5
+ attr_reader :api_user
6
+ attr_reader :api_key
7
7
  attr_accessor :nick
8
8
 
9
+ # Creates a new instance of the Cleverbot.
10
+ # @param api_user [String] The API user for the Cleverbot API.
11
+ # @param api_key [String] The API key for the Cleverbot API.
12
+ # @param nick [String] The reference nick. If nil, one will be set automatically through the API.
9
13
  def initialize(api_user, api_key, nick = nil)
10
14
  @api_user = api_user
11
15
  @api_key = api_key
12
16
  @nick = nick
13
17
  @client = HTTPClient.new
14
- end
15
18
 
16
- # Creates a new bot instance based on the nick. If no nick has been set, this will set a random one.
17
- # @return [Boolean] Whether the request was successful. If true, nick will be set.
18
- def create
19
19
  params = {
20
20
  user: @api_user,
21
21
  key: @api_key
@@ -23,23 +23,19 @@ class Cleverbot
23
23
  params[:nick] = @nick unless @nick.nil?
24
24
  response = JSON.parse(@client.post('https://cleverbot.io/1.0/create', params).body)
25
25
  @nick = response['nick'] if response['status'] == 'success'
26
-
27
- response['status'] == 'success'
28
26
  end
29
27
 
30
28
  # Sends the bot a message and returns its response. If the nick has not been set, it will call #{create}.
31
29
  # @param str [String] The message to send to the bot.
32
30
  # @return [String] The bot's response, or its error message.
31
+ # @todo Error handling.
33
32
  def say(str)
34
33
  params = {
35
34
  user: @api_user,
36
35
  key: @api_key,
37
- text: str
36
+ text: str,
37
+ nick: @nick
38
38
  }
39
- if @nick.nil?
40
- create
41
- end
42
- params[:nick] = @nick
43
39
  response = JSON.parse(@client.post('https://cleverbot.io/1.0/ask', params).body)
44
40
  if response['status'] == 'success'
45
41
  response['response']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cleverbot_io
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eli Foster
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-01 00:00:00.000000000 Z
11
+ date: 2016-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -24,7 +24,7 @@ dependencies:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
26
  version: 2.7.1
27
- description: A very basic wrapper to the Cleverbot.io web API.
27
+ description: A fully featured wrapper to the Cleverbot.io web API.
28
28
  email: elifosterwy@gmail.com
29
29
  executables: []
30
30
  extensions: []
@@ -32,11 +32,11 @@ extra_rdoc_files: []
32
32
  files:
33
33
  - CHANGELOG.md
34
34
  - lib/cleverbot.rb
35
- homepage: https://github.com/elifoster/cleverbot_io
35
+ homepage: https://github.com/CleverbotIO/ruby-cleverbot.io
36
36
  licenses:
37
37
  - CC-BY-NC-ND-4.0
38
38
  metadata:
39
- issue_tracker: https://github.com/elifoster/cleverbot_io/issues
39
+ issue_tracker: https://github.com/CleverobtIO/ruby-cleverbot.io/issues
40
40
  post_install_message:
41
41
  rdoc_options: []
42
42
  require_paths: