deepl-rb 3.6.1 → 3.7.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 +5 -0
- data/CHANGELOG.md +19 -1
- data/README.md +153 -22
- data/Rakefile +2 -0
- data/VERSION +1 -1
- data/deepl-rb.gemspec +31 -4
- data/lib/deepl/requests/base.rb +16 -0
- data/lib/deepl/requests/document/upload.rb +6 -5
- data/lib/deepl/requests/style_rule/create.rb +46 -0
- data/lib/deepl/requests/style_rule/create_custom_instruction.rb +45 -0
- data/lib/deepl/requests/style_rule/destroy.rb +39 -0
- data/lib/deepl/requests/style_rule/destroy_custom_instruction.rb +40 -0
- data/lib/deepl/requests/style_rule/find.rb +40 -0
- data/lib/deepl/requests/style_rule/find_custom_instruction.rb +41 -0
- data/lib/deepl/requests/style_rule/update.rb +42 -0
- data/lib/deepl/requests/style_rule/update_configured_rules.rb +41 -0
- data/lib/deepl/requests/style_rule/update_custom_instruction.rb +47 -0
- data/lib/deepl/requests/translate.rb +15 -2
- data/lib/deepl/requests/translation_memory/list.rb +58 -0
- data/lib/deepl/resources/style_rule.rb +2 -1
- data/lib/deepl/resources/translation_memory.rb +25 -0
- data/lib/deepl/style_rule_api.rb +44 -0
- data/lib/deepl/translation_memory_api.rb +17 -0
- data/lib/deepl.rb +68 -51
- data/lib/version.rb +1 -1
- data/spec/fixtures/vcr_cassettes/style_rules_crud.yml +926 -0
- data/spec/fixtures/vcr_cassettes/translate_texts.yml +1 -1
- data/spec/fixtures/vcr_cassettes/translation_memories.yml +74 -0
- data/spec/integration_tests/style_rule_api_spec.rb +56 -0
- data/spec/integration_tests/translation_memory_api_spec.rb +70 -0
- data/spec/requests/style_rule/create_custom_instruction_spec.rb +54 -0
- data/spec/requests/style_rule/create_spec.rb +45 -0
- data/spec/requests/style_rule/destroy_custom_instruction_spec.rb +54 -0
- data/spec/requests/style_rule/destroy_spec.rb +54 -0
- data/spec/requests/style_rule/find_custom_instruction_spec.rb +56 -0
- data/spec/requests/style_rule/find_spec.rb +56 -0
- data/spec/requests/style_rule/list_spec.rb +58 -0
- data/spec/requests/style_rule/update_configured_rules_spec.rb +52 -0
- data/spec/requests/style_rule/update_custom_instruction_spec.rb +58 -0
- data/spec/requests/style_rule/update_spec.rb +48 -0
- data/spec/requests/translate_spec.rb +1 -2
- data/spec/requests/translation_memory/list_spec.rb +61 -0
- data/spec/resources/translation_memory_spec.rb +35 -0
- metadata +30 -3
|
@@ -0,0 +1,58 @@
|
|
|
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.md file.
|
|
4
|
+
# frozen_string_literal: true
|
|
5
|
+
|
|
6
|
+
require 'spec_helper'
|
|
7
|
+
|
|
8
|
+
describe DeepL::Requests::StyleRule::UpdateCustomInstruction do
|
|
9
|
+
subject(:update_instruction) do
|
|
10
|
+
described_class.new(api, style_id, instruction_id, label, prompt, nil, {})
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
around do |tests|
|
|
14
|
+
tmp_env = replace_env_preserving_deepl_vars_except_mock_server
|
|
15
|
+
tests.call
|
|
16
|
+
ENV.replace(tmp_env)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
let(:api) { build_deepl_api }
|
|
20
|
+
let(:style_id) { 'dca2e053-8ae5-45e6-a0d2-881156e7f4e4' }
|
|
21
|
+
let(:instruction_id) { 'test-instruction-id' }
|
|
22
|
+
let(:label) { 'Updated Label' }
|
|
23
|
+
let(:prompt) { 'Use casual language' }
|
|
24
|
+
|
|
25
|
+
describe '#initialize' do
|
|
26
|
+
context 'when building a request' do
|
|
27
|
+
it 'creates a request object' do
|
|
28
|
+
expect(update_instruction).to be_a(described_class)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
describe '#request' do
|
|
34
|
+
around do |example|
|
|
35
|
+
VCR.use_cassette('style_rules_crud') { example.call }
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
context 'when performing a valid request' do
|
|
39
|
+
subject(:update_instruction) do
|
|
40
|
+
described_class.new(api, new_rule.style_id, new_instruction.id, label, prompt)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
let(:new_rule) do
|
|
44
|
+
DeepL::Requests::StyleRule::Create.new(api, 'Update Instruction Test', 'en').request
|
|
45
|
+
end
|
|
46
|
+
let(:new_instruction) do
|
|
47
|
+
DeepL::Requests::StyleRule::CreateCustomInstruction.new(
|
|
48
|
+
api, new_rule.style_id, 'Original', 'Original prompt'
|
|
49
|
+
).request
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it 'returns a custom instruction object' do
|
|
53
|
+
instruction = update_instruction.request
|
|
54
|
+
expect(instruction).to be_a(DeepL::Resources::CustomInstruction)
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
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.md file.
|
|
4
|
+
# frozen_string_literal: true
|
|
5
|
+
|
|
6
|
+
require 'spec_helper'
|
|
7
|
+
|
|
8
|
+
describe DeepL::Requests::StyleRule::Update do
|
|
9
|
+
subject(:update) { described_class.new(api, style_id, name, options) }
|
|
10
|
+
|
|
11
|
+
around do |tests|
|
|
12
|
+
tmp_env = replace_env_preserving_deepl_vars_except_mock_server
|
|
13
|
+
tests.call
|
|
14
|
+
ENV.replace(tmp_env)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
let(:api) { build_deepl_api }
|
|
18
|
+
let(:style_id) { 'dca2e053-8ae5-45e6-a0d2-881156e7f4e4' }
|
|
19
|
+
let(:name) { 'Updated Name' }
|
|
20
|
+
let(:options) { {} }
|
|
21
|
+
|
|
22
|
+
describe '#initialize' do
|
|
23
|
+
context 'when building a request' do
|
|
24
|
+
it 'creates a request object' do
|
|
25
|
+
expect(update).to be_a(described_class)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe '#request' do
|
|
31
|
+
around do |example|
|
|
32
|
+
VCR.use_cassette('style_rules_crud') { example.call }
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
context 'when performing a valid request' do
|
|
36
|
+
subject(:update) { described_class.new(api, new_rule.style_id, 'Updated Name') }
|
|
37
|
+
|
|
38
|
+
let(:new_rule) do
|
|
39
|
+
DeepL::Requests::StyleRule::Create.new(api, 'Update Test', 'en').request
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'returns a style rule object' do
|
|
43
|
+
style_rule = update.request
|
|
44
|
+
expect(style_rule).to be_a(DeepL::Resources::StyleRule)
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -401,8 +401,7 @@ describe DeepL::Requests::Translate do
|
|
|
401
401
|
translate = described_class.new(api, text, source_lang, target_lang, options)
|
|
402
402
|
res = translate.request
|
|
403
403
|
expect(res).to be_a(DeepL::Resources::Text)
|
|
404
|
-
|
|
405
|
-
expect(res.model_type_used).to eq(expected_model_type)
|
|
404
|
+
expect(res.model_type_used).not_to be_nil
|
|
406
405
|
end
|
|
407
406
|
end
|
|
408
407
|
end
|
|
@@ -0,0 +1,61 @@
|
|
|
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.md file.
|
|
4
|
+
# frozen_string_literal: true
|
|
5
|
+
|
|
6
|
+
require 'spec_helper'
|
|
7
|
+
|
|
8
|
+
describe DeepL::Requests::TranslationMemory::List do
|
|
9
|
+
subject(:translation_memory_list) { described_class.new(api, options) }
|
|
10
|
+
|
|
11
|
+
around do |tests|
|
|
12
|
+
tmp_env = replace_env_preserving_deepl_vars_except_mock_server
|
|
13
|
+
tests.call
|
|
14
|
+
ENV.replace(tmp_env)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
let(:api) { build_deepl_api }
|
|
18
|
+
let(:options) { {} }
|
|
19
|
+
|
|
20
|
+
describe '#initialize' do
|
|
21
|
+
context 'when building a request' do
|
|
22
|
+
it 'creates a request object' do
|
|
23
|
+
expect(translation_memory_list).to be_a(described_class)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
describe '#request' do
|
|
29
|
+
around do |example|
|
|
30
|
+
VCR.use_cassette('translation_memories') { example.call }
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
context 'when requesting a list of all translation memories' do
|
|
34
|
+
it 'returns an array of translation memories' do
|
|
35
|
+
translation_memories = translation_memory_list.request
|
|
36
|
+
expect(translation_memories).to be_an(Array)
|
|
37
|
+
expect(translation_memories).not_to be_empty
|
|
38
|
+
expect(translation_memories.first).to be_a(DeepL::Resources::TranslationMemory)
|
|
39
|
+
expect(translation_memories.first.translation_memory_id).to be_a(String)
|
|
40
|
+
expect(translation_memories.first.name).to be_a(String)
|
|
41
|
+
expect(translation_memories.first.source_language).to be_a(String)
|
|
42
|
+
expect(translation_memories.first.target_languages).to be_an(Array)
|
|
43
|
+
expect(translation_memories.first.segment_count).to be_an(Integer)
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
context 'when performing a bad request' do
|
|
48
|
+
context 'when using an invalid token' do
|
|
49
|
+
let(:api) do
|
|
50
|
+
api = build_deepl_api
|
|
51
|
+
api.configuration.auth_key = 'invalid'
|
|
52
|
+
api
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it 'raises an authorization failed error' do
|
|
56
|
+
expect { translation_memory_list.request }.to raise_error(DeepL::Exceptions::AuthorizationFailed)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
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.md file.
|
|
4
|
+
# frozen_string_literal: true
|
|
5
|
+
|
|
6
|
+
require 'spec_helper'
|
|
7
|
+
|
|
8
|
+
describe DeepL::Resources::TranslationMemory do
|
|
9
|
+
subject(:translation_memory) do
|
|
10
|
+
described_class.new({
|
|
11
|
+
'translation_memory_id' => 'a74d88fb-ed2a-4943-a664-a4512398b994',
|
|
12
|
+
'name' => 'Legal',
|
|
13
|
+
'source_language' => 'en',
|
|
14
|
+
'target_languages' => %w[es de],
|
|
15
|
+
'segment_count' => 3542
|
|
16
|
+
}, nil, nil)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
describe '#initialize' do
|
|
20
|
+
context 'when building a basic object' do
|
|
21
|
+
it 'creates a resource' do
|
|
22
|
+
expect(translation_memory).to be_a(described_class)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it 'assigns the attributes' do
|
|
26
|
+
expect(translation_memory.translation_memory_id)
|
|
27
|
+
.to eq('a74d88fb-ed2a-4943-a664-a4512398b994')
|
|
28
|
+
expect(translation_memory.name).to eq('Legal')
|
|
29
|
+
expect(translation_memory.source_language).to eq('en')
|
|
30
|
+
expect(translation_memory.target_languages).to eq(%w[es de])
|
|
31
|
+
expect(translation_memory.segment_count).to eq(3542)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
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: 3.
|
|
4
|
+
version: 3.7.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- DeepL SE
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-05-14 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: juwelier
|
|
@@ -98,8 +98,18 @@ files:
|
|
|
98
98
|
- lib/deepl/requests/glossary/list.rb
|
|
99
99
|
- lib/deepl/requests/languages.rb
|
|
100
100
|
- lib/deepl/requests/rephrase.rb
|
|
101
|
+
- lib/deepl/requests/style_rule/create.rb
|
|
102
|
+
- lib/deepl/requests/style_rule/create_custom_instruction.rb
|
|
103
|
+
- lib/deepl/requests/style_rule/destroy.rb
|
|
104
|
+
- lib/deepl/requests/style_rule/destroy_custom_instruction.rb
|
|
105
|
+
- lib/deepl/requests/style_rule/find.rb
|
|
106
|
+
- lib/deepl/requests/style_rule/find_custom_instruction.rb
|
|
101
107
|
- lib/deepl/requests/style_rule/list.rb
|
|
108
|
+
- lib/deepl/requests/style_rule/update.rb
|
|
109
|
+
- lib/deepl/requests/style_rule/update_configured_rules.rb
|
|
110
|
+
- lib/deepl/requests/style_rule/update_custom_instruction.rb
|
|
102
111
|
- lib/deepl/requests/translate.rb
|
|
112
|
+
- lib/deepl/requests/translation_memory/list.rb
|
|
103
113
|
- lib/deepl/requests/usage.rb
|
|
104
114
|
- lib/deepl/resources/base.rb
|
|
105
115
|
- lib/deepl/resources/document_handle.rb
|
|
@@ -109,8 +119,10 @@ files:
|
|
|
109
119
|
- lib/deepl/resources/language_pair.rb
|
|
110
120
|
- lib/deepl/resources/style_rule.rb
|
|
111
121
|
- lib/deepl/resources/text.rb
|
|
122
|
+
- lib/deepl/resources/translation_memory.rb
|
|
112
123
|
- lib/deepl/resources/usage.rb
|
|
113
124
|
- lib/deepl/style_rule_api.rb
|
|
125
|
+
- lib/deepl/translation_memory_api.rb
|
|
114
126
|
- lib/deepl/utils/backoff_timer.rb
|
|
115
127
|
- lib/deepl/utils/exception_builder.rb
|
|
116
128
|
- lib/http_client_options.rb
|
|
@@ -131,11 +143,14 @@ files:
|
|
|
131
143
|
- spec/fixtures/vcr_cassettes/languages.yml
|
|
132
144
|
- spec/fixtures/vcr_cassettes/rephrase_texts.yml
|
|
133
145
|
- spec/fixtures/vcr_cassettes/style_rules.yml
|
|
146
|
+
- spec/fixtures/vcr_cassettes/style_rules_crud.yml
|
|
134
147
|
- spec/fixtures/vcr_cassettes/translate_texts.yml
|
|
148
|
+
- spec/fixtures/vcr_cassettes/translation_memories.yml
|
|
135
149
|
- spec/fixtures/vcr_cassettes/usage.yml
|
|
136
150
|
- spec/integration_tests/document_api_spec.rb
|
|
137
151
|
- spec/integration_tests/integration_test_utils.rb
|
|
138
152
|
- spec/integration_tests/style_rule_api_spec.rb
|
|
153
|
+
- spec/integration_tests/translation_memory_api_spec.rb
|
|
139
154
|
- spec/requests/extra_body_parameters_types_spec.rb
|
|
140
155
|
- spec/requests/glossary/create_spec.rb
|
|
141
156
|
- spec/requests/glossary/destroy_spec.rb
|
|
@@ -145,12 +160,24 @@ files:
|
|
|
145
160
|
- spec/requests/glossary/list_spec.rb
|
|
146
161
|
- spec/requests/languages_spec.rb
|
|
147
162
|
- spec/requests/rephrase_spec.rb
|
|
163
|
+
- spec/requests/style_rule/create_custom_instruction_spec.rb
|
|
164
|
+
- spec/requests/style_rule/create_spec.rb
|
|
165
|
+
- spec/requests/style_rule/destroy_custom_instruction_spec.rb
|
|
166
|
+
- spec/requests/style_rule/destroy_spec.rb
|
|
167
|
+
- spec/requests/style_rule/find_custom_instruction_spec.rb
|
|
168
|
+
- spec/requests/style_rule/find_spec.rb
|
|
169
|
+
- spec/requests/style_rule/list_spec.rb
|
|
170
|
+
- spec/requests/style_rule/update_configured_rules_spec.rb
|
|
171
|
+
- spec/requests/style_rule/update_custom_instruction_spec.rb
|
|
172
|
+
- spec/requests/style_rule/update_spec.rb
|
|
148
173
|
- spec/requests/translate_spec.rb
|
|
174
|
+
- spec/requests/translation_memory/list_spec.rb
|
|
149
175
|
- spec/requests/usage_spec.rb
|
|
150
176
|
- spec/resources/glossary_spec.rb
|
|
151
177
|
- spec/resources/language_pair_spec.rb
|
|
152
178
|
- spec/resources/language_spec.rb
|
|
153
179
|
- spec/resources/text_spec.rb
|
|
180
|
+
- spec/resources/translation_memory_spec.rb
|
|
154
181
|
- spec/resources/usage_spec.rb
|
|
155
182
|
- spec/spec_helper.rb
|
|
156
183
|
homepage: https://github.com/DeepLcom/deepl-rb
|
|
@@ -176,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
176
203
|
- !ruby/object:Gem::Version
|
|
177
204
|
version: '0'
|
|
178
205
|
requirements: []
|
|
179
|
-
rubygems_version: 3.4.
|
|
206
|
+
rubygems_version: 3.4.10
|
|
180
207
|
signing_key:
|
|
181
208
|
specification_version: 4
|
|
182
209
|
summary: Official Ruby library for the DeepL language translation API.
|