deepl-rb 2.3.1 → 2.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +7 -4
- data/README.md +100 -1
- data/VERSION +1 -1
- data/deepl-rb.gemspec +25 -4
- data/lib/deepl/configuration.rb +2 -2
- data/lib/deepl/exceptions/not_found.rb +13 -0
- data/lib/deepl/exceptions/not_supported.rb +11 -0
- data/lib/deepl/glossary_api.rb +35 -0
- data/lib/deepl/requests/base.rb +21 -4
- 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 +3 -1
- data/lib/deepl/requests/translate.rb +4 -2
- data/lib/deepl/resources/glossary.rb +25 -0
- data/lib/deepl/resources/language.rb +8 -1
- data/lib/deepl/resources/language_pair.rb +20 -0
- data/lib/deepl.rb +16 -0
- data/spec/api/configuration_spec.rb +1 -1
- data/spec/api/deepl_spec.rb +189 -0
- data/spec/fixtures/vcr_cassettes/deepl_glossaries.yml +374 -0
- data/spec/fixtures/vcr_cassettes/deepl_languages.yml +3 -1
- data/spec/fixtures/vcr_cassettes/deepl_translate.yml +212 -1
- data/spec/fixtures/vcr_cassettes/deepl_usage.yml +3 -1
- data/spec/fixtures/vcr_cassettes/glossaries.yml +480 -0
- data/spec/fixtures/vcr_cassettes/languages.yml +9 -3
- data/spec/fixtures/vcr_cassettes/translate_texts.yml +101 -44
- data/spec/fixtures/vcr_cassettes/usage.yml +3 -1
- 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/translate_spec.rb +74 -2
- data/spec/resources/glossary_spec.rb +35 -0
- data/spec/resources/language_pair_spec.rb +20 -0
- data/spec/resources/language_spec.rb +23 -1
- data/spec/spec_helper.rb +3 -3
- metadata +24 -3
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe DeepL::Resources::Glossary do
|
6
|
+
subject do
|
7
|
+
described_class.new({
|
8
|
+
'glossary_id' => 'def3a26b-3e84-45b3-84ae-0c0aaf3525f7',
|
9
|
+
'name' => 'Mein Glossar',
|
10
|
+
'ready' => true,
|
11
|
+
'source_lang' => 'EN',
|
12
|
+
'target_lang' => 'DE',
|
13
|
+
'creation_time' => '2021-08-03T14:16:18.329Z',
|
14
|
+
'entry_count' => 1
|
15
|
+
}, nil, nil)
|
16
|
+
end
|
17
|
+
|
18
|
+
describe '#initialize' do
|
19
|
+
context 'When building a basic object' do
|
20
|
+
it 'should create a resource' do
|
21
|
+
expect(subject).to be_a(described_class)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should assign the attributes' do
|
25
|
+
expect(subject.id).to eq('def3a26b-3e84-45b3-84ae-0c0aaf3525f7')
|
26
|
+
expect(subject.name).to eq('Mein Glossar')
|
27
|
+
expect(subject.ready).to eq(true)
|
28
|
+
expect(subject.source_lang).to eq('EN')
|
29
|
+
expect(subject.target_lang).to eq('DE')
|
30
|
+
expect(subject.creation_time).to eq('2021-08-03T14:16:18.329Z')
|
31
|
+
expect(subject.entry_count).to eq(1)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe DeepL::Resources::LanguagePair do
|
6
|
+
subject { described_class.new('en', 'de', 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.source_lang).to eq('en')
|
16
|
+
expect(subject.target_lang).to eq('de')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe DeepL::Resources::Language do
|
6
|
-
subject { described_class.new('EN', 'English', nil, nil) }
|
6
|
+
subject { described_class.new('EN', 'English', nil, nil, nil) }
|
7
7
|
|
8
8
|
describe '#initialize' do
|
9
9
|
context 'When building a basic object' do
|
@@ -15,6 +15,28 @@ describe DeepL::Resources::Language do
|
|
15
15
|
expect(subject.code).to eq('EN')
|
16
16
|
expect(subject.name).to eq('English')
|
17
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
|
18
40
|
end
|
19
41
|
end
|
20
42
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -18,10 +18,10 @@ require 'vcr'
|
|
18
18
|
VCR.configure do |config|
|
19
19
|
config.cassette_library_dir = 'spec/fixtures/vcr_cassettes'
|
20
20
|
config.hook_into :webmock
|
21
|
-
config.filter_sensitive_data('VALID_TOKEN') { ENV
|
21
|
+
config.filter_sensitive_data('VALID_TOKEN') { ENV.fetch('DEEPL_AUTH_KEY', nil) }
|
22
22
|
config.default_cassette_options = {
|
23
|
-
record: :new_episodes,
|
24
|
-
match_requests_on: %i[method uri body]
|
23
|
+
# record: :new_episodes,
|
24
|
+
match_requests_on: %i[method uri body headers]
|
25
25
|
}
|
26
26
|
end
|
27
27
|
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Herzog
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-06-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: juwelier
|
@@ -62,28 +62,49 @@ files:
|
|
62
62
|
- lib/deepl/exceptions/bad_request.rb
|
63
63
|
- lib/deepl/exceptions/error.rb
|
64
64
|
- lib/deepl/exceptions/limit_exceeded.rb
|
65
|
+
- lib/deepl/exceptions/not_found.rb
|
66
|
+
- lib/deepl/exceptions/not_supported.rb
|
65
67
|
- lib/deepl/exceptions/quota_exceeded.rb
|
66
68
|
- lib/deepl/exceptions/request_error.rb
|
69
|
+
- lib/deepl/glossary_api.rb
|
67
70
|
- lib/deepl/requests/base.rb
|
71
|
+
- lib/deepl/requests/glossary/create.rb
|
72
|
+
- lib/deepl/requests/glossary/destroy.rb
|
73
|
+
- lib/deepl/requests/glossary/entries.rb
|
74
|
+
- lib/deepl/requests/glossary/find.rb
|
75
|
+
- lib/deepl/requests/glossary/language_pairs.rb
|
76
|
+
- lib/deepl/requests/glossary/list.rb
|
68
77
|
- lib/deepl/requests/languages.rb
|
69
78
|
- lib/deepl/requests/translate.rb
|
70
79
|
- lib/deepl/requests/usage.rb
|
71
80
|
- lib/deepl/resources/base.rb
|
81
|
+
- lib/deepl/resources/glossary.rb
|
72
82
|
- lib/deepl/resources/language.rb
|
83
|
+
- lib/deepl/resources/language_pair.rb
|
73
84
|
- lib/deepl/resources/text.rb
|
74
85
|
- lib/deepl/resources/usage.rb
|
75
86
|
- spec/api/api_spec.rb
|
76
87
|
- spec/api/configuration_spec.rb
|
77
88
|
- spec/api/deepl_spec.rb
|
89
|
+
- spec/fixtures/vcr_cassettes/deepl_glossaries.yml
|
78
90
|
- spec/fixtures/vcr_cassettes/deepl_languages.yml
|
79
91
|
- spec/fixtures/vcr_cassettes/deepl_translate.yml
|
80
92
|
- spec/fixtures/vcr_cassettes/deepl_usage.yml
|
93
|
+
- spec/fixtures/vcr_cassettes/glossaries.yml
|
81
94
|
- spec/fixtures/vcr_cassettes/languages.yml
|
82
95
|
- spec/fixtures/vcr_cassettes/translate_texts.yml
|
83
96
|
- spec/fixtures/vcr_cassettes/usage.yml
|
97
|
+
- spec/requests/glossary/create_spec.rb
|
98
|
+
- spec/requests/glossary/destroy_spec.rb
|
99
|
+
- spec/requests/glossary/entries_spec.rb
|
100
|
+
- spec/requests/glossary/find_spec.rb
|
101
|
+
- spec/requests/glossary/language_pairs_spec.rb
|
102
|
+
- spec/requests/glossary/list_spec.rb
|
84
103
|
- spec/requests/languages_spec.rb
|
85
104
|
- spec/requests/translate_spec.rb
|
86
105
|
- spec/requests/usage_spec.rb
|
106
|
+
- spec/resources/glossary_spec.rb
|
107
|
+
- spec/resources/language_pair_spec.rb
|
87
108
|
- spec/resources/language_spec.rb
|
88
109
|
- spec/resources/text_spec.rb
|
89
110
|
- spec/resources/usage_spec.rb
|
@@ -107,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
128
|
- !ruby/object:Gem::Version
|
108
129
|
version: '0'
|
109
130
|
requirements: []
|
110
|
-
rubygems_version: 3.
|
131
|
+
rubygems_version: 3.3.7
|
111
132
|
signing_key:
|
112
133
|
specification_version: 4
|
113
134
|
summary: A simple ruby wrapper for the DeepL API
|