deepl-rb 3.7.0 → 3.8.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/.gitlab-ci.yml +3 -1
- data/CHANGELOG.md +17 -1
- data/Gemfile +0 -2
- data/README.md +12 -12
- data/VERSION +1 -1
- data/deepl-rb.gemspec +27 -22
- data/lib/deepl/requests/rephrase.rb +3 -2
- data/lib/deepl/requests/translate.rb +2 -2
- data/lib/deepl.rb +7 -4
- data/lib/version.rb +1 -1
- data/spec/api/deepl_spec.rb +134 -332
- data/spec/integration_tests/document_api_spec.rb +4 -18
- data/spec/integration_tests/document_error_paths_spec.rb +33 -0
- data/spec/integration_tests/glossary_api_spec.rb +114 -0
- data/spec/integration_tests/glossary_error_paths_spec.rb +107 -0
- data/spec/integration_tests/languages_api_spec.rb +54 -0
- data/spec/integration_tests/languages_error_paths_spec.rb +25 -0
- data/spec/integration_tests/rephrase_api_spec.rb +90 -0
- data/spec/integration_tests/rephrase_error_paths_spec.rb +53 -0
- data/spec/integration_tests/smoke_test_spec.rb +24 -0
- data/spec/integration_tests/style_rule_api_spec.rb +1 -19
- data/spec/integration_tests/style_rule_error_paths_spec.rb +45 -0
- data/spec/integration_tests/translate_api_spec.rb +98 -0
- data/spec/integration_tests/translate_error_paths_spec.rb +48 -0
- data/spec/integration_tests/translation_memory_api_spec.rb +1 -17
- data/spec/integration_tests/translation_memory_error_paths_spec.rb +19 -0
- data/spec/integration_tests/usage_api_spec.rb +29 -0
- data/spec/integration_tests/usage_error_paths_spec.rb +18 -0
- data/spec/requests/glossary/create_spec.rb +0 -21
- data/spec/requests/glossary/destroy_spec.rb +0 -39
- data/spec/requests/glossary/entries_spec.rb +0 -35
- data/spec/requests/glossary/find_spec.rb +0 -40
- data/spec/requests/glossary/language_pairs_spec.rb +0 -13
- data/spec/requests/glossary/list_spec.rb +0 -27
- data/spec/requests/languages_spec.rb +0 -41
- data/spec/requests/rephrase_spec.rb +13 -139
- data/spec/requests/style_rule/create_custom_instruction_spec.rb +0 -24
- data/spec/requests/style_rule/create_spec.rb +0 -16
- data/spec/requests/style_rule/destroy_custom_instruction_spec.rb +0 -26
- data/spec/requests/style_rule/destroy_spec.rb +0 -27
- data/spec/requests/style_rule/find_custom_instruction_spec.rb +0 -27
- data/spec/requests/style_rule/find_spec.rb +0 -28
- data/spec/requests/style_rule/list_spec.rb +0 -31
- data/spec/requests/style_rule/update_configured_rules_spec.rb +0 -21
- data/spec/requests/style_rule/update_custom_instruction_spec.rb +0 -26
- data/spec/requests/style_rule/update_spec.rb +0 -19
- data/spec/requests/translate_spec.rb +8 -217
- data/spec/requests/translation_memory/list_spec.rb +0 -34
- data/spec/requests/usage_spec.rb +0 -16
- data/spec/resources/custom_instruction_spec.rb +32 -0
- data/spec/resources/style_rule_spec.rb +68 -0
- data/spec/spec_helper.rb +15 -45
- data/spec/support/live_mock_server.rb +12 -0
- data/spec/support/managed_glossary.rb +17 -0
- data/spec/support/managed_style_rule.rb +17 -0
- data/spec/support/managed_translation_memory.rb +7 -0
- metadata +23 -21
- data/spec/fixtures/vcr_cassettes/deepl_document.yml +0 -95
- data/spec/fixtures/vcr_cassettes/deepl_document_download.yml +0 -1214
- data/spec/fixtures/vcr_cassettes/deepl_glossaries.yml +0 -1163
- data/spec/fixtures/vcr_cassettes/deepl_languages.yml +0 -54
- data/spec/fixtures/vcr_cassettes/deepl_rephrase.yml +0 -87
- data/spec/fixtures/vcr_cassettes/deepl_translate.yml +0 -358
- data/spec/fixtures/vcr_cassettes/deepl_usage.yml +0 -129
- data/spec/fixtures/vcr_cassettes/glossaries.yml +0 -1702
- data/spec/fixtures/vcr_cassettes/languages.yml +0 -229
- data/spec/fixtures/vcr_cassettes/rephrase_texts.yml +0 -401
- data/spec/fixtures/vcr_cassettes/style_rules.yml +0 -92
- data/spec/fixtures/vcr_cassettes/style_rules_crud.yml +0 -926
- data/spec/fixtures/vcr_cassettes/translate_texts.yml +0 -10630
- data/spec/fixtures/vcr_cassettes/translation_memories.yml +0 -74
- data/spec/fixtures/vcr_cassettes/usage.yml +0 -171
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1e06f20b76b38eff20ef4f3f7c7863f374afe2e314438b0bc021df6c4535f991
|
|
4
|
+
data.tar.gz: 30ac12887bd80d6e81cf5c815e5bb8bc5725ea50c66edfd7f4c34c1881e5ad5d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0c5ded1350056aa468d7255ff93eb537dfcf141608a1761651530d5a1d01851bd242a1f205b14626ff8136ec103f38911731242f86e0127e00e75a6fc5c7da08
|
|
7
|
+
data.tar.gz: 570ce96a8751e4de0116b93cac78d08453df5eaf65bef669f9151b361481ab85bea83f72e8d07ffaac01c7e010d8537fd003b0ef3f762d2cc3b2c29c601bfec0
|
data/.gitlab-ci.yml
CHANGED
|
@@ -118,6 +118,9 @@ semgrep-sast:
|
|
|
118
118
|
.test_base:
|
|
119
119
|
stage: test
|
|
120
120
|
extends: .test
|
|
121
|
+
variables:
|
|
122
|
+
VALIDATE_REQUESTS_FOR_DEEPL_MOCK: '1'
|
|
123
|
+
VALIDATE_RESPONSES_FOR_DEEPL_MOCK: '1'
|
|
121
124
|
parallel:
|
|
122
125
|
matrix:
|
|
123
126
|
- DOCKER_IMAGE: 'ruby:2.7'
|
|
@@ -164,7 +167,6 @@ test_manual:
|
|
|
164
167
|
rules:
|
|
165
168
|
- if: $CI_PIPELINE_SOURCE != "schedule"
|
|
166
169
|
|
|
167
|
-
|
|
168
170
|
# stage: publish ----------------------
|
|
169
171
|
|
|
170
172
|
gitlab release:
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
7
|
## [Unreleased]
|
|
8
|
+
### Changed
|
|
9
|
+
- Reworked the test suite to run against the `deepl-mock` server with OpenAPI
|
|
10
|
+
request and response validation enabled in CI, replacing recorded VCR
|
|
11
|
+
cassettes. Added live integration and error-path specs across all endpoints,
|
|
12
|
+
with resource-level unit specs for response field mapping.
|
|
13
|
+
|
|
14
|
+
### Removed
|
|
15
|
+
- Dropped VCR cassette playback and the `vcr` and `webmock` development
|
|
16
|
+
dependencies.
|
|
17
|
+
|
|
18
|
+
## [3.8.0] - 2026-05-27
|
|
19
|
+
### Added
|
|
20
|
+
- Added support for passing additional HTTP headers to `translate()` and
|
|
21
|
+
`rephrase()`. This can be used to send the `X-DeepL-Reporting-Tag` header
|
|
22
|
+
for usage reporting.
|
|
8
23
|
|
|
9
24
|
## [3.7.0] - 2026-05-14
|
|
10
25
|
### Added
|
|
@@ -119,7 +134,8 @@ The change in major version is only due to the change in maintainership, there i
|
|
|
119
134
|
### Fixed
|
|
120
135
|
- Make RequestEntityTooLarge error message more clear
|
|
121
136
|
|
|
122
|
-
[Unreleased]: https://github.com/DeepLcom/deepl-rb/compare/v3.
|
|
137
|
+
[Unreleased]: https://github.com/DeepLcom/deepl-rb/compare/v3.8.0...HEAD
|
|
138
|
+
[3.8.0]: https://github.com/DeepLcom/deepl-rb/compare/v3.7.0...v3.8.0
|
|
123
139
|
[3.7.0]: https://github.com/DeepLcom/deepl-rb/compare/v3.6.1...v3.7.0
|
|
124
140
|
[3.6.1]: https://github.com/DeepLcom/deepl-rb/compare/v3.6.0...v3.6.1
|
|
125
141
|
[3.6.0]: https://github.com/DeepLcom/deepl-rb/compare/v3.5.1...v3.6.0
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -551,6 +551,18 @@ doc_handle = DeepL.document.upload('/path/to/spanish_document.pdf', 'ES', 'EN',
|
|
|
551
551
|
|
|
552
552
|
The `extra_body_parameters` option allows you to pass arbitrary parameters in the request body. This can be used to access beta features by adding new parameters, or to override built-in parameters (such as `target_lang`, `source_lang`, etc.) for testing purposes.
|
|
553
553
|
|
|
554
|
+
### Sending additional HTTP headers
|
|
555
|
+
|
|
556
|
+
You can pass additional HTTP headers to `translate`, `rephrase`, and the
|
|
557
|
+
`document` methods. For example, to send the `X-DeepL-Reporting-Tag` header
|
|
558
|
+
for usage reporting (see the [cookbook entry](https://developers.deepl.com/docs/learning-how-tos/cookbook/sending-custom-reporting-tags-from-client-libraries)):
|
|
559
|
+
|
|
560
|
+
```rb
|
|
561
|
+
additional_headers = { 'X-DeepL-Reporting-Tag' => 'my-tag' }
|
|
562
|
+
translation = DeepL.translate 'Hello, world!', 'EN', 'DE', {}, additional_headers
|
|
563
|
+
rephrased = DeepL.rephrase 'Hello, world!', 'EN', nil, nil, {}, additional_headers
|
|
564
|
+
```
|
|
565
|
+
|
|
554
566
|
### Handle exceptions
|
|
555
567
|
|
|
556
568
|
You can capture and process exceptions that may be raised during API calls. These are all the possible exceptions:
|
|
@@ -712,18 +724,6 @@ To run tests (rspec and rubocop), use
|
|
|
712
724
|
bundle exec rake test
|
|
713
725
|
```
|
|
714
726
|
|
|
715
|
-
### Caution: Changing VCR Tests
|
|
716
|
-
|
|
717
|
-
If you need to rerecord some of the VCR tests, simply setting `record: :new_episodes` and rerunning `rspec` won't be enough in some cases, specifically around document translation (due to its statefulness) and glossaries (since a glossary ID is associated with a specific API account).
|
|
718
|
-
For example, there are document translations tests that split up the `upload`, `get_status` and `download` calls into separate test cases. You need to first rerecord the `upload` call, you can do execute a single test like this (the line should be where the `it` block of the test starts):
|
|
719
|
-
|
|
720
|
-
```sh
|
|
721
|
-
rspec ./spec/api/deepl_spec.rb:152
|
|
722
|
-
```
|
|
723
|
-
|
|
724
|
-
This will return a `document_id` and a `document_key`, you will need to update the values in the `get_status` and `download` tests accordingly. You can find examples for this in the git history.
|
|
725
|
-
Similarly, for the glossary tests you will need to delete the recorded HTTP requests for certain glossary IDs so that `rspec` will create the glossaries on your account instead. Feel free to reach out on our discord if you run into any trouble here.
|
|
726
|
-
|
|
727
727
|
## Acknowledgements
|
|
728
728
|
|
|
729
729
|
This library was originally developed by [Daniel Herzog](mailto:info@danielherzog.es), we are grateful for his contributions. Beginning with v3.0.0, DeepL took over development and officially supports and maintains the library together with Daniel.
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
3.
|
|
1
|
+
3.8.0
|
data/deepl-rb.gemspec
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
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 3.
|
|
5
|
+
# stub: deepl-rb 3.8.0 ruby lib
|
|
6
6
|
|
|
7
7
|
Gem::Specification.new do |s|
|
|
8
8
|
s.name = "deepl-rb".freeze
|
|
9
|
-
s.version = "3.
|
|
9
|
+
s.version = "3.8.0".freeze
|
|
10
10
|
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
|
12
12
|
s.metadata = { "bug_tracker_uri" => "https://github.com/DeepLcom/deepl-rb/issues", "changelog_uri" => "https://github.com/DeepLcom/deepl-rb/blob/main/CHANGELOG.md", "documentation_uri" => "https://github.com/DeepLcom/deepl-rb/blob/main/README.md", "homepage_uri" => "https://github.com/DeepLcom/deepl-rb" } if s.respond_to? :metadata=
|
|
13
13
|
s.require_paths = ["lib".freeze]
|
|
14
14
|
s.authors = ["DeepL SE".freeze]
|
|
15
|
-
s.date = "2026-
|
|
15
|
+
s.date = "2026-06-18"
|
|
16
16
|
s.description = "Official Ruby library for the DeepL language translation API (v2). For more information, check this: https://www.deepl.com/docs/api-reference.html".freeze
|
|
17
17
|
s.email = "open-source@deepl.com".freeze
|
|
18
18
|
s.extra_rdoc_files = [
|
|
@@ -105,25 +105,24 @@ Gem::Specification.new do |s|
|
|
|
105
105
|
"spec/api/configuration_spec.rb",
|
|
106
106
|
"spec/api/deepl_spec.rb",
|
|
107
107
|
"spec/constants/constants_spec.rb",
|
|
108
|
-
"spec/fixtures/vcr_cassettes/deepl_document.yml",
|
|
109
|
-
"spec/fixtures/vcr_cassettes/deepl_document_download.yml",
|
|
110
|
-
"spec/fixtures/vcr_cassettes/deepl_glossaries.yml",
|
|
111
|
-
"spec/fixtures/vcr_cassettes/deepl_languages.yml",
|
|
112
|
-
"spec/fixtures/vcr_cassettes/deepl_rephrase.yml",
|
|
113
|
-
"spec/fixtures/vcr_cassettes/deepl_translate.yml",
|
|
114
|
-
"spec/fixtures/vcr_cassettes/deepl_usage.yml",
|
|
115
|
-
"spec/fixtures/vcr_cassettes/glossaries.yml",
|
|
116
|
-
"spec/fixtures/vcr_cassettes/languages.yml",
|
|
117
|
-
"spec/fixtures/vcr_cassettes/rephrase_texts.yml",
|
|
118
|
-
"spec/fixtures/vcr_cassettes/style_rules.yml",
|
|
119
|
-
"spec/fixtures/vcr_cassettes/style_rules_crud.yml",
|
|
120
|
-
"spec/fixtures/vcr_cassettes/translate_texts.yml",
|
|
121
|
-
"spec/fixtures/vcr_cassettes/translation_memories.yml",
|
|
122
|
-
"spec/fixtures/vcr_cassettes/usage.yml",
|
|
123
108
|
"spec/integration_tests/document_api_spec.rb",
|
|
109
|
+
"spec/integration_tests/document_error_paths_spec.rb",
|
|
110
|
+
"spec/integration_tests/glossary_api_spec.rb",
|
|
111
|
+
"spec/integration_tests/glossary_error_paths_spec.rb",
|
|
124
112
|
"spec/integration_tests/integration_test_utils.rb",
|
|
113
|
+
"spec/integration_tests/languages_api_spec.rb",
|
|
114
|
+
"spec/integration_tests/languages_error_paths_spec.rb",
|
|
115
|
+
"spec/integration_tests/rephrase_api_spec.rb",
|
|
116
|
+
"spec/integration_tests/rephrase_error_paths_spec.rb",
|
|
117
|
+
"spec/integration_tests/smoke_test_spec.rb",
|
|
125
118
|
"spec/integration_tests/style_rule_api_spec.rb",
|
|
119
|
+
"spec/integration_tests/style_rule_error_paths_spec.rb",
|
|
120
|
+
"spec/integration_tests/translate_api_spec.rb",
|
|
121
|
+
"spec/integration_tests/translate_error_paths_spec.rb",
|
|
126
122
|
"spec/integration_tests/translation_memory_api_spec.rb",
|
|
123
|
+
"spec/integration_tests/translation_memory_error_paths_spec.rb",
|
|
124
|
+
"spec/integration_tests/usage_api_spec.rb",
|
|
125
|
+
"spec/integration_tests/usage_error_paths_spec.rb",
|
|
127
126
|
"spec/requests/extra_body_parameters_types_spec.rb",
|
|
128
127
|
"spec/requests/glossary/create_spec.rb",
|
|
129
128
|
"spec/requests/glossary/destroy_spec.rb",
|
|
@@ -146,22 +145,28 @@ Gem::Specification.new do |s|
|
|
|
146
145
|
"spec/requests/translate_spec.rb",
|
|
147
146
|
"spec/requests/translation_memory/list_spec.rb",
|
|
148
147
|
"spec/requests/usage_spec.rb",
|
|
148
|
+
"spec/resources/custom_instruction_spec.rb",
|
|
149
149
|
"spec/resources/glossary_spec.rb",
|
|
150
150
|
"spec/resources/language_pair_spec.rb",
|
|
151
151
|
"spec/resources/language_spec.rb",
|
|
152
|
+
"spec/resources/style_rule_spec.rb",
|
|
152
153
|
"spec/resources/text_spec.rb",
|
|
153
154
|
"spec/resources/translation_memory_spec.rb",
|
|
154
155
|
"spec/resources/usage_spec.rb",
|
|
155
|
-
"spec/spec_helper.rb"
|
|
156
|
+
"spec/spec_helper.rb",
|
|
157
|
+
"spec/support/live_mock_server.rb",
|
|
158
|
+
"spec/support/managed_glossary.rb",
|
|
159
|
+
"spec/support/managed_style_rule.rb",
|
|
160
|
+
"spec/support/managed_translation_memory.rb"
|
|
156
161
|
]
|
|
157
162
|
s.homepage = "https://github.com/DeepLcom/deepl-rb".freeze
|
|
158
163
|
s.licenses = ["MIT".freeze]
|
|
159
|
-
s.rubygems_version = "3.
|
|
164
|
+
s.rubygems_version = "3.6.2".freeze
|
|
160
165
|
s.summary = "Official Ruby library for the DeepL language translation API.".freeze
|
|
161
166
|
|
|
162
167
|
s.specification_version = 4
|
|
163
168
|
|
|
164
|
-
s.add_development_dependency(%q<juwelier>.freeze, [">= 0"])
|
|
165
|
-
s.add_development_dependency(%q<byebug>.freeze, [">= 0"])
|
|
169
|
+
s.add_development_dependency(%q<juwelier>.freeze, [">= 0".freeze])
|
|
170
|
+
s.add_development_dependency(%q<byebug>.freeze, [">= 0".freeze])
|
|
166
171
|
end
|
|
167
172
|
|
|
@@ -8,8 +8,9 @@ module DeepL
|
|
|
8
8
|
class Rephrase < Base
|
|
9
9
|
attr_reader :text, :target_lang, :writing_style, :tone
|
|
10
10
|
|
|
11
|
-
def initialize(api, text, target_lang = nil, writing_style = nil, tone = nil, options = {}
|
|
12
|
-
|
|
11
|
+
def initialize(api, text, target_lang = nil, writing_style = nil, tone = nil, options = {}, # rubocop:disable Metrics/ParameterLists
|
|
12
|
+
additional_headers = {})
|
|
13
|
+
super(api, options, additional_headers)
|
|
13
14
|
@text = text
|
|
14
15
|
@target_lang = target_lang
|
|
15
16
|
@writing_style = writing_style
|
|
@@ -30,8 +30,8 @@ module DeepL
|
|
|
30
30
|
attr_reader :text, :source_lang, :target_lang, :ignore_tags, :splitting_tags,
|
|
31
31
|
:non_splitting_tags, :model_type, :custom_instructions, :tag_handling_version
|
|
32
32
|
|
|
33
|
-
def initialize(api, text, source_lang, target_lang, options = {})
|
|
34
|
-
super(api, options)
|
|
33
|
+
def initialize(api, text, source_lang, target_lang, options = {}, additional_headers = {})
|
|
34
|
+
super(api, options, additional_headers)
|
|
35
35
|
@text = text
|
|
36
36
|
@source_lang = source_lang
|
|
37
37
|
@target_lang = target_lang
|
data/lib/deepl.rb
CHANGED
|
@@ -100,9 +100,10 @@ module DeepL
|
|
|
100
100
|
Requests::Languages.new(api, options).request
|
|
101
101
|
end
|
|
102
102
|
|
|
103
|
-
def translate(text, source_lang, target_lang, options = {})
|
|
103
|
+
def translate(text, source_lang, target_lang, options = {}, additional_headers = {})
|
|
104
104
|
configure if @configuration.nil?
|
|
105
|
-
Requests::Translate.new(api, text, source_lang, target_lang, options
|
|
105
|
+
Requests::Translate.new(api, text, source_lang, target_lang, options,
|
|
106
|
+
additional_headers).request
|
|
106
107
|
end
|
|
107
108
|
|
|
108
109
|
def document(options = {})
|
|
@@ -125,9 +126,11 @@ module DeepL
|
|
|
125
126
|
TranslationMemoryApi.new(api, options)
|
|
126
127
|
end
|
|
127
128
|
|
|
128
|
-
def rephrase(text, target_lang = nil, writing_style = nil, tone = nil, options = {}
|
|
129
|
+
def rephrase(text, target_lang = nil, writing_style = nil, tone = nil, options = {}, # rubocop:disable Metrics/ParameterLists
|
|
130
|
+
additional_headers = {})
|
|
129
131
|
configure if @configuration.nil?
|
|
130
|
-
Requests::Rephrase.new(api, text, target_lang, writing_style, tone, options
|
|
132
|
+
Requests::Rephrase.new(api, text, target_lang, writing_style, tone, options,
|
|
133
|
+
additional_headers).request
|
|
131
134
|
end
|
|
132
135
|
|
|
133
136
|
def usage(options = {})
|
data/lib/version.rb
CHANGED