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
data/spec/spec_helper.rb
CHANGED
|
@@ -14,59 +14,29 @@ SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
|
|
|
14
14
|
require_relative '../lib/deepl'
|
|
15
15
|
require_relative 'integration_tests/integration_test_utils'
|
|
16
16
|
|
|
17
|
+
# Auto-load test helpers under spec/support
|
|
18
|
+
Dir[File.expand_path('support/**/*.rb', __dir__)].sort.each { |f| require f }
|
|
19
|
+
|
|
17
20
|
# Lib config
|
|
18
21
|
ENV['DEEPL_AUTH_KEY'] ||= 'TEST-TOKEN'
|
|
19
22
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
RSpec.configure do |config|
|
|
24
|
+
config.include ManagedGlossary
|
|
25
|
+
config.include ManagedStyleRule
|
|
26
|
+
config.include ManagedTranslationMemory
|
|
24
27
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
uri1 = request1.uri
|
|
28
|
-
uri2 = request2.uri
|
|
29
|
-
uri1_match = uri1.match(deepl_api_regexp)
|
|
30
|
-
uri2_match = uri2.match(deepl_api_regexp)
|
|
31
|
-
if uri1_match && uri2_match
|
|
32
|
-
uri1_without_deepl_domain = uri1.gsub(uri1_match[0], '')
|
|
33
|
-
uri2_without_deepl_domain = uri2.gsub(uri2_match[0], '')
|
|
34
|
-
uri1_without_deepl_domain == uri2_without_deepl_domain
|
|
35
|
-
else
|
|
36
|
-
uri1 == uri2
|
|
28
|
+
config.before(:each, :mock_server_only) do
|
|
29
|
+
skip 'Only runs on mock server' unless ENV.key?('DEEPL_MOCK_SERVER_PORT')
|
|
37
30
|
end
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
headers_ignoring_user_agent = lambda do |request1, request2|
|
|
41
|
-
user_agent_key = 'User-Agent'
|
|
42
|
-
# Pass by reference, so we need to use a copy of the headers
|
|
43
|
-
headers1 = request1.headers.dup
|
|
44
|
-
headers2 = request2.headers.dup
|
|
45
|
-
headers1_has_user_agent = headers1.key?(user_agent_key)
|
|
46
|
-
headers2_has_user_agent = headers2.key?(user_agent_key)
|
|
47
|
-
return false if headers1_has_user_agent != headers2_has_user_agent
|
|
48
31
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
32
|
+
config.before(:each, :real_server_only) do
|
|
33
|
+
skip 'Only runs on real server' if ENV.key?('DEEPL_MOCK_SERVER_PORT')
|
|
34
|
+
end
|
|
52
35
|
end
|
|
53
36
|
|
|
54
|
-
#
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
config.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
|
|
58
|
-
config.hook_into :webmock
|
|
59
|
-
config.filter_sensitive_data('VALID_TOKEN') { ENV.fetch('DEEPL_AUTH_KEY', nil) }
|
|
60
|
-
|
|
61
|
-
# to record new or missing VCR cassettes, call rspec like this:
|
|
62
|
-
# $ VCR_RECORD_MODE=new_episodes bundle exec rspec
|
|
63
|
-
|
|
64
|
-
record_mode = ENV['VCR_RECORD_MODE'] ? ENV['VCR_RECORD_MODE'].to_sym : :none
|
|
65
|
-
config.default_cassette_options = {
|
|
66
|
-
record: record_mode,
|
|
67
|
-
match_requests_on: [:method, uri_ignoring_deepl_api_subdomain, :body,
|
|
68
|
-
headers_ignoring_user_agent]
|
|
69
|
-
}
|
|
37
|
+
# General helpers
|
|
38
|
+
def build_deepl_api
|
|
39
|
+
DeepL::API.new(DeepL::Configuration.new)
|
|
70
40
|
end
|
|
71
41
|
|
|
72
42
|
# Test helpers
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Copyright 2026 DeepL SE (https://www.deepl.com)
|
|
2
|
+
# Use of this source code is governed by an MIT
|
|
3
|
+
# license that can be found in the LICENSE file.
|
|
4
|
+
# frozen_string_literal: true
|
|
5
|
+
|
|
6
|
+
# Shared setup for integration specs that hit the live mock server: expose an
|
|
7
|
+
# API the server rejects as unauthorized without mutating global DeepL state.
|
|
8
|
+
RSpec.shared_context 'with a live mock server' do
|
|
9
|
+
let(:unauthorized_api) do
|
|
10
|
+
DeepL::API.new(DeepL::Configuration.new(auth_key: 'invalid'))
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Copyright 2025 DeepL SE (https://www.deepl.com)
|
|
2
|
+
# Use of this source code is governed by an MIT
|
|
3
|
+
# license that can be found in the LICENSE file.
|
|
4
|
+
# frozen_string_literal: true
|
|
5
|
+
|
|
6
|
+
module ManagedGlossary
|
|
7
|
+
def with_managed_glossary(name:, source_lang:, target_lang:, entries:, options: {})
|
|
8
|
+
glossary = DeepL.glossaries.create(name, source_lang, target_lang, entries, options)
|
|
9
|
+
yield glossary
|
|
10
|
+
ensure
|
|
11
|
+
begin
|
|
12
|
+
DeepL.glossaries.destroy(glossary.id) if glossary
|
|
13
|
+
rescue StandardError
|
|
14
|
+
nil
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Copyright 2025 DeepL SE (https://www.deepl.com)
|
|
2
|
+
# Use of this source code is governed by an MIT
|
|
3
|
+
# license that can be found in the LICENSE file.
|
|
4
|
+
# frozen_string_literal: true
|
|
5
|
+
|
|
6
|
+
module ManagedStyleRule
|
|
7
|
+
def with_managed_style_rule(name:, language:, options: {})
|
|
8
|
+
style_rule = DeepL.style_rules.create(name, language, options)
|
|
9
|
+
yield style_rule
|
|
10
|
+
ensure
|
|
11
|
+
begin
|
|
12
|
+
DeepL.style_rules.destroy(style_rule.style_id) if style_rule
|
|
13
|
+
rescue StandardError
|
|
14
|
+
nil
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: deepl-rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.
|
|
4
|
+
version: 3.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- DeepL SE
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
10
|
+
date: 2026-06-18 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: juwelier
|
|
@@ -132,25 +131,24 @@ files:
|
|
|
132
131
|
- spec/api/configuration_spec.rb
|
|
133
132
|
- spec/api/deepl_spec.rb
|
|
134
133
|
- spec/constants/constants_spec.rb
|
|
135
|
-
- spec/fixtures/vcr_cassettes/deepl_document.yml
|
|
136
|
-
- spec/fixtures/vcr_cassettes/deepl_document_download.yml
|
|
137
|
-
- spec/fixtures/vcr_cassettes/deepl_glossaries.yml
|
|
138
|
-
- spec/fixtures/vcr_cassettes/deepl_languages.yml
|
|
139
|
-
- spec/fixtures/vcr_cassettes/deepl_rephrase.yml
|
|
140
|
-
- spec/fixtures/vcr_cassettes/deepl_translate.yml
|
|
141
|
-
- spec/fixtures/vcr_cassettes/deepl_usage.yml
|
|
142
|
-
- spec/fixtures/vcr_cassettes/glossaries.yml
|
|
143
|
-
- spec/fixtures/vcr_cassettes/languages.yml
|
|
144
|
-
- spec/fixtures/vcr_cassettes/rephrase_texts.yml
|
|
145
|
-
- spec/fixtures/vcr_cassettes/style_rules.yml
|
|
146
|
-
- spec/fixtures/vcr_cassettes/style_rules_crud.yml
|
|
147
|
-
- spec/fixtures/vcr_cassettes/translate_texts.yml
|
|
148
|
-
- spec/fixtures/vcr_cassettes/translation_memories.yml
|
|
149
|
-
- spec/fixtures/vcr_cassettes/usage.yml
|
|
150
134
|
- spec/integration_tests/document_api_spec.rb
|
|
135
|
+
- spec/integration_tests/document_error_paths_spec.rb
|
|
136
|
+
- spec/integration_tests/glossary_api_spec.rb
|
|
137
|
+
- spec/integration_tests/glossary_error_paths_spec.rb
|
|
151
138
|
- spec/integration_tests/integration_test_utils.rb
|
|
139
|
+
- spec/integration_tests/languages_api_spec.rb
|
|
140
|
+
- spec/integration_tests/languages_error_paths_spec.rb
|
|
141
|
+
- spec/integration_tests/rephrase_api_spec.rb
|
|
142
|
+
- spec/integration_tests/rephrase_error_paths_spec.rb
|
|
143
|
+
- spec/integration_tests/smoke_test_spec.rb
|
|
152
144
|
- spec/integration_tests/style_rule_api_spec.rb
|
|
145
|
+
- spec/integration_tests/style_rule_error_paths_spec.rb
|
|
146
|
+
- spec/integration_tests/translate_api_spec.rb
|
|
147
|
+
- spec/integration_tests/translate_error_paths_spec.rb
|
|
153
148
|
- spec/integration_tests/translation_memory_api_spec.rb
|
|
149
|
+
- spec/integration_tests/translation_memory_error_paths_spec.rb
|
|
150
|
+
- spec/integration_tests/usage_api_spec.rb
|
|
151
|
+
- spec/integration_tests/usage_error_paths_spec.rb
|
|
154
152
|
- spec/requests/extra_body_parameters_types_spec.rb
|
|
155
153
|
- spec/requests/glossary/create_spec.rb
|
|
156
154
|
- spec/requests/glossary/destroy_spec.rb
|
|
@@ -173,13 +171,19 @@ files:
|
|
|
173
171
|
- spec/requests/translate_spec.rb
|
|
174
172
|
- spec/requests/translation_memory/list_spec.rb
|
|
175
173
|
- spec/requests/usage_spec.rb
|
|
174
|
+
- spec/resources/custom_instruction_spec.rb
|
|
176
175
|
- spec/resources/glossary_spec.rb
|
|
177
176
|
- spec/resources/language_pair_spec.rb
|
|
178
177
|
- spec/resources/language_spec.rb
|
|
178
|
+
- spec/resources/style_rule_spec.rb
|
|
179
179
|
- spec/resources/text_spec.rb
|
|
180
180
|
- spec/resources/translation_memory_spec.rb
|
|
181
181
|
- spec/resources/usage_spec.rb
|
|
182
182
|
- spec/spec_helper.rb
|
|
183
|
+
- spec/support/live_mock_server.rb
|
|
184
|
+
- spec/support/managed_glossary.rb
|
|
185
|
+
- spec/support/managed_style_rule.rb
|
|
186
|
+
- spec/support/managed_translation_memory.rb
|
|
183
187
|
homepage: https://github.com/DeepLcom/deepl-rb
|
|
184
188
|
licenses:
|
|
185
189
|
- MIT
|
|
@@ -188,7 +192,6 @@ metadata:
|
|
|
188
192
|
changelog_uri: https://github.com/DeepLcom/deepl-rb/blob/main/CHANGELOG.md
|
|
189
193
|
documentation_uri: https://github.com/DeepLcom/deepl-rb/blob/main/README.md
|
|
190
194
|
homepage_uri: https://github.com/DeepLcom/deepl-rb
|
|
191
|
-
post_install_message:
|
|
192
195
|
rdoc_options: []
|
|
193
196
|
require_paths:
|
|
194
197
|
- lib
|
|
@@ -203,8 +206,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
203
206
|
- !ruby/object:Gem::Version
|
|
204
207
|
version: '0'
|
|
205
208
|
requirements: []
|
|
206
|
-
rubygems_version: 3.
|
|
207
|
-
signing_key:
|
|
209
|
+
rubygems_version: 3.6.2
|
|
208
210
|
specification_version: 4
|
|
209
211
|
summary: Official Ruby library for the DeepL language translation API.
|
|
210
212
|
test_files: []
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
http_interactions:
|
|
3
|
-
- request:
|
|
4
|
-
method: post
|
|
5
|
-
uri: https://api.deepl.com/v2/document
|
|
6
|
-
body:
|
|
7
|
-
encoding: US-ASCII
|
|
8
|
-
string: ''
|
|
9
|
-
headers:
|
|
10
|
-
Authorization:
|
|
11
|
-
- DeepL-Auth-Key VALID_TOKEN
|
|
12
|
-
User-Agent:
|
|
13
|
-
- deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
|
|
14
|
-
Content-Type:
|
|
15
|
-
- multipart/form-data
|
|
16
|
-
Accept-Encoding:
|
|
17
|
-
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
18
|
-
Accept:
|
|
19
|
-
- "*/*"
|
|
20
|
-
Fake-Header:
|
|
21
|
-
- fake_value
|
|
22
|
-
response:
|
|
23
|
-
status:
|
|
24
|
-
code: 200
|
|
25
|
-
message: OK
|
|
26
|
-
headers:
|
|
27
|
-
Date:
|
|
28
|
-
- Tue, 09 Jul 2024 02:02:17 GMT
|
|
29
|
-
Content-Type:
|
|
30
|
-
- application/json; charset=utf-8
|
|
31
|
-
Transfer-Encoding:
|
|
32
|
-
- chunked
|
|
33
|
-
Vary:
|
|
34
|
-
- Accept-Encoding
|
|
35
|
-
Access-Control-Allow-Origin:
|
|
36
|
-
- "*"
|
|
37
|
-
X-Trace-Id:
|
|
38
|
-
- cdde031b7a5e48d7a8c4a5a2f1b9dc6e
|
|
39
|
-
Strict-Transport-Security:
|
|
40
|
-
- max-age=63072000; includeSubDomains; preload
|
|
41
|
-
Server-Timing:
|
|
42
|
-
- l7_lb_tls;dur=100, l7_lb_idle;dur=2, l7_lb_receive;dur=0, l7_lb_total;dur=192
|
|
43
|
-
Access-Control-Expose-Headers:
|
|
44
|
-
- Server-Timing, X-Trace-ID
|
|
45
|
-
body:
|
|
46
|
-
encoding: ASCII-8BIT
|
|
47
|
-
string: '{"document_id":"9B7CB9418DCDEBF2C4C519F65A32B99F","document_key":"EA637EA43BB3F8A52A2A25B76EF3E0C72CE9CD00C881148D1236CB584CB34815"}'
|
|
48
|
-
recorded_at: Tue, 09 Jul 2024 02:02:17 GMT
|
|
49
|
-
- request:
|
|
50
|
-
method: post
|
|
51
|
-
uri: https://api.deepl.com/v2/document/9B7CB9418DCDEBF2C4C519F65A32B99F
|
|
52
|
-
body:
|
|
53
|
-
encoding: UTF-8
|
|
54
|
-
string: '{"document_key":"EA637EA43BB3F8A52A2A25B76EF3E0C72CE9CD00C881148D1236CB584CB34815","param":"fake"}'
|
|
55
|
-
headers:
|
|
56
|
-
Authorization:
|
|
57
|
-
- DeepL-Auth-Key VALID_TOKEN
|
|
58
|
-
User-Agent:
|
|
59
|
-
- deepl-ruby/3.0.2 (darwin23) ruby/3.3.3
|
|
60
|
-
Content-Type:
|
|
61
|
-
- application/json
|
|
62
|
-
Accept-Encoding:
|
|
63
|
-
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
64
|
-
Accept:
|
|
65
|
-
- "*/*"
|
|
66
|
-
Fake-Header:
|
|
67
|
-
- fake_value
|
|
68
|
-
response:
|
|
69
|
-
status:
|
|
70
|
-
code: 200
|
|
71
|
-
message: OK
|
|
72
|
-
headers:
|
|
73
|
-
Date:
|
|
74
|
-
- Tue, 09 Jul 2024 02:03:49 GMT
|
|
75
|
-
Content-Type:
|
|
76
|
-
- application/json; charset=utf-8
|
|
77
|
-
Transfer-Encoding:
|
|
78
|
-
- chunked
|
|
79
|
-
Vary:
|
|
80
|
-
- Accept-Encoding
|
|
81
|
-
Access-Control-Allow-Origin:
|
|
82
|
-
- "*"
|
|
83
|
-
X-Trace-Id:
|
|
84
|
-
- 73fc4be8f3964b4080f89ee686c090be
|
|
85
|
-
Strict-Transport-Security:
|
|
86
|
-
- max-age=63072000; includeSubDomains; preload
|
|
87
|
-
Server-Timing:
|
|
88
|
-
- l7_lb_tls;dur=152, l7_lb_idle;dur=9, l7_lb_receive;dur=0, l7_lb_total;dur=166
|
|
89
|
-
Access-Control-Expose-Headers:
|
|
90
|
-
- Server-Timing, X-Trace-ID
|
|
91
|
-
body:
|
|
92
|
-
encoding: ASCII-8BIT
|
|
93
|
-
string: '{"document_id":"9B7CB9418DCDEBF2C4C519F65A32B99F","status":"done","billed_characters":256}'
|
|
94
|
-
recorded_at: Tue, 09 Jul 2024 02:03:49 GMT
|
|
95
|
-
recorded_with: VCR 6.2.0
|