cleverbot_io 1.2.3 → 2.0.0
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/cleverbot.rb +6 -9
- metadata +3 -5
- data/lib/cleverbot_errors.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a6d4a6bdc02041ad062d219acbdb7d1a079ff8e
|
4
|
+
data.tar.gz: 02e5e7eaf207d13bf0f4dcc531fbcf11f89718e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df57a20f47919a9562e90eed543632ba6ad8e33d408c69ac807d3e586163758403e97a3f0463e5df06e4ba52e3598074bb2e962027da15e4fe89db5e92e4fe2f
|
7
|
+
data.tar.gz: 98a95c873870c0409518860fe7f31d030f4c3e8f869571f6f31906853a2da726e639c77af5a7d89d3f1c7c89ca12795b041f749a3d0d4b8ddc47dc503e45ae90
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
# Changelog
|
2
|
+
## Version 2
|
3
|
+
### 2.0.0
|
4
|
+
* Rewrite Errors stuff. There is now just a single `Cleverbot::Error` class. This improves portability with breaking API changes, and is just nicer in general.
|
5
|
+
|
2
6
|
## Version 1
|
3
7
|
### 1.2.3
|
4
8
|
* Fix unrecognized error throwing an error (#6) (saxton-tad)
|
data/lib/cleverbot.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'httpclient'
|
2
2
|
require 'oj'
|
3
|
-
require_relative 'cleverbot_errors'
|
4
3
|
|
5
4
|
class Cleverbot
|
6
5
|
# @return [String] The API User for the instance.
|
@@ -48,18 +47,16 @@ class Cleverbot
|
|
48
47
|
response['response']
|
49
48
|
end
|
50
49
|
|
50
|
+
# A generic Error class for all Cleverbot errors.
|
51
|
+
class Error < StandardError; end
|
52
|
+
|
51
53
|
private
|
52
54
|
|
53
55
|
# Throws the relevant errors if possible.
|
54
56
|
# @param status [String] The status value from the API
|
55
|
-
# @raise [
|
56
|
-
# @raise [DuplicatedReferenceNamesError] If the reference name is already in use by the instance.
|
57
|
+
# @raise [Cleverbot::Error] If an error is thrown by the Cleverbot API.
|
57
58
|
def try_throw(status)
|
58
|
-
|
59
|
-
|
60
|
-
when 'Error: reference name already exists' then fail Cleverbot::Errors::DuplicatedReferenceNamesError
|
61
|
-
when 'success' then return
|
62
|
-
else fail "#{status} UNRECOGNIZED ERROR! PLEASE REPORT TO CLEVERBOT RUBY ISSUE TRACKER."
|
63
|
-
end
|
59
|
+
return if status == 'success'
|
60
|
+
fail Error.new(status)
|
64
61
|
end
|
65
62
|
end
|
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:
|
4
|
+
version: 2.0.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: 2017-
|
11
|
+
date: 2017-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -46,7 +46,6 @@ extra_rdoc_files: []
|
|
46
46
|
files:
|
47
47
|
- CHANGELOG.md
|
48
48
|
- lib/cleverbot.rb
|
49
|
-
- lib/cleverbot_errors.rb
|
50
49
|
homepage: https://github.com/CleverbotIO/ruby-cleverbot.io
|
51
50
|
licenses:
|
52
51
|
- MIT
|
@@ -68,9 +67,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
68
67
|
version: '0'
|
69
68
|
requirements: []
|
70
69
|
rubyforge_project:
|
71
|
-
rubygems_version: 2.6.
|
70
|
+
rubygems_version: 2.6.10
|
72
71
|
signing_key:
|
73
72
|
specification_version: 4
|
74
73
|
summary: A Ruby wrapper for the Cleverbot.io web API.
|
75
74
|
test_files: []
|
76
|
-
has_rdoc:
|
data/lib/cleverbot_errors.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
class Cleverbot
|
2
|
-
class Errors
|
3
|
-
class IncorrectCredentialsError < StandardError
|
4
|
-
def message
|
5
|
-
'Incorrect API credentials.'
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
class DuplicatedReferenceNamesError < StandardError
|
10
|
-
def message
|
11
|
-
'Reference name already exists.'
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|