deepl-rb 2.1.0 → 2.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7c3fdd20441317600a911a02659531c6595949ac
4
- data.tar.gz: 54818a5de28df31e33f2cf8434834177fbe71989
3
+ metadata.gz: 00b65dd648e7d29dc160d9e8b66c2eecc15dccdc
4
+ data.tar.gz: 47a4e9cd8476b801b617f1290a020e017aa80bb4
5
5
  SHA512:
6
- metadata.gz: e389b2270f9cc4584bbe5e77cf6d1f7f6aa087d23a4aa649afe8507c3f0be484685813c161e72d9b30acba49a67277e116ec141b7943216cc1eef399d703edd6
7
- data.tar.gz: 1dc00e5ba9ab6622f1bcd0fad1b4df2eef7258dcf1ee667ad6c9b7d647975c4eced8f4a37db192c96df020a395124bc48ab599f5dd2a05da23fa8452907bf12f
6
+ metadata.gz: 3ef63e90c6708751fffd2229c0e3ba96951932b2a520f66f566856b2990466bb1dc876c815f224495ae642fba9266591af74d1029fadf4abc2263f8ba25a570b
7
+ data.tar.gz: a017cc9b56ee7c10cba7e41c59bb17e5969f2e285d8293493ef1dff02947cfdb508684901dd0891ae3c1e17cce1511273ed9f758074607f5e9066c590adffd0d
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # DeepL for ruby
4
4
 
5
- A simple ruby wrapper for the [DeepL translation API (v1)](https://www.deepl.com/api.html).
5
+ A simple ruby wrapper for the [DeepL translation API (v2)](https://www.deepl.com/api.html).
6
6
 
7
7
  ## Installation
8
8
 
@@ -35,12 +35,13 @@ DeepL.configure do |config|
35
35
  end
36
36
  ```
37
37
 
38
- You can also configure the api host:
38
+ You can also configure the API host and the API version:
39
39
 
40
40
  ```rb
41
41
  DeepL.configure do |config|
42
42
  config.auth_key = 'your-api-token'
43
43
  config.host = 'https://test-api.deepl.com' # Default value is 'https://api.deepl.com'
44
+ config.version = 'v1' # Default value is 'v2'
44
45
  end
45
46
  ```
46
47
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.0
1
+ 2.2.0
data/deepl-rb.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: deepl-rb 2.1.0 ruby lib
5
+ # stub: deepl-rb 2.2.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "deepl-rb".freeze
9
- s.version = "2.1.0"
9
+ s.version = "2.2.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib".freeze]
13
13
  s.authors = ["Daniel Herzog".freeze]
14
- s.date = "2018-07-24"
14
+ s.date = "2018-11-28"
15
15
  s.description = "A simple ruby wrapper for the DeepL translation API (v1). For more information, check this: https://www.deepl.com/docs/api-reference.html".freeze
16
16
  s.email = "info@danielherzog.es".freeze
17
17
  s.extra_rdoc_files = [
@@ -1,6 +1,6 @@
1
1
  module DeepL
2
2
  class Configuration
3
- ATTRIBUTES = %i[auth_key host].freeze
3
+ ATTRIBUTES = %i[auth_key host version].freeze
4
4
 
5
5
  attr_accessor(*ATTRIBUTES)
6
6
 
@@ -8,6 +8,7 @@ module DeepL
8
8
  data.each { |key, value| send("#{key}=", value) }
9
9
  @auth_key ||= ENV['DEEPL_AUTH_KEY']
10
10
  @host ||= 'https://api.deepl.com'
11
+ @version ||= 'v2'
11
12
  end
12
13
 
13
14
  def validate!
@@ -1,8 +1,6 @@
1
1
  module DeepL
2
2
  module Requests
3
3
  class Base
4
- API_VERSION = 'v1'.freeze
5
-
6
4
  attr_reader :api, :response, :options
7
5
 
8
6
  def initialize(api, options = {})
@@ -73,7 +71,7 @@ module DeepL
73
71
  end
74
72
 
75
73
  def url
76
- "#{host}/#{API_VERSION}/#{path}"
74
+ "#{host}/#{api.configuration.version}/#{path}"
77
75
  end
78
76
 
79
77
  def uri
@@ -9,15 +9,17 @@ describe DeepL::Configuration do
9
9
  it 'should use default attributes' do
10
10
  expect(subject.auth_key).to eq(ENV['DEEPL_AUTH_KEY'])
11
11
  expect(subject.host).to eq('https://api.deepl.com')
12
+ expect(subject.version).to eq('v2')
12
13
  end
13
14
  end
14
15
 
15
16
  context 'When using custom configuration attributes' do
16
- let(:attributes) { { auth_key: 'SAMPLE', host: 'http://www.example.org' } }
17
+ let(:attributes) { { auth_key: 'SAMPLE', host: 'http://www.example.org', version: 'v1' } }
17
18
 
18
19
  it 'should use custom attributes' do
19
20
  expect(subject.auth_key).to eq(attributes[:auth_key])
20
21
  expect(subject.host).to eq(attributes[:host])
22
+ expect(subject.version).to eq(attributes[:version])
21
23
  end
22
24
  end
23
25
  end
@@ -15,12 +15,13 @@ describe DeepL do
15
15
 
16
16
  context 'When providing a valid configuration' do
17
17
  let(:configuration) do
18
- DeepL::Configuration.new(auth_key: 'VALID', host: 'http://www.example.org')
18
+ DeepL::Configuration.new(auth_key: 'VALID', host: 'http://www.example.org', version: 'v1')
19
19
  end
20
20
  before do
21
21
  subject.configure do |config|
22
22
  config.auth_key = configuration.auth_key
23
23
  config.host = configuration.host
24
+ config.version = configuration.version
24
25
  end
25
26
  end
26
27
 
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: https://api.deepl.com/v1/translate?auth_key=VALID_TOKEN&param=fake
5
+ uri: https://api.deepl.com/v2/translate?auth_key=VALID_TOKEN&param=fake
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: text=Sample&source_lang=EN&target_lang=ES
@@ -35,6 +35,6 @@ http_interactions:
35
35
  body:
36
36
  encoding: UTF-8
37
37
  string: '{"translations":[{"detected_source_language":"EN","text":"Muestra"}]}'
38
- http_version:
38
+ http_version:
39
39
  recorded_at: Tue, 08 May 2018 16:31:33 GMT
40
40
  recorded_with: VCR 4.0.0
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://api.deepl.com/v1/usage?auth_key=VALID_TOKEN
5
+ uri: https://api.deepl.com/v2/usage?auth_key=VALID_TOKEN
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: post
5
- uri: https://api.deepl.com/v1/translate?auth_key=VALID_TOKEN
5
+ uri: https://api.deepl.com/v2/translate?auth_key=VALID_TOKEN
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: text=Sample+text&source_lang=EN&target_lang=ES
@@ -40,7 +40,7 @@ http_interactions:
40
40
  recorded_at: Tue, 08 May 2018 16:31:34 GMT
41
41
  - request:
42
42
  method: post
43
- uri: https://api.deepl.com/v1/translate?auth_key=VALID_TOKEN
43
+ uri: https://api.deepl.com/v2/translate?auth_key=VALID_TOKEN
44
44
  body:
45
45
  encoding: US-ASCII
46
46
  string: text=Sample&text=Word&source_lang=EN&target_lang=ES
@@ -77,7 +77,7 @@ http_interactions:
77
77
  recorded_at: Tue, 08 May 2018 16:31:35 GMT
78
78
  - request:
79
79
  method: post
80
- uri: https://api.deepl.com/v1/translate?auth_key=VALID_TOKEN
80
+ uri: https://api.deepl.com/v2/translate?auth_key=VALID_TOKEN
81
81
  body:
82
82
  encoding: US-ASCII
83
83
  string: text=%3Cp%3ESample+text%3C%2Fp%3E&source_lang=EN&target_lang=ES
@@ -115,7 +115,7 @@ http_interactions:
115
115
  recorded_at: Tue, 08 May 2018 16:31:36 GMT
116
116
  - request:
117
117
  method: post
118
- uri: https://api.deepl.com/v1/translate?auth_key=invalid
118
+ uri: https://api.deepl.com/v2/translate?auth_key=invalid
119
119
  body:
120
120
  encoding: US-ASCII
121
121
  string: text=Sample+text&source_lang=EN&target_lang=ES
@@ -148,7 +148,7 @@ http_interactions:
148
148
  recorded_at: Tue, 08 May 2018 16:31:37 GMT
149
149
  - request:
150
150
  method: post
151
- uri: https://api.deepl.com/v1/translate?auth_key=VALID_TOKEN
151
+ uri: https://api.deepl.com/v2/translate?auth_key=VALID_TOKEN
152
152
  body:
153
153
  encoding: US-ASCII
154
154
  string: source_lang=EN&target_lang=ES
@@ -181,7 +181,7 @@ http_interactions:
181
181
  recorded_at: Tue, 08 May 2018 16:31:37 GMT
182
182
  - request:
183
183
  method: post
184
- uri: https://api.deepl.com/v1/translate?auth_key=VALID_TOKEN
184
+ uri: https://api.deepl.com/v2/translate?auth_key=VALID_TOKEN
185
185
  body:
186
186
  encoding: US-ASCII
187
187
  string: text=Sample+text&source_lang=EN
@@ -214,7 +214,7 @@ http_interactions:
214
214
  recorded_at: Tue, 08 May 2018 16:31:37 GMT
215
215
  - request:
216
216
  method: post
217
- uri: https://api.deepl.com/v1/translate?auth_key=VALID_TOKEN&ignore_tags=code,%20span
217
+ uri: https://api.deepl.com/v2/translate?auth_key=VALID_TOKEN&ignore_tags=code,%20span
218
218
  body:
219
219
  encoding: US-ASCII
220
220
  string: text=Welcome+and+%3Ccode%3EHello+great+World%3C%2Fcode%3E+Good+Morning%21&source_lang=EN&target_lang=ES
@@ -2,7 +2,7 @@
2
2
  http_interactions:
3
3
  - request:
4
4
  method: get
5
- uri: https://api.deepl.com/v1/usage?auth_key=VALID_TOKEN
5
+ uri: https://api.deepl.com/v2/usage?auth_key=VALID_TOKEN
6
6
  body:
7
7
  encoding: US-ASCII
8
8
  string: ''
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.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Herzog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-24 00:00:00.000000000 Z
11
+ date: 2018-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: juwelier