oxford_dictionary 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78ec18e159b5cbee6d642ed69123ce7478c2d578c9a8cac8ebc87462eb9f44fe
4
- data.tar.gz: fd8b47b41a3693f5dcd55c9fa97b260ae9278405a12b596ad3fd9276b2e7ab1c
3
+ metadata.gz: 1b30f885cc09faf1783a64f1b666103936d066373b0a8f2382750d1710fbe2a4
4
+ data.tar.gz: 9e7bb4ee4e9d066c30dcf062085159218b0540db781130ca400227bd65157725
5
5
  SHA512:
6
- metadata.gz: 1e6eeb2e17ceb1be3473863ac38a94f44a0f4f4ae6101a31ccf00504d84d90380484c51a33e3e20f066dae77a70840930c334165b4689848bb27b92701d0e7e0
7
- data.tar.gz: 1d57ef61a92b985d85d8ca5be8890852c8c734c7dea76f9e96c6761a03d01c15b0f1f5bf8ff58af0137138d4aad98897efedf9e8c40849597a1de0b1449df4c6
6
+ metadata.gz: 30b60f3fceb455902872b749b61a7c9676d6962343051234d30d08414f43f98440a10d9c6a75029676d09bc5b7f8984874fb13573d94b0992ba2dc16c13a8302
7
+ data.tar.gz: 7a69d03c0cab8929e9e30191d4662123823d8dd1d63be2e2a80bdb74f7aa30f5075fbbba16c9e14b41874ff05e00b82960092f41486072ed77b489ef2d44b40a
@@ -3,13 +3,13 @@
3
3
  ## OxfordDictionary 1.3.0 (2019-06-22)
4
4
 
5
5
  - Add V2 translations support
6
- [\#10](https://github.com/swcraig/oxford-dictionary/pull/12)
6
+ [\#12](https://github.com/swcraig/oxford-dictionary/pull/12)
7
7
  - Add V2 sentences support
8
- [\#10](https://github.com/swcraig/oxford-dictionary/pull/13)
8
+ [\#13](https://github.com/swcraig/oxford-dictionary/pull/13)
9
9
  - Add V2 thesaurus support
10
- [\#10](https://github.com/swcraig/oxford-dictionary/pull/14)
10
+ [\#14](https://github.com/swcraig/oxford-dictionary/pull/14)
11
11
  - Add V2 search support
12
- [\#10](https://github.com/swcraig/oxford-dictionary/pull/15)
12
+ [\#15](https://github.com/swcraig/oxford-dictionary/pull/15)
13
13
 
14
14
  ## OxfordDictionary 1.2.0 (2019-06-22)
15
15
 
@@ -10,6 +10,8 @@ require 'oxford_dictionary/endpoints/sentences'
10
10
  require 'oxford_dictionary/endpoints/thesaurus'
11
11
  require 'oxford_dictionary/endpoints/search'
12
12
 
13
+ require 'oxford_dictionary/request'
14
+
13
15
  module OxfordDictionary
14
16
  # The client object to interact with
15
17
  class Client
@@ -12,6 +12,12 @@ module OxfordDictionary
12
12
  def deserialize
13
13
  @deserialize ||= OxfordDictionary::Deserialize.new
14
14
  end
15
+
16
+ def request_uri(path:, params:)
17
+ URI(path).tap do |uri|
18
+ uri.query = URI.encode_www_form(params) unless params.empty?
19
+ end
20
+ end
15
21
  end
16
22
  end
17
23
  end
@@ -7,24 +7,16 @@ module OxfordDictionary
7
7
  ENDPOINT = 'entries'.freeze
8
8
 
9
9
  def entry(word:, dataset:, params: {})
10
- query_string = "#{ENDPOINT}/#{dataset}/#{word}"
11
- uri = URI(query_string)
12
-
13
- unless params.empty?
14
- uri.query = URI.encode_www_form(params)
15
- end
10
+ path = "#{ENDPOINT}/#{dataset}/#{word}"
11
+ uri = request_uri(path: path, params: params)
16
12
 
17
13
  response = @request_client.get(uri: uri)
18
14
  deserialize.call(response.body)
19
15
  end
20
16
 
21
17
  def entry_snake_case(word:, dataset:, params: {})
22
- query_string = "#{ENDPOINT}/#{dataset}/#{word}"
23
- uri = URI(query_string)
24
-
25
- unless params.empty?
26
- uri.query = URI.encode_www_form(params)
27
- end
18
+ path = "#{ENDPOINT}/#{dataset}/#{word}"
19
+ uri = request_uri(path: path, params: params)
28
20
 
29
21
  response = @request_client.get(uri: uri)
30
22
  snake_keys = JSON.parse(response.body).to_snake_keys
@@ -6,12 +6,8 @@ module OxfordDictionary
6
6
  ENDPOINT = 'lemmas'.freeze
7
7
 
8
8
  def lemma(word:, language:, params: {})
9
- query_string = "#{ENDPOINT}/#{language}/#{word}"
10
- uri = URI(query_string)
11
-
12
- unless params.empty?
13
- uri.query = URI.encode_www_form(params)
14
- end
9
+ path = "#{ENDPOINT}/#{language}/#{word}"
10
+ uri = request_uri(path: path, params: params)
15
11
 
16
12
  response = @request_client.get(uri: uri)
17
13
  deserialize.call(response.body)
@@ -6,25 +6,16 @@ module OxfordDictionary
6
6
  ENDPOINT = 'search'.freeze
7
7
 
8
8
  def search(language:, params: {})
9
- query_string = "#{ENDPOINT}/#{language}"
10
- uri = URI(query_string)
11
-
12
- unless params.empty?
13
- uri.query = URI.encode_www_form(params)
14
- end
9
+ path = "#{ENDPOINT}/#{language}"
10
+ uri = request_uri(path: path, params: params)
15
11
 
16
12
  response = @request_client.get(uri: uri)
17
13
  deserialize.call(response.body)
18
14
  end
19
15
 
20
16
  def search_translation(source_language:, target_language:, params: {})
21
- query_string =
22
- "#{ENDPOINT}/translations/#{source_language}/#{target_language}"
23
- uri = URI(query_string)
24
-
25
- unless params.empty?
26
- uri.query = URI.encode_www_form(params)
27
- end
17
+ path = "#{ENDPOINT}/translations/#{source_language}/#{target_language}"
18
+ uri = request_uri(path: path, params: params)
28
19
 
29
20
  response = @request_client.get(uri: uri)
30
21
  deserialize.call(response.body)
@@ -6,12 +6,8 @@ module OxfordDictionary
6
6
  ENDPOINT = 'sentences'.freeze
7
7
 
8
8
  def sentence(word:, language:, params: {})
9
- query_string = "#{ENDPOINT}/#{language}/#{word}"
10
- uri = URI(query_string)
11
-
12
- unless params.empty?
13
- uri.query = URI.encode_www_form(params)
14
- end
9
+ path = "#{ENDPOINT}/#{language}/#{word}"
10
+ uri = request_uri(path: path, params: params)
15
11
 
16
12
  response = @request_client.get(uri: uri)
17
13
  deserialize.call(response.body)
@@ -6,12 +6,8 @@ module OxfordDictionary
6
6
  ENDPOINT = 'thesaurus'.freeze
7
7
 
8
8
  def thesaurus(word:, language:, params: {})
9
- query_string = "#{ENDPOINT}/#{language}/#{word}"
10
- uri = URI(query_string)
11
-
12
- unless params.empty?
13
- uri.query = URI.encode_www_form(params)
14
- end
9
+ path = "#{ENDPOINT}/#{language}/#{word}"
10
+ uri = request_uri(path: path, params: params)
15
11
 
16
12
  response = @request_client.get(uri: uri)
17
13
  deserialize.call(response.body)
@@ -6,13 +6,8 @@ module OxfordDictionary
6
6
  ENDPOINT = 'translations'.freeze
7
7
 
8
8
  def translation(word:, source_language:, target_language:, params: {})
9
- query_string =
10
- "#{ENDPOINT}/#{source_language}/#{target_language}/#{word}"
11
- uri = URI(query_string)
12
-
13
- unless params.empty?
14
- uri.query = URI.encode_www_form(params)
15
- end
9
+ path = "#{ENDPOINT}/#{source_language}/#{target_language}/#{word}"
10
+ uri = request_uri(path: path, params: params)
16
11
 
17
12
  response = @request_client.get(uri: uri)
18
13
  deserialize.call(response.body)
@@ -1,3 +1,3 @@
1
1
  module OxfordDictionary
2
- VERSION = '1.3.0'.freeze
2
+ VERSION = '1.3.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oxford_dictionary
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - swcraig
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-06-23 00:00:00.000000000 Z
11
+ date: 2019-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler