deepl-rb 3.2.0 → 3.4.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.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +46 -27
  3. data/README.md +71 -0
  4. metadata +3 -95
  5. data/.circleci/config.yml +0 -27
  6. data/.github/workflows/add_issues_to_kanban.yml +0 -16
  7. data/.gitlab-ci.yml +0 -135
  8. data/.rubocop.yml +0 -51
  9. data/CODE_OF_CONDUCT.md +0 -132
  10. data/CONTRIBUTING.md +0 -37
  11. data/Gemfile +0 -24
  12. data/Rakefile +0 -53
  13. data/SECURITY.md +0 -58
  14. data/VERSION +0 -1
  15. data/deepl-rb.gemspec +0 -132
  16. data/lib/deepl/api.rb +0 -22
  17. data/lib/deepl/configuration.rb +0 -59
  18. data/lib/deepl/constants/base_constant.rb +0 -18
  19. data/lib/deepl/constants/formality.rb +0 -16
  20. data/lib/deepl/constants/model_type.rb +0 -14
  21. data/lib/deepl/constants/split_sentences.rb +0 -14
  22. data/lib/deepl/constants/tag_handling.rb +0 -13
  23. data/lib/deepl/constants/tone.rb +0 -20
  24. data/lib/deepl/constants/writing_style.rb +0 -20
  25. data/lib/deepl/document_api.rb +0 -121
  26. data/lib/deepl/exceptions/authorization_failed.rb +0 -14
  27. data/lib/deepl/exceptions/bad_request.rb +0 -16
  28. data/lib/deepl/exceptions/document_translation_error.rb +0 -15
  29. data/lib/deepl/exceptions/error.rb +0 -14
  30. data/lib/deepl/exceptions/limit_exceeded.rb +0 -18
  31. data/lib/deepl/exceptions/not_found.rb +0 -16
  32. data/lib/deepl/exceptions/not_supported.rb +0 -14
  33. data/lib/deepl/exceptions/quota_exceeded.rb +0 -14
  34. data/lib/deepl/exceptions/request_entity_too_large.rb +0 -15
  35. data/lib/deepl/exceptions/request_error.rb +0 -21
  36. data/lib/deepl/exceptions/server_error.rb +0 -18
  37. data/lib/deepl/glossary_api.rb +0 -38
  38. data/lib/deepl/requests/base.rb +0 -163
  39. data/lib/deepl/requests/document/download.rb +0 -44
  40. data/lib/deepl/requests/document/get_status.rb +0 -44
  41. data/lib/deepl/requests/document/upload.rb +0 -64
  42. data/lib/deepl/requests/glossary/create.rb +0 -59
  43. data/lib/deepl/requests/glossary/destroy.rb +0 -37
  44. data/lib/deepl/requests/glossary/entries.rb +0 -37
  45. data/lib/deepl/requests/glossary/find.rb +0 -38
  46. data/lib/deepl/requests/glossary/language_pairs.rb +0 -38
  47. data/lib/deepl/requests/glossary/list.rb +0 -37
  48. data/lib/deepl/requests/languages.rb +0 -37
  49. data/lib/deepl/requests/rephrase.rb +0 -54
  50. data/lib/deepl/requests/translate.rb +0 -82
  51. data/lib/deepl/requests/usage.rb +0 -33
  52. data/lib/deepl/resources/base.rb +0 -17
  53. data/lib/deepl/resources/document_handle.rb +0 -57
  54. data/lib/deepl/resources/document_translation_status.rb +0 -54
  55. data/lib/deepl/resources/glossary.rb +0 -28
  56. data/lib/deepl/resources/language.rb +0 -30
  57. data/lib/deepl/resources/language_pair.rb +0 -23
  58. data/lib/deepl/resources/text.rb +0 -24
  59. data/lib/deepl/resources/usage.rb +0 -27
  60. data/lib/deepl/utils/backoff_timer.rb +0 -46
  61. data/lib/deepl/utils/exception_builder.rb +0 -34
  62. data/lib/deepl.rb +0 -142
  63. data/lib/http_client_options.rb +0 -22
  64. data/spec/api/api_spec.rb +0 -20
  65. data/spec/api/configuration_spec.rb +0 -122
  66. data/spec/api/deepl_spec.rb +0 -431
  67. data/spec/constants/constants_spec.rb +0 -158
  68. data/spec/fixtures/vcr_cassettes/deepl_document.yml +0 -95
  69. data/spec/fixtures/vcr_cassettes/deepl_document_download.yml +0 -1214
  70. data/spec/fixtures/vcr_cassettes/deepl_glossaries.yml +0 -1163
  71. data/spec/fixtures/vcr_cassettes/deepl_languages.yml +0 -54
  72. data/spec/fixtures/vcr_cassettes/deepl_translate.yml +0 -358
  73. data/spec/fixtures/vcr_cassettes/deepl_usage.yml +0 -129
  74. data/spec/fixtures/vcr_cassettes/glossaries.yml +0 -1702
  75. data/spec/fixtures/vcr_cassettes/languages.yml +0 -229
  76. data/spec/fixtures/vcr_cassettes/rephrase_texts.yml +0 -401
  77. data/spec/fixtures/vcr_cassettes/translate_texts.yml +0 -10372
  78. data/spec/fixtures/vcr_cassettes/usage.yml +0 -171
  79. data/spec/integration_tests/document_api_spec.rb +0 -155
  80. data/spec/integration_tests/integration_test_utils.rb +0 -170
  81. data/spec/requests/glossary/create_spec.rb +0 -65
  82. data/spec/requests/glossary/destroy_spec.rb +0 -66
  83. data/spec/requests/glossary/entries_spec.rb +0 -62
  84. data/spec/requests/glossary/find_spec.rb +0 -68
  85. data/spec/requests/glossary/language_pairs_spec.rb +0 -40
  86. data/spec/requests/glossary/list_spec.rb +0 -54
  87. data/spec/requests/languages_spec.rb +0 -68
  88. data/spec/requests/rephrase_spec.rb +0 -172
  89. data/spec/requests/translate_spec.rb +0 -410
  90. data/spec/requests/usage_spec.rb +0 -43
  91. data/spec/resources/glossary_spec.rb +0 -38
  92. data/spec/resources/language_pair_spec.rb +0 -23
  93. data/spec/resources/language_spec.rb +0 -45
  94. data/spec/resources/text_spec.rb +0 -23
  95. data/spec/resources/usage_spec.rb +0 -35
  96. data/spec/spec_helper.rb +0 -92
@@ -1,59 +0,0 @@
1
- # Copyright 2022 Daniel Herzog
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
- module DeepL
7
- module Requests
8
- module Glossary
9
- class Create < Base
10
- attr_reader :name, :source_lang, :target_lang, :entries, :entries_format
11
-
12
- def initialize(api, name, source_lang, target_lang, entries, options = {})
13
- super(api, options)
14
- @name = name
15
- @source_lang = source_lang
16
- @target_lang = target_lang
17
- @entries = entries
18
- @entries_format = delete_option(:entries_format) || 'tsv'
19
- end
20
-
21
- def request
22
- payload = {
23
- name: name, source_lang: source_lang, target_lang: target_lang, entries: entries_to_tsv,
24
- entries_format: entries_format
25
- }
26
- build_glossary(*execute_request_with_retries(post_request(payload)))
27
- end
28
-
29
- def details
30
- "HTTP Headers: #{headers}\nPayload #{{
31
- name: name, source_lang: source_lang, target_lang: target_lang, entries: entries_to_tsv,
32
- entries_format: entries_format
33
- }}"
34
- end
35
-
36
- def to_s
37
- "POST #{uri.request_uri}"
38
- end
39
-
40
- private
41
-
42
- def entries_to_tsv
43
- return entries if entries.is_a?(String)
44
-
45
- entries.reduce('') { |tsv, entry| "#{tsv}#{entry.first}\t#{entry.last}\n" }
46
- end
47
-
48
- def build_glossary(request, response)
49
- glossary = JSON.parse(response.body)
50
- Resources::Glossary.new(glossary, request, response)
51
- end
52
-
53
- def path
54
- 'glossaries'
55
- end
56
- end
57
- end
58
- end
59
- end
@@ -1,37 +0,0 @@
1
- # Copyright 2022 Daniel Herzog
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
- module DeepL
7
- module Requests
8
- module Glossary
9
- class Destroy < Base
10
- attr_reader :id
11
-
12
- def initialize(api, id, options = {})
13
- super(api, options)
14
- @id = id
15
- end
16
-
17
- def request
18
- build_response(*execute_request_with_retries(delete_request))
19
- end
20
-
21
- def to_s
22
- "DELETE #{uri.request_uri}"
23
- end
24
-
25
- private
26
-
27
- def build_response(_, _)
28
- id
29
- end
30
-
31
- def path
32
- "glossaries/#{id}"
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,37 +0,0 @@
1
- # Copyright 2022 Daniel Herzog
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
- module DeepL
7
- module Requests
8
- module Glossary
9
- class Entries < Base
10
- attr_reader :id
11
-
12
- def initialize(api, id, options = {})
13
- super(api, options)
14
- @id = id
15
- end
16
-
17
- def request
18
- build_entries(*execute_request_with_retries(get_request))
19
- end
20
-
21
- def to_s
22
- "GET #{uri.request_uri}"
23
- end
24
-
25
- private
26
-
27
- def build_entries(_, response)
28
- response.body.split("\n").map { |entry| entry.split("\t") }
29
- end
30
-
31
- def path
32
- "glossaries/#{id}/entries"
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,38 +0,0 @@
1
- # Copyright 2022 Daniel Herzog
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
- module DeepL
7
- module Requests
8
- module Glossary
9
- class Find < Base
10
- attr_reader :id
11
-
12
- def initialize(api, id, options = {})
13
- super(api, options)
14
- @id = id
15
- end
16
-
17
- def request
18
- build_glossary(*execute_request_with_retries(get_request))
19
- end
20
-
21
- def to_s
22
- "GET #{uri.request_uri}"
23
- end
24
-
25
- private
26
-
27
- def build_glossary(request, response)
28
- glossary = JSON.parse(response.body)
29
- Resources::Glossary.new(glossary, request, response)
30
- end
31
-
32
- def path
33
- "glossaries/#{id}"
34
- end
35
- end
36
- end
37
- end
38
- end
@@ -1,38 +0,0 @@
1
- # Copyright 2022 Daniel Herzog
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
- module DeepL
7
- module Requests
8
- module Glossary
9
- class LanguagePairs < Base
10
- def initialize(api, options = {})
11
- super
12
- end
13
-
14
- def request
15
- build_language_pair_list(*execute_request_with_retries(get_request))
16
- end
17
-
18
- def to_s
19
- "GET #{uri.request_uri}"
20
- end
21
-
22
- private
23
-
24
- def build_language_pair_list(request, response)
25
- data = JSON.parse(response.body)
26
- data['supported_languages'].map do |language_pair|
27
- Resources::LanguagePair.new(language_pair['source_lang'], language_pair['target_lang'],
28
- request, response)
29
- end
30
- end
31
-
32
- def path
33
- 'glossary-language-pairs'
34
- end
35
- end
36
- end
37
- end
38
- end
@@ -1,37 +0,0 @@
1
- # Copyright 2022 Daniel Herzog
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
- module DeepL
7
- module Requests
8
- module Glossary
9
- class List < Base
10
- def initialize(api, options = {})
11
- super
12
- end
13
-
14
- def request
15
- build_glossary_list(*execute_request_with_retries(get_request))
16
- end
17
-
18
- def to_s
19
- "GET #{uri.request_uri}"
20
- end
21
-
22
- private
23
-
24
- def build_glossary_list(request, response)
25
- data = JSON.parse(response.body)
26
- data['glossaries'].map do |glossary|
27
- Resources::Glossary.new(glossary, request, response)
28
- end
29
- end
30
-
31
- def path
32
- 'glossaries'
33
- end
34
- end
35
- end
36
- end
37
- end
@@ -1,37 +0,0 @@
1
- # Copyright 2021 Daniel Herzog
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
- module DeepL
7
- module Requests
8
- class Languages < Base
9
- def initialize(api, options = {})
10
- super
11
- end
12
-
13
- def request
14
- build_languages(*execute_request_with_retries(get_request))
15
- end
16
-
17
- def to_s
18
- "GET #{uri.request_uri}"
19
- end
20
-
21
- private
22
-
23
- def build_languages(request, response)
24
- data = JSON.parse(response.body)
25
- data.map do |language|
26
- Resources::Language.new(language['language'], language['name'],
27
- language['supports_formality'],
28
- request, response)
29
- end
30
- end
31
-
32
- def path
33
- 'languages'
34
- end
35
- end
36
- end
37
- end
@@ -1,54 +0,0 @@
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.md file.
4
- # frozen_string_literal: true
5
-
6
- module DeepL
7
- module Requests
8
- class Rephrase < Base
9
- attr_reader :text, :target_lang, :writing_style, :tone
10
-
11
- def initialize(api, text, target_lang, writing_style = nil, tone = nil, options = {})
12
- super(api, options)
13
- @text = text
14
- @target_lang = target_lang
15
- @writing_style = writing_style
16
- @tone = tone
17
- end
18
-
19
- def request
20
- text_arrayified = text.is_a?(Array) ? text : [text]
21
- payload = { text: text_arrayified, target_lang: target_lang }
22
- payload[:writing_style] = writing_style unless writing_style.nil?
23
- payload[:tone] = tone unless tone.nil?
24
- build_texts(*execute_request_with_retries(post_request(payload)))
25
- end
26
-
27
- def details
28
- "HTTP Headers: #{headers}\nPayload #{{ text: text, target_lang: target_lang,
29
- writing_style: writing_style, tone: tone }}"
30
- end
31
-
32
- def to_s
33
- "POST #{uri.request_uri}"
34
- end
35
-
36
- private
37
-
38
- def build_texts(request, response)
39
- data = JSON.parse(response.body)
40
-
41
- texts = data['improvements'].map do |improvement|
42
- Resources::Text.new(improvement['text'], improvement['detected_source_language'], nil,
43
- request, response)
44
- end
45
-
46
- texts.size == 1 ? texts.first : texts
47
- end
48
-
49
- def path
50
- 'write/rephrase'
51
- end
52
- end
53
- end
54
- end
@@ -1,82 +0,0 @@
1
- # Copyright 2018 Daniel Herzog
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
- module DeepL
7
- module Requests
8
- class Translate < Base
9
- STRING_TO_BOOLEAN_MAP = { '1' => true, '0' => false }.freeze
10
- BOOLEAN_TO_STRING_MAP = { true => '1', false => '0' }.freeze
11
- STRING_TO_BOOLEAN_CONVERSION = ->(value) { STRING_TO_BOOLEAN_MAP[value] }
12
- BOOLEAN_TO_STRING_CONVERSION = ->(value) { BOOLEAN_TO_STRING_MAP[value] }
13
- STRING_TO_ARRAY_CONVERSION = lambda { |value|
14
- if value.nil?
15
- nil
16
- else
17
- (value.is_a?(Array) ? value : value.split(','))
18
- end
19
- }.freeze
20
- OPTIONS_CONVERSIONS = {
21
- split_sentences: BOOLEAN_TO_STRING_CONVERSION,
22
- preserve_formatting: STRING_TO_BOOLEAN_CONVERSION,
23
- outline_detection: STRING_TO_BOOLEAN_CONVERSION,
24
- splitting_tags: STRING_TO_ARRAY_CONVERSION,
25
- non_splitting_tags: STRING_TO_ARRAY_CONVERSION,
26
- ignore_tags: STRING_TO_ARRAY_CONVERSION
27
- }.freeze
28
-
29
- attr_reader :text, :source_lang, :target_lang, :ignore_tags, :splitting_tags,
30
- :non_splitting_tags, :model_type
31
-
32
- def initialize(api, text, source_lang, target_lang, options = {})
33
- super(api, options)
34
- @text = text
35
- @source_lang = source_lang
36
- @target_lang = target_lang
37
-
38
- tweak_parameters!
39
- end
40
-
41
- def request
42
- text_arrayified = text.is_a?(Array) ? text : [text]
43
- payload = { text: text_arrayified, source_lang: source_lang, target_lang: target_lang }
44
- build_texts(*execute_request_with_retries(post_request(payload)))
45
- end
46
-
47
- def details
48
- "HTTP Headers: #{headers}\nPayload #{{ text: text, source_lang: source_lang,
49
- target_lang: target_lang }}"
50
- end
51
-
52
- def to_s
53
- "POST #{uri.request_uri}"
54
- end
55
-
56
- private
57
-
58
- def tweak_parameters!
59
- OPTIONS_CONVERSIONS.each do |param, converter|
60
- next unless option?(param) && !converter[option(param)].nil?
61
-
62
- set_option(param, converter[option(param)])
63
- end
64
- end
65
-
66
- def build_texts(request, response)
67
- data = JSON.parse(response.body)
68
-
69
- texts = data['translations'].map do |translation|
70
- Resources::Text.new(translation['text'], translation['detected_source_language'],
71
- translation['model_type_used'], request, response)
72
- end
73
-
74
- texts.size == 1 ? texts.first : texts
75
- end
76
-
77
- def path
78
- 'translate'
79
- end
80
- end
81
- end
82
- end
@@ -1,33 +0,0 @@
1
- # Copyright 2018 Daniel Herzog
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
- module DeepL
7
- module Requests
8
- class Usage < Base
9
- def initialize(api, options = {})
10
- super
11
- end
12
-
13
- def request
14
- build_usage(*execute_request_with_retries(get_request))
15
- end
16
-
17
- def to_s
18
- "GET #{uri.request_uri}"
19
- end
20
-
21
- private
22
-
23
- def build_usage(request, response)
24
- data = JSON.parse(response.body)
25
- Resources::Usage.new(data['character_count'], data['character_limit'], request, response)
26
- end
27
-
28
- def path
29
- 'usage'
30
- end
31
- end
32
- end
33
- end
@@ -1,17 +0,0 @@
1
- # Copyright 2018 Daniel Herzog
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
- module DeepL
7
- module Resources
8
- class Base
9
- attr_reader :request, :response
10
-
11
- def initialize(request, response)
12
- @request = request
13
- @response = response
14
- end
15
- end
16
- end
17
- end
@@ -1,57 +0,0 @@
1
- # Copyright 2024 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 DeepL
7
- module Resources
8
- class DocumentHandle < Base
9
- attr_reader :document_id, :document_key
10
-
11
- def initialize(document_id, document_key, *args)
12
- super(*args)
13
-
14
- @document_id = document_id
15
- @document_key = document_key
16
- end
17
-
18
- def to_s
19
- "DocumentHandle: ID: #{document_id} - Key: #{document_key}"
20
- end
21
-
22
- ##
23
- # For this DocumentHandle, waits until the document translation is finished and returns the
24
- # final status of the document.
25
- #
26
- # @return [DeepL::Resources::DocumentTranslationStatus] Final status of the document
27
- # translation.
28
-
29
- def wait_until_document_translation_finished
30
- doc_status = nil
31
- max_tries = max_doc_status_queries
32
- num_tries = 0
33
- loop do
34
- num_tries += 1
35
- sleep(calculate_waiting_time(doc_status)) unless doc_status.nil?
36
- doc_status = DeepL.document.get_status(self)
37
- break if doc_status.finished? || num_tries > max_tries
38
- end
39
- doc_status
40
- end
41
-
42
- private
43
-
44
- def calculate_waiting_time(_resp)
45
- # ignore _resp.seconds_remaining for now, while it is unreliable
46
- 5
47
- end
48
-
49
- def max_doc_status_queries
50
- configured_value = DeepL.configuration.max_doc_status_queries
51
- return configured_value unless configured_value.nil?
52
-
53
- 10
54
- end
55
- end
56
- end
57
- end
@@ -1,54 +0,0 @@
1
- # Copyright 2024 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 DeepL
7
- module Resources
8
- class DocumentTranslationStatus < Base
9
- attr_reader :document_id, :status, :seconds_remaining, :billed_characters, :error_message
10
-
11
- def initialize(response, *args)
12
- super(*args)
13
-
14
- @document_id = response['document_id']
15
- @status = response['status']
16
- @seconds_remaining = response['seconds_remaining']
17
- @billed_characters = response['billed_characters']
18
- @error_message = response['error_message']
19
- end
20
-
21
- def to_s
22
- "DocumentTranslationStatus: ID: #{document_id} - Status: #{status} " \
23
- "- Error message: #{error_message}"
24
- end
25
-
26
- ##
27
- # Checks if the translation finished successfully
28
- #
29
- # @return [true] if so
30
-
31
- def successful?
32
- status == 'done'
33
- end
34
-
35
- ##
36
- # Checks if there was an error during translation
37
- #
38
- # @return [true] if so
39
-
40
- def error?
41
- status == 'error'
42
- end
43
-
44
- ##
45
- # Checks if the translation process terminated. Note that this could be due to an error as
46
- # well, but means no further waiting is necessary.
47
- #
48
- # @return [true] if so
49
- def finished?
50
- successful? || error?
51
- end
52
- end
53
- end
54
- end
@@ -1,28 +0,0 @@
1
- # Copyright 2022 Daniel Herzog
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
- module DeepL
7
- module Resources
8
- class Glossary < Base
9
- attr_reader :id, :name, :ready, :source_lang, :target_lang, :creation_time, :entry_count
10
-
11
- def initialize(glossary, *args)
12
- super(*args)
13
-
14
- @id = glossary['glossary_id']
15
- @name = glossary['name']
16
- @ready = glossary['ready']
17
- @source_lang = glossary['source_lang']
18
- @target_lang = glossary['target_lang']
19
- @creation_time = glossary['creation_time']
20
- @entry_count = glossary['entry_count']
21
- end
22
-
23
- def to_s
24
- "#{id} - #{name}"
25
- end
26
- end
27
- end
28
- end
@@ -1,30 +0,0 @@
1
- # Copyright 2021 Daniel Herzog
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
- module DeepL
7
- module Resources
8
- class Language < Base
9
- attr_reader :code, :name
10
-
11
- def initialize(code, name, supports_formality, *args)
12
- super(*args)
13
-
14
- @code = code
15
- @name = name
16
- @supports_formality = supports_formality
17
- end
18
-
19
- def to_s
20
- "#{code} - #{name}"
21
- end
22
-
23
- def supports_formality?
24
- return @supports_formality unless @supports_formality.nil?
25
-
26
- raise Exceptions::NotSupported, 'Support formality is only available on target languages'
27
- end
28
- end
29
- end
30
- end
@@ -1,23 +0,0 @@
1
- # Copyright 2022 Daniel Herzog
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
- module DeepL
7
- module Resources
8
- class LanguagePair < Base
9
- attr_reader :source_lang, :target_lang
10
-
11
- def initialize(source_lang, target_lang, *args)
12
- super(*args)
13
-
14
- @source_lang = source_lang
15
- @target_lang = target_lang
16
- end
17
-
18
- def to_s
19
- "#{source_lang} - #{target_lang}"
20
- end
21
- end
22
- end
23
- end
@@ -1,24 +0,0 @@
1
- # Copyright 2018 Daniel Herzog
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
- module DeepL
7
- module Resources
8
- class Text < Base
9
- attr_reader :text, :detected_source_language, :model_type_used
10
-
11
- def initialize(text, detected_source_language, model_type_used, *args)
12
- super(*args)
13
-
14
- @text = text
15
- @detected_source_language = detected_source_language
16
- @model_type_used = model_type_used
17
- end
18
-
19
- def to_s
20
- text
21
- end
22
- end
23
- end
24
- end