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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: caa1d8d6444ccf76e89d22a383bd515d30eb2210
4
- data.tar.gz: 8004497531599cb36ec28aa75e53fbfbc11a2922
3
+ metadata.gz: 9a6d4a6bdc02041ad062d219acbdb7d1a079ff8e
4
+ data.tar.gz: 02e5e7eaf207d13bf0f4dcc531fbcf11f89718e1
5
5
  SHA512:
6
- metadata.gz: 74cc7a1cf4b0963c952749c47a85f477013da0ad47d02f2493be4789b1cf50fde844356708a6b85b22d39a3baed0e1810619c2f553e560d6d4d4b20148a55d2c
7
- data.tar.gz: 598d18f2fbda688a59c08f64c24c3c10cc0f649637d02af9919018b352f5335b9894168507263c6d62f30c4a1c222055e0ee461edb483e99b3f361f4d360c124
6
+ metadata.gz: df57a20f47919a9562e90eed543632ba6ad8e33d408c69ac807d3e586163758403e97a3f0463e5df06e4ba52e3598074bb2e962027da15e4fe89db5e92e4fe2f
7
+ data.tar.gz: 98a95c873870c0409518860fe7f31d030f4c3e8f869571f6f31906853a2da726e639c77af5a7d89d3f1c7c89ca12795b041f749a3d0d4b8ddc47dc503e45ae90
@@ -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)
@@ -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 [IncorrectCredentialsError] If the api_user and api_key are incorrect.
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
- case status
59
- when 'Error: API credentials incorrect' then fail Cleverbot::Errors::IncorrectCredentialsError
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: 1.2.3
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-01-23 00:00:00.000000000 Z
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.4
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:
@@ -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