deepl-rb 3.3.0 → 3.5.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 (97) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -2
  3. data/README.md +72 -0
  4. metadata +2 -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 -172
  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 -54
  13. data/SECURITY.md +0 -58
  14. data/VERSION +0 -1
  15. data/deepl-rb.gemspec +0 -133
  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 -196
  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 -74
  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 -55
  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 -147
  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 -460
  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_rephrase.yml +0 -87
  73. data/spec/fixtures/vcr_cassettes/deepl_translate.yml +0 -358
  74. data/spec/fixtures/vcr_cassettes/deepl_usage.yml +0 -129
  75. data/spec/fixtures/vcr_cassettes/glossaries.yml +0 -1702
  76. data/spec/fixtures/vcr_cassettes/languages.yml +0 -229
  77. data/spec/fixtures/vcr_cassettes/rephrase_texts.yml +0 -401
  78. data/spec/fixtures/vcr_cassettes/translate_texts.yml +0 -10415
  79. data/spec/fixtures/vcr_cassettes/usage.yml +0 -171
  80. data/spec/integration_tests/document_api_spec.rb +0 -177
  81. data/spec/integration_tests/integration_test_utils.rb +0 -170
  82. data/spec/requests/glossary/create_spec.rb +0 -65
  83. data/spec/requests/glossary/destroy_spec.rb +0 -66
  84. data/spec/requests/glossary/entries_spec.rb +0 -62
  85. data/spec/requests/glossary/find_spec.rb +0 -68
  86. data/spec/requests/glossary/language_pairs_spec.rb +0 -40
  87. data/spec/requests/glossary/list_spec.rb +0 -54
  88. data/spec/requests/languages_spec.rb +0 -68
  89. data/spec/requests/rephrase_spec.rb +0 -172
  90. data/spec/requests/translate_spec.rb +0 -422
  91. data/spec/requests/usage_spec.rb +0 -43
  92. data/spec/resources/glossary_spec.rb +0 -38
  93. data/spec/resources/language_pair_spec.rb +0 -23
  94. data/spec/resources/language_spec.rb +0 -45
  95. data/spec/resources/text_spec.rb +0 -23
  96. data/spec/resources/usage_spec.rb +0 -35
  97. data/spec/spec_helper.rb +0 -92
data/CONTRIBUTING.md DELETED
@@ -1,37 +0,0 @@
1
- # Contributing guidelines
2
-
3
- * [Code of Conduct](#code-of-conduct)
4
- * [Issues](#issues)
5
- * [Pull Requests](#pull-requests)
6
-
7
- ## Code of Conduct
8
-
9
- This project has a [Code of Conduct](CODE_OF_CONDUCT.md) to which all
10
- contributors must adhere when participating in the project. Instances of
11
- abusive, harassing, or otherwise unacceptable behavior may be reported by
12
- contacting [open-source@deepl.com](mailto:open-source@deepl.com) and/or a
13
- project maintainer.
14
-
15
- ## Issues
16
-
17
- If you experience problems using the library, or would like to request a new
18
- feature, please open an [issue][issues].
19
-
20
- Please provide as much context as possible when you open an issue. The
21
- information you provide must be comprehensive enough for us to reproduce the
22
- issue.
23
-
24
- ## Pull Requests
25
-
26
- You are welcome to contribute code and/or documentation in order to fix a bug or
27
- to implement a new feature. Before beginning work, you should create an issue
28
- describing the changes you plan to contribute, to avoid wasting or duplicating
29
- effort. We will then let you know whether we would accept the changes.
30
-
31
- Contributions must be licensed under the same license as the project:
32
- [MIT License](LICENSE.md).
33
-
34
- Currently automated testing is implemented internally at DeepL, however we plan
35
- to implement publicly visible testing soon.
36
-
37
- [issues]: https://www.github.com/DeepLcom/deepl-rb/issues
data/Gemfile DELETED
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source 'https://rubygems.org'
4
-
5
- group :development do
6
- # Gem management
7
- gem 'juwelier'
8
- end
9
-
10
- group :test, :development do
11
- gem 'byebug', require: 'byebug'
12
- end
13
-
14
- group :test do
15
- # Test
16
- gem 'rspec'
17
- gem 'rspec_junit_formatter'
18
- gem 'rubocop'
19
- gem 'rubocop-rspec'
20
- gem 'simplecov'
21
- gem 'simplecov-cobertura'
22
- gem 'vcr'
23
- gem 'webmock'
24
- end
data/Rakefile DELETED
@@ -1,54 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rubygems'
4
- require 'bundler'
5
-
6
- begin
7
- Bundler.setup(:default, :development)
8
- rescue Bundler::BundlerError => e
9
- warn e.message
10
- warn 'Run `bundle install` to install missing gems'
11
- exit e.status_code
12
- end
13
-
14
- require 'rake'
15
- require 'juwelier'
16
-
17
- Juwelier::Tasks.new do |gem|
18
- gem.name = 'deepl-rb'
19
- gem.homepage = 'https://github.com/DeepLcom/deepl-rb'
20
- gem.license = 'MIT'
21
- gem.summary = 'Official Ruby library for the DeepL language translation API.'
22
- gem.description =
23
- 'Official Ruby library for the DeepL language translation API (v2). ' \
24
- 'For more information, check this: https://www.deepl.com/docs/api-reference.html'
25
-
26
- gem.email = 'open-source@deepl.com'
27
- gem.authors = ['DeepL SE']
28
- gem.metadata = {
29
- 'bug_tracker_uri' => 'https://github.com/DeepLcom/deepl-rb/issues',
30
- 'changelog_uri' => 'https://github.com/DeepLcom/deepl-rb/blob/main/CHANGELOG.md',
31
- 'documentation_uri' => 'https://github.com/DeepLcom/deepl-rb/blob/main/README.md',
32
- 'homepage_uri' => 'https://github.com/DeepLcom/deepl-rb'
33
- }
34
- gem.files.exclude '.github'
35
- gem.files.exclude '.circleci'
36
- gem.files.exclude 'catalog-info.yaml'
37
- end
38
-
39
- Juwelier::RubygemsDotOrgTasks.new
40
-
41
- # Tests
42
- require 'rspec/core/rake_task'
43
- require 'rubocop/rake_task'
44
-
45
- RuboCop::RakeTask.new
46
- RSpec::Core::RakeTask.new(:spec)
47
-
48
- desc 'Run all tests.'
49
- task :test do
50
- Rake::Task['spec'].invoke
51
- Rake::Task['rubocop'].invoke
52
- end
53
-
54
- task default: :test
data/SECURITY.md DELETED
@@ -1,58 +0,0 @@
1
- To report security concerns or vulnerabilities within deepl-rb, please email
2
- us at [security@deepl.com](mailto:security@deepl.com).
3
-
4
- You can send us PGP-encrypted email using the following PGP public key:
5
-
6
- ```
7
- -----BEGIN PGP PUBLIC KEY BLOCK-----
8
-
9
- mQINBF7WSmABEADzRUp22VY7bVfUWScKLi9o8BRSEL4u3aPn9WOQoRLQH0j3dNNQ
10
- FQlwTPn/Ez6qreEl8mX0aE+eLCEykXqsrU/UaTSTslF+H6UQyuGLXkRm8Lblt93I
11
- OEhL069fC7rm+/zJq72+hishBF8DXqa+WtFd8VfK3i211vRhU/teKeAKT0xiuN/5
12
- EQl1Bn7jR7mmQtNbPBhCsAlaC/tNUQ3Lyj6LYnnco7ums5Q/gCvfs2HM3mXJyvnG
13
- 1MC2IrECPowTt04W3V1uXuMcm766orTG/AmtBIbPmOzao4sfqwRVHGvc8zcr1az9
14
- 0nVyEJXx1eUVRDU1GAQuMjEkGgwvTd+nt6sHpn8C+9hMYJhon9veDSupViBuvNRC
15
- p1PnpSLYYy7tA7DPXMhP3c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e5MryioKRbTFQ8OgvKh9GK/tYtqZakn7Q9596ajUjHOQV1+Uw/jywLYRlcbqI
48
- zbxyNVWitxPs3Z7jUDAvhPOIOmhLFc+QxSYrs1W4ZEGnZ3+9utqzlEiMusy9Rq0T
49
- /W/wrG6SckebjhrwWZJmy/hkW6V6LUX4++vCVV5+zwsvgEortCV8bhvLfqQDr/WN
50
- fnmbNZtXJbyhTYbcYReOLeKidxO2lZEemnX6iOt5xCdoMcYU23xDT9+tE7Eh6Nfw
51
- einZemBwfku5vxxPF73pOoQUCRq9tgvUrEq+3BqkqidhnFUOPi0J5726q1PBG65x
52
- 5o+SQyvB3NA3al3mEH65z3V3/g0UHnhGcEMwVOXBkffgdKNhWYw59qhSVQnkiq0U
53
- MG10g/RL7VdiISAFPTDmKWUaEDYosinKqOMHwcaVdJq9ssvPf89et6yP/ZkbLIHs
54
- 2y3oiPonh2RMxi2OedlDz+Jp/A2o3qHmwNvBx/meGB0praGUonFVZTAA1EMS39Bi
55
- NhG/L8giTyzA0mMkTJAPXtUVlRe5rEjORgYJsgRqZxEfpsJC9OkvYS4ayO0eCEs=
56
- =jVHt
57
- -----END PGP PUBLIC KEY BLOCK-----
58
- ```%
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 3.3.0
data/deepl-rb.gemspec DELETED
@@ -1,133 +0,0 @@
1
- # Generated by juwelier
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
- # stub: deepl-rb 3.3.0 ruby lib
6
-
7
- Gem::Specification.new do |s|
8
- s.name = "deepl-rb".freeze
9
- s.version = "3.3.0"
10
-
11
- s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
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
- s.require_paths = ["lib".freeze]
14
- s.authors = ["DeepL SE".freeze]
15
- s.date = "2025-11-04"
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
- s.email = "open-source@deepl.com".freeze
18
- s.extra_rdoc_files = [
19
- "CHANGELOG.md",
20
- "LICENSE.md",
21
- "README.md",
22
- "license_checker.sh"
23
- ]
24
- s.files = [
25
- ".circleci/config.yml",
26
- ".github/workflows/add_issues_to_kanban.yml",
27
- ".gitlab-ci.yml",
28
- ".rubocop.yml",
29
- "CHANGELOG.md",
30
- "CODE_OF_CONDUCT.md",
31
- "CONTRIBUTING.md",
32
- "Gemfile",
33
- "LICENSE.md",
34
- "README.md",
35
- "Rakefile",
36
- "SECURITY.md",
37
- "VERSION",
38
- "deepl-rb.gemspec",
39
- "lib/deepl.rb",
40
- "lib/deepl/api.rb",
41
- "lib/deepl/configuration.rb",
42
- "lib/deepl/constants/base_constant.rb",
43
- "lib/deepl/constants/formality.rb",
44
- "lib/deepl/constants/model_type.rb",
45
- "lib/deepl/constants/split_sentences.rb",
46
- "lib/deepl/constants/tag_handling.rb",
47
- "lib/deepl/constants/tone.rb",
48
- "lib/deepl/constants/writing_style.rb",
49
- "lib/deepl/document_api.rb",
50
- "lib/deepl/exceptions/authorization_failed.rb",
51
- "lib/deepl/exceptions/bad_request.rb",
52
- "lib/deepl/exceptions/document_translation_error.rb",
53
- "lib/deepl/exceptions/error.rb",
54
- "lib/deepl/exceptions/limit_exceeded.rb",
55
- "lib/deepl/exceptions/not_found.rb",
56
- "lib/deepl/exceptions/not_supported.rb",
57
- "lib/deepl/exceptions/quota_exceeded.rb",
58
- "lib/deepl/exceptions/request_entity_too_large.rb",
59
- "lib/deepl/exceptions/request_error.rb",
60
- "lib/deepl/exceptions/server_error.rb",
61
- "lib/deepl/glossary_api.rb",
62
- "lib/deepl/requests/base.rb",
63
- "lib/deepl/requests/document/download.rb",
64
- "lib/deepl/requests/document/get_status.rb",
65
- "lib/deepl/requests/document/upload.rb",
66
- "lib/deepl/requests/glossary/create.rb",
67
- "lib/deepl/requests/glossary/destroy.rb",
68
- "lib/deepl/requests/glossary/entries.rb",
69
- "lib/deepl/requests/glossary/find.rb",
70
- "lib/deepl/requests/glossary/language_pairs.rb",
71
- "lib/deepl/requests/glossary/list.rb",
72
- "lib/deepl/requests/languages.rb",
73
- "lib/deepl/requests/rephrase.rb",
74
- "lib/deepl/requests/translate.rb",
75
- "lib/deepl/requests/usage.rb",
76
- "lib/deepl/resources/base.rb",
77
- "lib/deepl/resources/document_handle.rb",
78
- "lib/deepl/resources/document_translation_status.rb",
79
- "lib/deepl/resources/glossary.rb",
80
- "lib/deepl/resources/language.rb",
81
- "lib/deepl/resources/language_pair.rb",
82
- "lib/deepl/resources/text.rb",
83
- "lib/deepl/resources/usage.rb",
84
- "lib/deepl/utils/backoff_timer.rb",
85
- "lib/deepl/utils/exception_builder.rb",
86
- "lib/http_client_options.rb",
87
- "license_checker.sh",
88
- "spec/api/api_spec.rb",
89
- "spec/api/configuration_spec.rb",
90
- "spec/api/deepl_spec.rb",
91
- "spec/constants/constants_spec.rb",
92
- "spec/fixtures/vcr_cassettes/deepl_document.yml",
93
- "spec/fixtures/vcr_cassettes/deepl_document_download.yml",
94
- "spec/fixtures/vcr_cassettes/deepl_glossaries.yml",
95
- "spec/fixtures/vcr_cassettes/deepl_languages.yml",
96
- "spec/fixtures/vcr_cassettes/deepl_rephrase.yml",
97
- "spec/fixtures/vcr_cassettes/deepl_translate.yml",
98
- "spec/fixtures/vcr_cassettes/deepl_usage.yml",
99
- "spec/fixtures/vcr_cassettes/glossaries.yml",
100
- "spec/fixtures/vcr_cassettes/languages.yml",
101
- "spec/fixtures/vcr_cassettes/rephrase_texts.yml",
102
- "spec/fixtures/vcr_cassettes/translate_texts.yml",
103
- "spec/fixtures/vcr_cassettes/usage.yml",
104
- "spec/integration_tests/document_api_spec.rb",
105
- "spec/integration_tests/integration_test_utils.rb",
106
- "spec/requests/glossary/create_spec.rb",
107
- "spec/requests/glossary/destroy_spec.rb",
108
- "spec/requests/glossary/entries_spec.rb",
109
- "spec/requests/glossary/find_spec.rb",
110
- "spec/requests/glossary/language_pairs_spec.rb",
111
- "spec/requests/glossary/list_spec.rb",
112
- "spec/requests/languages_spec.rb",
113
- "spec/requests/rephrase_spec.rb",
114
- "spec/requests/translate_spec.rb",
115
- "spec/requests/usage_spec.rb",
116
- "spec/resources/glossary_spec.rb",
117
- "spec/resources/language_pair_spec.rb",
118
- "spec/resources/language_spec.rb",
119
- "spec/resources/text_spec.rb",
120
- "spec/resources/usage_spec.rb",
121
- "spec/spec_helper.rb"
122
- ]
123
- s.homepage = "https://github.com/DeepLcom/deepl-rb".freeze
124
- s.licenses = ["MIT".freeze]
125
- s.rubygems_version = "3.4.6".freeze
126
- s.summary = "Official Ruby library for the DeepL language translation API.".freeze
127
-
128
- s.specification_version = 4
129
-
130
- s.add_development_dependency(%q<juwelier>.freeze, [">= 0"])
131
- s.add_development_dependency(%q<byebug>.freeze, [">= 0"])
132
- end
133
-
data/lib/deepl/api.rb DELETED
@@ -1,22 +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
- class API
8
- attr_reader :configuration, :http_client
9
-
10
- def initialize(configuration)
11
- @configuration = configuration
12
- configuration.validate!
13
- uri = URI(configuration.host)
14
- @http_client = Net::HTTP.new(uri.host, uri.port)
15
- @http_client.use_ssl = uri.scheme == 'https'
16
- end
17
-
18
- def update_http_client(client)
19
- @http_client = client
20
- end
21
- end
22
- end
@@ -1,59 +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
- class Configuration
8
- ATTRIBUTES = %i[auth_key host logger max_doc_status_queries max_network_retries user_agent
9
- version].freeze
10
-
11
- attr_accessor(*ATTRIBUTES)
12
-
13
- DEEPL_SERVER_URL = 'https://api.deepl.com'
14
- DEEPL_SERVER_URL_FREE = 'https://api-free.deepl.com'
15
- private_constant :DEEPL_SERVER_URL, :DEEPL_SERVER_URL_FREE
16
-
17
- def initialize(data = {}, app_info_name = nil, app_info_version = nil, send_platform_info = true) # rubocop:disable all
18
- data.each { |key, value| send("#{key}=", value) }
19
- @auth_key ||= ENV.fetch('DEEPL_AUTH_KEY', nil)
20
- @host ||= ENV.fetch('DEEPL_SERVER_URL', nil)
21
- @host ||= if self.class.free_account_auth_key?(@auth_key)
22
- DEEPL_SERVER_URL_FREE
23
- else
24
- DEEPL_SERVER_URL
25
- end
26
- @version ||= 'v2'
27
- @user_agent ||= construct_user_agent(send_platform_info, app_info_name, app_info_version)
28
- @max_network_retries ||= 5
29
- @logger ||= nil
30
- end
31
-
32
- def validate!
33
- raise Exceptions::Error, 'auth_key not provided' if auth_key.nil? || auth_key.empty?
34
- end
35
-
36
- def attributes
37
- ATTRIBUTES.to_h { |attr| [attr, send(attr)] }
38
- end
39
-
40
- def ==(other)
41
- attributes == other.attributes
42
- end
43
-
44
- def self.free_account_auth_key?(key)
45
- key&.end_with?(':fx')
46
- end
47
-
48
- def construct_user_agent(send_platform_info, app_info_name, app_info_version)
49
- library_info_str = 'deepl-ruby/3.0.2'
50
- if send_platform_info
51
- library_info_str += " (#{RbConfig::CONFIG['host_os']}) ruby/#{RUBY_VERSION}"
52
- end
53
- if app_info_name && app_info_version
54
- library_info_str += " #{app_info_name}/#{app_info_version}"
55
- end
56
- library_info_str
57
- end
58
- end
59
- end
@@ -1,18 +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 Constants
8
- class BaseConstant
9
- def self.options
10
- constants.map { |const| const_get(const) }
11
- end
12
-
13
- def self.valid?(value)
14
- options.include?(value)
15
- end
16
- end
17
- end
18
- end
@@ -1,16 +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 Constants
8
- class Formality < BaseConstant
9
- DEFAULT = 'default'
10
- MORE = 'more'
11
- LESS = 'less'
12
- PREFER_MORE = 'prefer_more'
13
- PREFER_LESS = 'prefer_less'
14
- end
15
- end
16
- end
@@ -1,14 +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 Constants
8
- class ModelType < BaseConstant
9
- QUALITY_OPTIMIZED = 'quality_optimized'
10
- PREFER_QUALITY_OPTIMIZED = 'prefer_quality_optimized'
11
- LATENCY_OPTIMIZED = 'latency_optimized'
12
- end
13
- end
14
- end
@@ -1,14 +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 Constants
8
- class SplitSentences < BaseConstant
9
- NO_SPLITTING = '0'
10
- SPLIT_ON_PUNCTUATION_AND_NEWLINES = '1'
11
- SPLIT_ON_PUNCTUATION_ONLY = 'nonewlines'
12
- end
13
- end
14
- end
@@ -1,13 +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 Constants
8
- class TagHandling < BaseConstant
9
- XML = 'xml'
10
- HTML = 'html'
11
- end
12
- end
13
- end
@@ -1,20 +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 Constants
8
- class Tone < BaseConstant
9
- DEFAULT = 'default'
10
- ENTHUSIASTIC = 'enthusiastic'
11
- FRIENDLY = 'friendly'
12
- CONFIDENT = 'confident'
13
- DIPLOMATIC = 'diplomatic'
14
- PREFER_ENTHUSIASTIC = 'prefer_enthusiastic'
15
- PREFER_FRIENDLY = 'prefer_friendly'
16
- PREFER_CONFIDENT = 'prefer_confident'
17
- PREFER_DIPLOMATIC = 'prefer_diplomatic'
18
- end
19
- end
20
- end
@@ -1,20 +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 Constants
8
- class WritingStyle < BaseConstant
9
- DEFAULT = 'default'
10
- SIMPLE = 'simple'
11
- BUSINESS = 'business'
12
- ACADEMIC = 'academic'
13
- CASUAL = 'casual'
14
- PREFER_SIMPLE = 'prefer_simple'
15
- PREFER_BUSINESS = 'prefer_business'
16
- PREFER_ACADEMIC = 'prefer_academic'
17
- PREFER_CASUAL = 'prefer_casual'
18
- end
19
- end
20
- end
@@ -1,121 +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
- class DocumentApi
8
- def initialize(api, options = {})
9
- @api = api
10
- @options = options
11
- end
12
-
13
- ##
14
- # Uploads the file at the given +input_file_path+ to be translated from +source_lang+ into
15
- # +target_lang+. The API interface is async, so you need to poll using the returned
16
- # `DeepL::Resources::DocumentHandle` until the translation is finished, then you can download it
17
- #
18
- # @param [String] input_file_path File path to the file to be translated
19
- # @param [String, nil] source_lang Source language to use for the translation. `nil` will cause
20
- # automatic source langauge detection to be used. Must be
21
- # formatted as ISO 639-1, 2-letter language codes.
22
- # @param [String] target_lang Target language to use for the translation. Must be formatted as
23
- # ISO 639-1, 2-letter language codes, plus a hyphen "-" with the
24
- # variant identifier for languages with variants/dialects/... .
25
- # @param [String, nil] filename The filename of the file, including its extension. Used to open
26
- # the different kinds of documents (PDFs, etc). If nil, will use
27
- # the filename of +input_file_path+.
28
- # @param [Hash] options Additional (body) options for the upload.
29
- # @param [Hash] additional_headers Additional HTTP headers for the upload.
30
- # @return [DeepL::Resources::DocumentHandle] Document handle for the uploaded document.
31
-
32
- def upload(input_file_path, source_lang, target_lang, filename = nil, options = {},
33
- additional_headers = {})
34
- DeepL::Requests::Document::Upload.new(@api, input_file_path, source_lang, target_lang,
35
- filename, options, additional_headers)
36
- .request
37
- end
38
-
39
- ##
40
- # Queries the status of the translation of the document with the given +document_handle+.
41
- #
42
- # @param [DeepL::Resources::DocumentHandle] document_handle Handle returned by the `upload`
43
- # method.
44
- # @param [Hash] options Additional options for the upload.
45
- # @param [Hash] additional_headers Additional HTTP headers for the status check.
46
- # @return [DeepL::Resources::DocumentTranslationStatus] Status of the document translation.
47
-
48
- def get_status(document_handle, options = {}, additional_headers = {})
49
- DeepL::Requests::Document::GetStatus.new(@api, document_handle.document_id,
50
- document_handle.document_key, options,
51
- additional_headers).request
52
- end
53
-
54
- ##
55
- # Downloads the document identified by the +document_handle+ to +output_file+
56
- #
57
- # @param [DeepL::Resources::DocumentHandle] document_handle Handle returned by the `upload`
58
- # method.
59
- # @param [String] output_file Path to the file to write to. Will be overwritten if the file
60
- # already exists.
61
- # @return [DeepL::Resources::DocumentTranslationStatus] Status of the document translation.
62
-
63
- def download(document_handle, output_file)
64
- DeepL::Requests::Document::Download.new(@api, document_handle.document_id,
65
- document_handle.document_key, output_file).request
66
- end
67
-
68
- ##
69
- # Translates a document with the DeepL API, `sleep`ing during waiting periods. Returns the
70
- # status that was queried last. This can be either because the document translation terminated
71
- # (successfully or with an error) or because the maximum number of status requests have been
72
- # made. See the parameter `max_doc_status_queries` for details.
73
- #
74
- # @raise [DocumentTranslationError] If any error occurs during the process.
75
- #
76
- # @param [String] input_file Path to the file to be translated
77
- # @param [String] output_file Path to the file to write to. Will be overwritten if the file
78
- # already exists.
79
- # @param [String, nil] source_lang Source language to use for the translation. `nil` will cause
80
- # automatic source langauge detection to be used. Must be
81
- # formatted as ISO 639-1, 2-letter language codes.
82
- # @param [String] target_lang Target language to use for the translation. Must be formatted as
83
- # ISO 639-1, 2-letter language codes, plus a hyphen "-" with the
84
- # variant identifier for languages with variants/dialects/... .
85
- # @param [String, nil] filename The filename of the file, including its extension. Used to open
86
- # the different kinds of documents (PDFs, etc). If nil, will use
87
- # the filename of +input_file_path+.
88
- # @param [Hash] options Additional options for the upload.
89
- # @param [Hash] additional_headers Additional headers for the upload.
90
- # @return [DeepL::Resources::DocumentTranslationStatus] Status of the document translation.
91
-
92
- def translate_document(input_file, output_file, source_lang, target_lang, # rubocop:disable Metrics/MethodLength,Metrics/ParameterLists
93
- filename = nil, options = {}, additional_headers = {})
94
- raise IOError 'File already exists at output path' if File.exist?(output_file)
95
-
96
- begin
97
- handle = upload(input_file, source_lang, target_lang, filename, options,
98
- additional_headers)
99
- translate_document_wait_and_download(handle, output_file)
100
- rescue StandardError => e
101
- FileUtils.rm_f(output_file)
102
- raise Exceptions::DocumentTranslationError.new(
103
- "Error occurred during document translation: #{e.message}", handle
104
- )
105
- end
106
- end
107
-
108
- private
109
-
110
- def translate_document_wait_and_download(document_handle, output_file)
111
- doc_status = document_handle.wait_until_document_translation_finished
112
- if doc_status.error?
113
- raise Exceptions::DocumentTranslationError.new(
114
- "Exception when querying document status #{doc_status.error_message}", document_handle
115
- )
116
- else
117
- download(document_handle, output_file)
118
- end
119
- end
120
- end
121
- end
@@ -1,14 +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 Exceptions
8
- class AuthorizationFailed < RequestError
9
- def to_s
10
- 'Authorization failed. Please supply a valid auth_key parameter.'
11
- end
12
- end
13
- end
14
- end