deepl-rb 2.2.0 → 2.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 00b65dd648e7d29dc160d9e8b66c2eecc15dccdc
4
- data.tar.gz: 47a4e9cd8476b801b617f1290a020e017aa80bb4
3
+ metadata.gz: fedf9315cf7b163148b9eebbbded4f80c93c4ae3
4
+ data.tar.gz: aa81c5a04442a74fc5099acb060bbbbd71e9bf00
5
5
  SHA512:
6
- metadata.gz: 3ef63e90c6708751fffd2229c0e3ba96951932b2a520f66f566856b2990466bb1dc876c815f224495ae642fba9266591af74d1029fadf4abc2263f8ba25a570b
7
- data.tar.gz: a017cc9b56ee7c10cba7e41c59bb17e5969f2e285d8293493ef1dff02947cfdb508684901dd0891ae3c1e17cce1511273ed9f758074607f5e9066c590adffd0d
6
+ metadata.gz: 8ef069fb972692ec56ac2688c85385de934beba10ce3f180fd354e42a14c91568d37dfa9549dc19a3c55824575885ead52d7fbea69fc58322851c2149dd01f0d
7
+ data.tar.gz: f92c7383dc6511902f825ba373aaf5c6bf7470a369d9a042dd28bf918409d7b9e80b4c044d50e09522e3c6410e3bae77a7d732b9e590db71022ac7227b4af18a
data/README.md CHANGED
@@ -87,9 +87,11 @@ Here's a list of available language codes:
87
87
  | `DE` | German
88
88
  | `FR` | French
89
89
  | `ES` | Spanish
90
+ | `PT` | Portuguese
90
91
  | `IT` | Italian
91
92
  | `NL` | Dutch
92
93
  | `PL` | Polish
94
+ | `RU` | Russian
93
95
 
94
96
  You can also use custom query parameters, like `tag_handling`, `split_sentences`, `non_splitting_tags` or `ignore_tags`:
95
97
 
@@ -128,11 +130,12 @@ puts usage.character_limit
128
130
 
129
131
  You can capture and process exceptions that may be raised during API calls. These are all the possible exceptions:
130
132
 
131
- | Exception class | Descripcion |
133
+ | Exception class | Description |
132
134
  | --------------- | ----------- |
133
- | `DeepL::Exceptions::AuthorizationFailed` | The authorization process has failed. Check your auth_key value. |
135
+ | `DeepL::Exceptions::AuthorizationFailed` | The authorization process has failed. Check your `auth_key` value. |
134
136
  | `DeepL::Exceptions::BadRequest` | Something is wrong in your request. Check `exception.message` for more information. |
135
137
  | `DeepL::Exceptions::LimitExceeded` | You've reached the API's call limit. |
138
+ | `DeepL::Exceptions::QuotaExceeded` | You've reached the API's character limit. |
136
139
  | `DeepL::Exceptions::RequestError` | An unkown request error. Check `exception.response` and `exception.request` for more information. |
137
140
 
138
141
  An exampling of handling a generic exception:
@@ -146,9 +149,31 @@ rescue DeepL::Exceptions::RequestError => e
146
149
  puts "Response body: #{e.response.body}"
147
150
  puts "Request body: #{e.request.body}"
148
151
  end
152
+ ```
153
+
154
+ ## Integrations
155
+
156
+ ### Ruby on Rails
149
157
 
158
+ You may use this gem as a standalone service by creating an initializer on your
159
+ `config/initializers` folder with your DeepL configuration. For example:
160
+
161
+ ```rb
162
+ # config/initializers/deepl.rb
163
+ DeepL.configure do |config|
164
+ # Your configuration goes here
165
+ end
150
166
  ```
151
167
 
168
+ Since the DeepL service is defined globally, you can use service anywhere in your code
169
+ (controllers, models, views, jobs, plain ruby objects… you name it).
170
+
171
+ ### i18n-tasks
172
+
173
+ You may also take a look at [`i18n-tasks`](https://github.com/glebm/i18n-tasks), which is a gem
174
+ that helps you find and manage missing and unused translations. `deepl-rb` is used as one the
175
+ backend services to translate content.
176
+
152
177
  ## Development
153
178
 
154
179
  Clone the repository, and install its dependencies:
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.2.0
1
+ 2.2.1
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: deepl-rb 2.2.0 ruby lib
5
+ # stub: deepl-rb 2.2.1 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "deepl-rb".freeze
9
- s.version = "2.2.0"
9
+ s.version = "2.2.1"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Daniel Herzog".freeze]
14
- s.date = "2018-11-28"
14
+ s.date = "2020-03-08"
15
15
  s.description = "A simple ruby wrapper for the DeepL translation API (v1). For more information, check this: https://www.deepl.com/docs/api-reference.html".freeze
16
16
  s.email = "info@danielherzog.es".freeze
17
17
  s.extra_rdoc_files = [
@@ -35,6 +35,7 @@ Gem::Specification.new do |s|
35
35
  "lib/deepl/exceptions/bad_request.rb",
36
36
  "lib/deepl/exceptions/error.rb",
37
37
  "lib/deepl/exceptions/limit_exceeded.rb",
38
+ "lib/deepl/exceptions/quota_exceeded.rb",
38
39
  "lib/deepl/exceptions/request_error.rb",
39
40
  "lib/deepl/requests/base.rb",
40
41
  "lib/deepl/requests/translate.rb",
@@ -8,6 +8,7 @@ require 'deepl/exceptions/request_error'
8
8
  require 'deepl/exceptions/authorization_failed'
9
9
  require 'deepl/exceptions/bad_request'
10
10
  require 'deepl/exceptions/limit_exceeded'
11
+ require 'deepl/exceptions/quota_exceeded'
11
12
 
12
13
  # -- Requests
13
14
  require 'deepl/requests/base'
@@ -0,0 +1,9 @@
1
+ module DeepL
2
+ module Exceptions
3
+ class QuotaExceeded < RequestError
4
+ def message
5
+ 'Quota exceeded. The character limit has been reached.'
6
+ end
7
+ end
8
+ end
9
+ end
@@ -62,6 +62,7 @@ module DeepL
62
62
  when '400' then raise Exceptions::BadRequest.new(request, response)
63
63
  when '403' then raise Exceptions::AuthorizationFailed.new(request, response)
64
64
  when '429' then raise Exceptions::LimitExceeded.new(request, response)
65
+ when '456' then raise Exceptions::QuotaExceeded.new(request, response)
65
66
  else raise Exceptions::RequestError.new(request, response)
66
67
  end
67
68
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deepl-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Herzog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-28 00:00:00.000000000 Z
11
+ date: 2020-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: juwelier
@@ -49,6 +49,7 @@ files:
49
49
  - lib/deepl/exceptions/bad_request.rb
50
50
  - lib/deepl/exceptions/error.rb
51
51
  - lib/deepl/exceptions/limit_exceeded.rb
52
+ - lib/deepl/exceptions/quota_exceeded.rb
52
53
  - lib/deepl/exceptions/request_error.rb
53
54
  - lib/deepl/requests/base.rb
54
55
  - lib/deepl/requests/translate.rb