oxford_dictionary 1.3.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +37 -49
- data/fixtures/vcr_cassettes/v1_entry.yml +526 -0
- data/fixtures/vcr_cassettes/v1_entry_antonym_synonym.yml +42 -0
- data/fixtures/vcr_cassettes/v1_entry_antonyms.yml +42 -0
- data/fixtures/vcr_cassettes/v1_entry_definitions.yml +228 -0
- data/fixtures/vcr_cassettes/v1_entry_error.yml +49 -0
- data/fixtures/vcr_cassettes/v1_entry_es.yml +108 -0
- data/fixtures/vcr_cassettes/v1_entry_examples.yml +242 -0
- data/fixtures/vcr_cassettes/v1_entry_past_nouns.yml +49 -0
- data/fixtures/vcr_cassettes/v1_entry_pronunciations.yml +156 -0
- data/fixtures/vcr_cassettes/v1_entry_synonyms.yml +42 -0
- data/fixtures/vcr_cassettes/v1_entry_us.yml +526 -0
- data/fixtures/vcr_cassettes/v1_inflection.yml +74 -0
- data/fixtures/vcr_cassettes/v1_inflection_filters.yml +52 -0
- data/fixtures/vcr_cassettes/v1_search.yml +42 -0
- data/fixtures/vcr_cassettes/v1_search_prefix.yml +42 -0
- data/fixtures/vcr_cassettes/v1_search_translation.yml +42 -0
- data/lib/oxford_dictionary/client.rb +211 -18
- data/lib/oxford_dictionary/version.rb +1 -1
- metadata +19 -16
- data/lib/oxford_dictionary/api_objects/entry.rb +0 -11
- data/lib/oxford_dictionary/api_objects/entry_response.rb +0 -12
- data/lib/oxford_dictionary/api_objects/lexical_entry.rb +0 -16
- data/lib/oxford_dictionary/api_objects/list_response.rb +0 -7
- data/lib/oxford_dictionary/api_objects/pronunciation.rb +0 -10
- data/lib/oxford_dictionary/api_objects/sense.rb +0 -19
- data/lib/oxford_dictionary/deprecated_request.rb +0 -127
- data/lib/oxford_dictionary/endpoints/entry_endpoint.rb +0 -131
- data/lib/oxford_dictionary/endpoints/inflection_endpoint.rb +0 -23
- data/lib/oxford_dictionary/endpoints/search_endpoint.rb +0 -26
- data/lib/oxford_dictionary/endpoints/wordlist_endpoint.rb +0 -35
- data/lib/oxford_dictionary/error.rb +0 -10
@@ -1,131 +0,0 @@
|
|
1
|
-
require 'oxford_dictionary/deprecated_request'
|
2
|
-
require 'oxford_dictionary/api_objects/entry_response'
|
3
|
-
|
4
|
-
module OxfordDictionary
|
5
|
-
module Endpoints
|
6
|
-
# Interface to '/entries' endpoint
|
7
|
-
module EntryEndpoint
|
8
|
-
include OxfordDictionary::DeprecatedRequest
|
9
|
-
ENDPOINT = 'entries'.freeze
|
10
|
-
|
11
|
-
def entry(query, params = {})
|
12
|
-
entry_request(query, params)
|
13
|
-
end
|
14
|
-
|
15
|
-
def entry_definitions(query, params = {})
|
16
|
-
warn '''
|
17
|
-
Client#entry_defintions is DEPRECATED and will become non-functional
|
18
|
-
on June 30, 2019. Use Client#entry instead. Reference
|
19
|
-
https://github.com/swcraig/oxford-dictionary/pull/8 for more
|
20
|
-
information. Check out OxfordDictionary::Endpoints::Entries for the
|
21
|
-
interface to use. Specifically use it with
|
22
|
-
params: { fields: \'definitions\' }
|
23
|
-
'''
|
24
|
-
|
25
|
-
params[:end] = 'definitions'
|
26
|
-
entry_request(query, params)
|
27
|
-
end
|
28
|
-
|
29
|
-
def entry_examples(query, params = {})
|
30
|
-
warn '''
|
31
|
-
Client#entry_examples is DEPRECATED and will become non-functional
|
32
|
-
on June 30, 2019. Use Client#entry instead. Reference
|
33
|
-
https://github.com/swcraig/oxford-dictionary/pull/8 for more
|
34
|
-
information. Check out OxfordDictionary::Endpoints::Entries for the
|
35
|
-
interface to use. Specifically use it with
|
36
|
-
params: { fields: \'examples\' }
|
37
|
-
'''
|
38
|
-
|
39
|
-
params[:end] = 'examples'
|
40
|
-
entry_request(query, params)
|
41
|
-
end
|
42
|
-
|
43
|
-
def entry_pronunciations(query, params = {})
|
44
|
-
warn '''
|
45
|
-
Client#entry_pronunciations is DEPRECATED and will become non-functional
|
46
|
-
on June 30, 2019. Use Client#entry instead. Reference
|
47
|
-
https://github.com/swcraig/oxford-dictionary/pull/8 for more
|
48
|
-
information. Check out OxfordDictionary::Endpoints::Entries for the
|
49
|
-
interface to use. Specifically use it with
|
50
|
-
params: { fields: \'pronunciations\' }
|
51
|
-
'''
|
52
|
-
|
53
|
-
params[:end] = 'pronunciations'
|
54
|
-
entry_request(query, params)
|
55
|
-
end
|
56
|
-
|
57
|
-
def entry_sentences(query, params = {})
|
58
|
-
warn '''
|
59
|
-
Client#entry_sentences is DEPRECATED and will become non-functional
|
60
|
-
on June 30, 2019. Use Client#sentence instead. Reference
|
61
|
-
https://github.com/swcraig/oxford-dictionary/pull/13 for more
|
62
|
-
information. Check out OxfordDictionary::Endpoints::Sentences for the
|
63
|
-
interface to use.
|
64
|
-
'''
|
65
|
-
|
66
|
-
params[:end] = 'sentences'
|
67
|
-
entry_request(query, params)
|
68
|
-
end
|
69
|
-
|
70
|
-
def entry_antonyms(query, params = {})
|
71
|
-
warn '''
|
72
|
-
Client#entry_antonyms is DEPRECATED and will become non-functional
|
73
|
-
on June 30, 2019. Use Client#thesaurus instead. Reference
|
74
|
-
https://github.com/swcraig/oxford-dictionary/pull/13 for more
|
75
|
-
information. Check out OxfordDictionary::Endpoints::Thesaurus for the
|
76
|
-
interface to use. Specifically use it with
|
77
|
-
params: { fields: \'antonyms\' }
|
78
|
-
'''
|
79
|
-
|
80
|
-
params[:end] = 'antonyms'
|
81
|
-
entry_request(query, params)
|
82
|
-
end
|
83
|
-
|
84
|
-
def entry_synonyms(query, params = {})
|
85
|
-
warn '''
|
86
|
-
Client#entry_synonyms is DEPRECATED and will become non-functional
|
87
|
-
on June 30, 2019. Use Client#thesaurus instead. Reference
|
88
|
-
https://github.com/swcraig/oxford-dictionary/pull/13 for more
|
89
|
-
information. Check out OxfordDictionary::Endpoints::Thesaurus for the
|
90
|
-
interface to use. Specifically use it with
|
91
|
-
params: { fields: \'synonyms\' }
|
92
|
-
'''
|
93
|
-
|
94
|
-
params[:end] = 'synonyms'
|
95
|
-
entry_request(query, params)
|
96
|
-
end
|
97
|
-
|
98
|
-
def entry_antonyms_synonyms(query, params = {})
|
99
|
-
warn '''
|
100
|
-
Client#entry_antonyms_synonyms is DEPRECATED and will be non-functional
|
101
|
-
on June 30, 2019. Use Client#thesaurus instead. Reference
|
102
|
-
https://github.com/swcraig/oxford-dictionary/pull/14 for more
|
103
|
-
information. Check out OxfordDictionary::Endpoints::Thesaurus for the
|
104
|
-
interface to use. Specifically use it with
|
105
|
-
params: { fields: \'synonyms,antonyms\' }
|
106
|
-
'''
|
107
|
-
|
108
|
-
params[:end] = 'synonyms;antonyms'
|
109
|
-
entry_request(query, params)
|
110
|
-
end
|
111
|
-
|
112
|
-
def entry_translations(query, params = {})
|
113
|
-
warn '''
|
114
|
-
Client#entry_translations is DEPRECATED and will become non-functional
|
115
|
-
on June 30, 2019. Use Client#translation instead. Reference
|
116
|
-
https://github.com/swcraig/oxford-dictionary/pull/12 for more
|
117
|
-
information. Check out OxfordDictionary::Endpoints::Translations for the
|
118
|
-
interface to use.
|
119
|
-
'''
|
120
|
-
params.key?(:translations) || params[:translations] = 'es'
|
121
|
-
entry_request(query, params)
|
122
|
-
end
|
123
|
-
|
124
|
-
private
|
125
|
-
|
126
|
-
def entry_request(query, params)
|
127
|
-
EntryResponse.new(request(ENDPOINT, query, params)['results'][0])
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
131
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'oxford_dictionary/deprecated_request'
|
2
|
-
require 'oxford_dictionary/api_objects/entry_response'
|
3
|
-
|
4
|
-
module OxfordDictionary
|
5
|
-
module Endpoints
|
6
|
-
# Interface to '/inflections' endpoint
|
7
|
-
module InflectionEndpoint
|
8
|
-
include OxfordDictionary::DeprecatedRequest
|
9
|
-
ENDPOINT = 'inflections'.freeze
|
10
|
-
|
11
|
-
def inflection(query, params = {})
|
12
|
-
warn '''
|
13
|
-
Client#inflection is DEPRECATED and will become non-functional
|
14
|
-
on June 30, 2019. Use Client#lemma instead. Reference
|
15
|
-
github.com/swcraig/oxford-dictionary/pull/10 for for more information.
|
16
|
-
Check out OxfordDictionary::Endpoints::Lemmas#lemma for the interface
|
17
|
-
to use.
|
18
|
-
'''
|
19
|
-
EntryResponse.new(request(ENDPOINT, query, params)['results'][0])
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'oxford_dictionary/deprecated_request'
|
2
|
-
require 'oxford_dictionary/api_objects/list_response'
|
3
|
-
|
4
|
-
module OxfordDictionary
|
5
|
-
module Endpoints
|
6
|
-
# Interface to '/search' endpoint
|
7
|
-
module SearchEndpoint
|
8
|
-
include OxfordDictionary::DeprecatedRequest
|
9
|
-
ENDPOINT = 'search'.freeze
|
10
|
-
|
11
|
-
def search(query, params = {})
|
12
|
-
warn '''
|
13
|
-
Client#search without using named parameters is DEPRECATED and will
|
14
|
-
become non-functional on June 30, 2019 (it uses the V1 interface which
|
15
|
-
Oxford Dictionaries is taking offline). Reference
|
16
|
-
https://github.com/swcraig/oxford-dictionary/pull/15 for more
|
17
|
-
information. Check out OxfordDictionary::Endpoints::Search for the
|
18
|
-
interface to use.
|
19
|
-
'''
|
20
|
-
|
21
|
-
params[:q] = query
|
22
|
-
ListResponse.new(request(ENDPOINT, query, params))
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'oxford_dictionary/deprecated_request'
|
2
|
-
require 'oxford_dictionary/api_objects/list_response'
|
3
|
-
|
4
|
-
module OxfordDictionary
|
5
|
-
module Endpoints
|
6
|
-
# Interface to '/wordlist' endpoint
|
7
|
-
module WordlistEndpoint
|
8
|
-
extend Gem::Deprecate
|
9
|
-
include OxfordDictionary::DeprecatedRequest
|
10
|
-
|
11
|
-
ENDPOINT = 'wordlist'.freeze
|
12
|
-
ADVANCED_FILTERS = [:exact, :exclude, :exclude_senses,
|
13
|
-
:exclude_prime_senses, :limit, :offset,
|
14
|
-
:prefix, :word_length].freeze
|
15
|
-
|
16
|
-
def wordlist(params = {})
|
17
|
-
# Check first so that we don't waste an API call
|
18
|
-
if too_many_filter_values(params)
|
19
|
-
raise(Error.new(400), 'Do not use more than 5 values for a filter')
|
20
|
-
end
|
21
|
-
ListResponse.new(request(ENDPOINT, nil, params))
|
22
|
-
end
|
23
|
-
deprecate :wordlist, :none, 2019, 6
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def too_many_filter_values(params)
|
28
|
-
params.each do |k, v|
|
29
|
-
return true if v.size > 5 && !ADVANCED_FILTERS.include?(k)
|
30
|
-
end
|
31
|
-
false
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|