deepl-rb 2.2.1 → 2.5.3
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 +5 -5
- data/.circleci/config.yml +1 -13
- data/.rubocop.yml +8 -4
- data/Gemfile +6 -0
- data/README.md +133 -25
- data/Rakefile +2 -0
- data/VERSION +1 -1
- data/deepl-rb.gemspec +38 -10
- data/lib/deepl/api.rb +2 -0
- data/lib/deepl/configuration.rb +4 -2
- data/lib/deepl/exceptions/authorization_failed.rb +2 -0
- data/lib/deepl/exceptions/bad_request.rb +4 -0
- data/lib/deepl/exceptions/error.rb +2 -0
- data/lib/deepl/exceptions/limit_exceeded.rb +2 -0
- data/lib/deepl/exceptions/not_found.rb +13 -0
- data/lib/deepl/exceptions/not_supported.rb +11 -0
- data/lib/deepl/exceptions/quota_exceeded.rb +2 -0
- data/lib/deepl/exceptions/request_entity_too_large.rb +12 -0
- data/lib/deepl/exceptions/request_error.rb +4 -1
- data/lib/deepl/glossary_api.rb +35 -0
- data/lib/deepl/requests/base.rb +23 -11
- data/lib/deepl/requests/glossary/create.rb +45 -0
- data/lib/deepl/requests/glossary/destroy.rb +30 -0
- data/lib/deepl/requests/glossary/entries.rb +30 -0
- data/lib/deepl/requests/glossary/find.rb +31 -0
- data/lib/deepl/requests/glossary/language_pairs.rb +31 -0
- data/lib/deepl/requests/glossary/list.rb +30 -0
- data/lib/deepl/requests/languages.rb +30 -0
- data/lib/deepl/requests/translate.rb +8 -2
- data/lib/deepl/requests/usage.rb +2 -0
- data/lib/deepl/resources/base.rb +2 -0
- data/lib/deepl/resources/glossary.rb +25 -0
- data/lib/deepl/resources/language.rb +27 -0
- data/lib/deepl/resources/language_pair.rb +20 -0
- data/lib/deepl/resources/text.rb +2 -0
- data/lib/deepl/resources/usage.rb +2 -0
- data/lib/deepl/utils/exception_builder.rb +29 -0
- data/lib/deepl.rb +28 -0
- data/spec/api/api_spec.rb +2 -0
- data/spec/api/configuration_spec.rb +4 -2
- data/spec/api/deepl_spec.rb +213 -0
- data/spec/fixtures/vcr_cassettes/deepl_glossaries.yml +374 -0
- data/spec/fixtures/vcr_cassettes/deepl_languages.yml +43 -0
- data/spec/fixtures/vcr_cassettes/deepl_translate.yml +215 -5
- data/spec/fixtures/vcr_cassettes/deepl_usage.yml +12 -7
- data/spec/fixtures/vcr_cassettes/glossaries.yml +480 -0
- data/spec/fixtures/vcr_cassettes/languages.yml +114 -0
- data/spec/fixtures/vcr_cassettes/translate_texts.yml +199 -33
- data/spec/fixtures/vcr_cassettes/usage.yml +12 -7
- data/spec/requests/glossary/create_spec.rb +55 -0
- data/spec/requests/glossary/destroy_spec.rb +50 -0
- data/spec/requests/glossary/entries_spec.rb +48 -0
- data/spec/requests/glossary/find_spec.rb +54 -0
- data/spec/requests/glossary/language_pairs_spec.rb +30 -0
- data/spec/requests/glossary/list_spec.rb +44 -0
- data/spec/requests/languages_spec.rb +58 -0
- data/spec/requests/translate_spec.rb +139 -4
- data/spec/requests/usage_spec.rb +2 -0
- data/spec/resources/glossary_spec.rb +35 -0
- data/spec/resources/language_pair_spec.rb +20 -0
- data/spec/resources/language_spec.rb +42 -0
- data/spec/resources/text_spec.rb +4 -2
- data/spec/resources/usage_spec.rb +5 -3
- data/spec/spec_helper.rb +6 -4
- metadata +49 -8
- data/Gemfile.lock +0 -113
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe DeepL::Resources::Language do
|
|
6
|
+
subject { described_class.new('EN', 'English', nil, nil, nil) }
|
|
7
|
+
|
|
8
|
+
describe '#initialize' do
|
|
9
|
+
context 'When building a basic object' do
|
|
10
|
+
it 'should create a resource' do
|
|
11
|
+
expect(subject).to be_a(described_class)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'should assign the attributes' do
|
|
15
|
+
expect(subject.code).to eq('EN')
|
|
16
|
+
expect(subject.name).to eq('English')
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'should not define the supports formality method' do
|
|
20
|
+
expect { subject.supports_formality? }.to raise_error(DeepL::Exceptions::NotSupported)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
context 'when building a target language object' do
|
|
25
|
+
subject { described_class.new('EN', 'English', true, nil, nil) }
|
|
26
|
+
|
|
27
|
+
it 'should create a resource' do
|
|
28
|
+
expect(subject).to be_a(described_class)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'should assign the attributes' do
|
|
32
|
+
expect(subject.code).to eq('EN')
|
|
33
|
+
expect(subject.name).to eq('English')
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'should include the supports formality method' do
|
|
37
|
+
expect { subject.supports_formality? }.not_to raise_error
|
|
38
|
+
expect(subject.supports_formality?).to be_truthy
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
data/spec/resources/text_spec.rb
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe DeepL::Resources::Text do
|
|
4
|
-
subject {
|
|
6
|
+
subject { described_class.new('Target', 'es', nil, nil) }
|
|
5
7
|
|
|
6
8
|
describe '#initialize' do
|
|
7
9
|
context 'When building a basic object' do
|
|
8
10
|
it 'should create a resource' do
|
|
9
|
-
expect(subject).to be_a(
|
|
11
|
+
expect(subject).to be_a(described_class)
|
|
10
12
|
end
|
|
11
13
|
|
|
12
14
|
it 'should assign the attributes' do
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe DeepL::Resources::Usage do
|
|
4
|
-
subject {
|
|
6
|
+
subject { described_class.new(3, 5, nil, nil) }
|
|
5
7
|
|
|
6
8
|
describe '#initialize' do
|
|
7
9
|
context 'When building a basic object' do
|
|
8
10
|
it 'should create a resource' do
|
|
9
|
-
expect(subject).to be_a(
|
|
11
|
+
expect(subject).to be_a(described_class)
|
|
10
12
|
end
|
|
11
13
|
|
|
12
14
|
it 'should assign the attributes' do
|
|
@@ -20,7 +22,7 @@ describe DeepL::Resources::Usage do
|
|
|
20
22
|
end
|
|
21
23
|
|
|
22
24
|
context 'When building a quota exceeded object' do
|
|
23
|
-
subject {
|
|
25
|
+
subject { described_class.new(5, 5, nil, nil) }
|
|
24
26
|
|
|
25
27
|
it 'should exceed the quota' do
|
|
26
28
|
expect(subject.quota_exceeded?).to be_truthy
|
data/spec/spec_helper.rb
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# Coverage
|
|
2
4
|
require 'simplecov'
|
|
3
5
|
SimpleCov.start
|
|
@@ -16,14 +18,14 @@ require 'vcr'
|
|
|
16
18
|
VCR.configure do |config|
|
|
17
19
|
config.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
|
|
18
20
|
config.hook_into :webmock
|
|
19
|
-
config.filter_sensitive_data('VALID_TOKEN') { ENV
|
|
21
|
+
config.filter_sensitive_data('VALID_TOKEN') { ENV.fetch('DEEPL_AUTH_KEY', nil) }
|
|
20
22
|
config.default_cassette_options = {
|
|
21
|
-
record: :new_episodes,
|
|
22
|
-
match_requests_on: %i[method uri body]
|
|
23
|
+
# record: :new_episodes,
|
|
24
|
+
match_requests_on: %i[method uri body headers]
|
|
23
25
|
}
|
|
24
26
|
end
|
|
25
27
|
|
|
26
28
|
# General helpers
|
|
27
29
|
def build_deepl_api
|
|
28
|
-
DeepL::API.new(DeepL::Configuration.new)
|
|
30
|
+
DeepL::API.new(DeepL::Configuration.new(host: 'https://api-free.deepl.com'))
|
|
29
31
|
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: 2.
|
|
4
|
+
version: 2.5.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel Herzog
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-09-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: juwelier
|
|
@@ -24,6 +24,20 @@ dependencies:
|
|
|
24
24
|
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '0'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: byebug
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
27
41
|
description: 'A simple ruby wrapper for the DeepL translation API (v1). For more information,
|
|
28
42
|
check this: https://www.deepl.com/docs/api-reference.html'
|
|
29
43
|
email: info@danielherzog.es
|
|
@@ -36,7 +50,6 @@ files:
|
|
|
36
50
|
- ".circleci/config.yml"
|
|
37
51
|
- ".rubocop.yml"
|
|
38
52
|
- Gemfile
|
|
39
|
-
- Gemfile.lock
|
|
40
53
|
- LICENSE.md
|
|
41
54
|
- README.md
|
|
42
55
|
- Rakefile
|
|
@@ -49,23 +62,52 @@ files:
|
|
|
49
62
|
- lib/deepl/exceptions/bad_request.rb
|
|
50
63
|
- lib/deepl/exceptions/error.rb
|
|
51
64
|
- lib/deepl/exceptions/limit_exceeded.rb
|
|
65
|
+
- lib/deepl/exceptions/not_found.rb
|
|
66
|
+
- lib/deepl/exceptions/not_supported.rb
|
|
52
67
|
- lib/deepl/exceptions/quota_exceeded.rb
|
|
68
|
+
- lib/deepl/exceptions/request_entity_too_large.rb
|
|
53
69
|
- lib/deepl/exceptions/request_error.rb
|
|
70
|
+
- lib/deepl/glossary_api.rb
|
|
54
71
|
- lib/deepl/requests/base.rb
|
|
72
|
+
- lib/deepl/requests/glossary/create.rb
|
|
73
|
+
- lib/deepl/requests/glossary/destroy.rb
|
|
74
|
+
- lib/deepl/requests/glossary/entries.rb
|
|
75
|
+
- lib/deepl/requests/glossary/find.rb
|
|
76
|
+
- lib/deepl/requests/glossary/language_pairs.rb
|
|
77
|
+
- lib/deepl/requests/glossary/list.rb
|
|
78
|
+
- lib/deepl/requests/languages.rb
|
|
55
79
|
- lib/deepl/requests/translate.rb
|
|
56
80
|
- lib/deepl/requests/usage.rb
|
|
57
81
|
- lib/deepl/resources/base.rb
|
|
82
|
+
- lib/deepl/resources/glossary.rb
|
|
83
|
+
- lib/deepl/resources/language.rb
|
|
84
|
+
- lib/deepl/resources/language_pair.rb
|
|
58
85
|
- lib/deepl/resources/text.rb
|
|
59
86
|
- lib/deepl/resources/usage.rb
|
|
87
|
+
- lib/deepl/utils/exception_builder.rb
|
|
60
88
|
- spec/api/api_spec.rb
|
|
61
89
|
- spec/api/configuration_spec.rb
|
|
62
90
|
- spec/api/deepl_spec.rb
|
|
91
|
+
- spec/fixtures/vcr_cassettes/deepl_glossaries.yml
|
|
92
|
+
- spec/fixtures/vcr_cassettes/deepl_languages.yml
|
|
63
93
|
- spec/fixtures/vcr_cassettes/deepl_translate.yml
|
|
64
94
|
- spec/fixtures/vcr_cassettes/deepl_usage.yml
|
|
95
|
+
- spec/fixtures/vcr_cassettes/glossaries.yml
|
|
96
|
+
- spec/fixtures/vcr_cassettes/languages.yml
|
|
65
97
|
- spec/fixtures/vcr_cassettes/translate_texts.yml
|
|
66
98
|
- spec/fixtures/vcr_cassettes/usage.yml
|
|
99
|
+
- spec/requests/glossary/create_spec.rb
|
|
100
|
+
- spec/requests/glossary/destroy_spec.rb
|
|
101
|
+
- spec/requests/glossary/entries_spec.rb
|
|
102
|
+
- spec/requests/glossary/find_spec.rb
|
|
103
|
+
- spec/requests/glossary/language_pairs_spec.rb
|
|
104
|
+
- spec/requests/glossary/list_spec.rb
|
|
105
|
+
- spec/requests/languages_spec.rb
|
|
67
106
|
- spec/requests/translate_spec.rb
|
|
68
107
|
- spec/requests/usage_spec.rb
|
|
108
|
+
- spec/resources/glossary_spec.rb
|
|
109
|
+
- spec/resources/language_pair_spec.rb
|
|
110
|
+
- spec/resources/language_spec.rb
|
|
69
111
|
- spec/resources/text_spec.rb
|
|
70
112
|
- spec/resources/usage_spec.rb
|
|
71
113
|
- spec/spec_helper.rb
|
|
@@ -73,7 +115,7 @@ homepage: http://github.com/wikiti/deepl-rb
|
|
|
73
115
|
licenses:
|
|
74
116
|
- MIT
|
|
75
117
|
metadata: {}
|
|
76
|
-
post_install_message:
|
|
118
|
+
post_install_message:
|
|
77
119
|
rdoc_options: []
|
|
78
120
|
require_paths:
|
|
79
121
|
- lib
|
|
@@ -88,9 +130,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
88
130
|
- !ruby/object:Gem::Version
|
|
89
131
|
version: '0'
|
|
90
132
|
requirements: []
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
signing_key:
|
|
133
|
+
rubygems_version: 3.3.7
|
|
134
|
+
signing_key:
|
|
94
135
|
specification_version: 4
|
|
95
136
|
summary: A simple ruby wrapper for the DeepL API
|
|
96
137
|
test_files: []
|
data/Gemfile.lock
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
GEM
|
|
2
|
-
remote: https://rubygems.org/
|
|
3
|
-
specs:
|
|
4
|
-
addressable (2.5.2)
|
|
5
|
-
public_suffix (>= 2.0.2, < 4.0)
|
|
6
|
-
ast (2.3.0)
|
|
7
|
-
builder (3.2.3)
|
|
8
|
-
codecov (0.1.10)
|
|
9
|
-
json
|
|
10
|
-
simplecov
|
|
11
|
-
url
|
|
12
|
-
crack (0.4.3)
|
|
13
|
-
safe_yaml (~> 1.0.0)
|
|
14
|
-
descendants_tracker (0.0.4)
|
|
15
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
|
16
|
-
diff-lcs (1.3)
|
|
17
|
-
docile (1.1.5)
|
|
18
|
-
faraday (0.12.2)
|
|
19
|
-
multipart-post (>= 1.2, < 3)
|
|
20
|
-
git (1.3.0)
|
|
21
|
-
github_api (0.18.2)
|
|
22
|
-
addressable (~> 2.4)
|
|
23
|
-
descendants_tracker (~> 0.0.4)
|
|
24
|
-
faraday (~> 0.8)
|
|
25
|
-
hashie (~> 3.5, >= 3.5.2)
|
|
26
|
-
oauth2 (~> 1.0)
|
|
27
|
-
hashdiff (0.3.7)
|
|
28
|
-
hashie (3.5.7)
|
|
29
|
-
highline (1.7.10)
|
|
30
|
-
json (2.1.0)
|
|
31
|
-
juwelier (2.1.3)
|
|
32
|
-
builder
|
|
33
|
-
bundler (>= 1.13)
|
|
34
|
-
git (>= 1.2.5)
|
|
35
|
-
github_api
|
|
36
|
-
highline (>= 1.6.15)
|
|
37
|
-
nokogiri (>= 1.5.10)
|
|
38
|
-
rake
|
|
39
|
-
rdoc
|
|
40
|
-
semver
|
|
41
|
-
jwt (1.5.6)
|
|
42
|
-
mini_portile2 (2.3.0)
|
|
43
|
-
multi_json (1.12.2)
|
|
44
|
-
multi_xml (0.6.0)
|
|
45
|
-
multipart-post (2.0.0)
|
|
46
|
-
nokogiri (1.8.1)
|
|
47
|
-
mini_portile2 (~> 2.3.0)
|
|
48
|
-
oauth2 (1.4.0)
|
|
49
|
-
faraday (>= 0.8, < 0.13)
|
|
50
|
-
jwt (~> 1.0)
|
|
51
|
-
multi_json (~> 1.3)
|
|
52
|
-
multi_xml (~> 0.5)
|
|
53
|
-
rack (>= 1.2, < 3)
|
|
54
|
-
parallel (1.12.1)
|
|
55
|
-
parser (2.4.0.2)
|
|
56
|
-
ast (~> 2.3)
|
|
57
|
-
powerpack (0.1.1)
|
|
58
|
-
public_suffix (3.0.1)
|
|
59
|
-
rack (1.6.8)
|
|
60
|
-
rainbow (3.0.0)
|
|
61
|
-
rake (12.3.0)
|
|
62
|
-
rdoc (5.1.0)
|
|
63
|
-
rspec (3.7.0)
|
|
64
|
-
rspec-core (~> 3.7.0)
|
|
65
|
-
rspec-expectations (~> 3.7.0)
|
|
66
|
-
rspec-mocks (~> 3.7.0)
|
|
67
|
-
rspec-core (3.7.1)
|
|
68
|
-
rspec-support (~> 3.7.0)
|
|
69
|
-
rspec-expectations (3.7.0)
|
|
70
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
|
71
|
-
rspec-support (~> 3.7.0)
|
|
72
|
-
rspec-mocks (3.7.0)
|
|
73
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
|
74
|
-
rspec-support (~> 3.7.0)
|
|
75
|
-
rspec-support (3.7.0)
|
|
76
|
-
rubocop (0.52.1)
|
|
77
|
-
parallel (~> 1.10)
|
|
78
|
-
parser (>= 2.4.0.2, < 3.0)
|
|
79
|
-
powerpack (~> 0.1)
|
|
80
|
-
rainbow (>= 2.2.2, < 4.0)
|
|
81
|
-
ruby-progressbar (~> 1.7)
|
|
82
|
-
unicode-display_width (~> 1.0, >= 1.0.1)
|
|
83
|
-
ruby-progressbar (1.9.0)
|
|
84
|
-
safe_yaml (1.0.4)
|
|
85
|
-
semver (1.0.1)
|
|
86
|
-
simplecov (0.15.1)
|
|
87
|
-
docile (~> 1.1.0)
|
|
88
|
-
json (>= 1.8, < 3)
|
|
89
|
-
simplecov-html (~> 0.10.0)
|
|
90
|
-
simplecov-html (0.10.2)
|
|
91
|
-
thread_safe (0.3.6)
|
|
92
|
-
unicode-display_width (1.3.0)
|
|
93
|
-
url (0.3.2)
|
|
94
|
-
vcr (4.0.0)
|
|
95
|
-
webmock (3.2.1)
|
|
96
|
-
addressable (>= 2.3.6)
|
|
97
|
-
crack (>= 0.3.2)
|
|
98
|
-
hashdiff
|
|
99
|
-
|
|
100
|
-
PLATFORMS
|
|
101
|
-
ruby
|
|
102
|
-
|
|
103
|
-
DEPENDENCIES
|
|
104
|
-
codecov
|
|
105
|
-
juwelier
|
|
106
|
-
rspec
|
|
107
|
-
rubocop
|
|
108
|
-
simplecov
|
|
109
|
-
vcr
|
|
110
|
-
webmock
|
|
111
|
-
|
|
112
|
-
BUNDLED WITH
|
|
113
|
-
1.16.0.pre.2
|