wordnik 0.4.7 → 4.06.00
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/Gemfile.lock +4 -4
- data/Rakefile +90 -66
- data/api_docs/account.json +1 -1
- data/api_docs/corpus.json +1 -1
- data/api_docs/document.json +1 -1
- data/api_docs/partners.json +1 -1
- data/api_docs/system.json +1 -1
- data/api_docs/tag.json +1 -1
- data/api_docs/user.json +1 -1
- data/api_docs/users.json +1 -1
- data/api_docs/word.json +1 -1
- data/api_docs/wordList.json +1 -1
- data/api_docs/wordLists.json +1 -1
- data/api_docs/words.json +1 -1
- data/lib/wordnik.rb +24 -31
- data/lib/wordnik/configuration.rb +14 -1
- data/lib/wordnik/operation.rb +3 -3
- data/lib/wordnik/operation_parameter.rb +1 -1
- data/lib/wordnik/resource_modules/account.rb +313 -57
- data/lib/wordnik/resource_modules/system.rb +159 -6
- data/lib/wordnik/resource_modules/user.rb +1012 -88
- data/lib/wordnik/resource_modules/word.rb +1087 -134
- data/lib/wordnik/resource_modules/word_list.rb +423 -60
- data/lib/wordnik/resource_modules/word_lists.rb +89 -18
- data/lib/wordnik/resource_modules/words.rb +313 -150
- data/lib/wordnik/response.rb +11 -3
- data/lib/wordnik/version.rb +2 -1
- data/spec/operation_parameter_spec.rb +16 -12
- data/spec/operation_spec.rb +10 -0
- data/spec/resource_spec.rb +1 -56
- data/spec/response_spec.rb +22 -2
- data/spec/spec_helper.rb +1 -0
- data/spec/wordnik_spec.rb +2 -2
- data/wordnik.gemspec +5 -1
- metadata +28 -23
- data/USAGE.md +0 -298
- data/api_docs/wordoftheday.json +0 -1
@@ -3,11 +3,14 @@
|
|
3
3
|
|
4
4
|
module WordListsMethods
|
5
5
|
|
6
|
-
#
|
6
|
+
# Fetches WordList objects by name.
|
7
|
+
# The term supplied is effectively given a wildcard before and after so 'cat' becomes '%cat%'
|
7
8
|
#
|
8
|
-
def
|
9
|
+
def find_by_name(searchString, *args)
|
9
10
|
http_method = :get
|
10
|
-
path = '/wordLists'
|
11
|
+
path = '/wordLists/find/{searchString}'
|
12
|
+
path.sub!('{searchString}', searchString.to_s)
|
13
|
+
|
11
14
|
# Ruby turns all key-value arguments at the end into a single hash
|
12
15
|
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
13
16
|
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
@@ -22,23 +25,44 @@ module WordListsMethods
|
|
22
25
|
last_arg.delete(:request_only)
|
23
26
|
end
|
24
27
|
|
25
|
-
|
26
|
-
|
27
|
-
body = last_arg
|
28
|
-
else
|
29
|
-
params = last_arg
|
30
|
-
body = nil
|
31
|
-
end
|
32
|
-
|
28
|
+
params = last_arg
|
29
|
+
body ||= {}
|
33
30
|
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
34
31
|
request_only ? request : request.response.body
|
35
32
|
end
|
36
33
|
|
37
34
|
# Creates a WordList.
|
38
35
|
#
|
39
|
-
def create_word_list(*args)
|
36
|
+
def create_word_list(body, *args)
|
40
37
|
http_method = :post
|
41
38
|
path = '/wordLists'
|
39
|
+
|
40
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
41
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
42
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
43
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
44
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
45
|
+
last_arg ||= {}
|
46
|
+
|
47
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
48
|
+
# that we want the request itself back, not the response body
|
49
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
50
|
+
request_only = true
|
51
|
+
last_arg.delete(:request_only)
|
52
|
+
end
|
53
|
+
|
54
|
+
params = last_arg
|
55
|
+
body ||= {}
|
56
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
57
|
+
request_only ? request : request.response.body
|
58
|
+
end
|
59
|
+
|
60
|
+
# Returns information about API parameters
|
61
|
+
#
|
62
|
+
def get_help(*args)
|
63
|
+
http_method = :get
|
64
|
+
path = '/wordLists'
|
65
|
+
|
42
66
|
# Ruby turns all key-value arguments at the end into a single hash
|
43
67
|
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
44
68
|
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
@@ -53,14 +77,61 @@ module WordListsMethods
|
|
53
77
|
last_arg.delete(:request_only)
|
54
78
|
end
|
55
79
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
80
|
+
params = last_arg
|
81
|
+
body ||= {}
|
82
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
83
|
+
request_only ? request : request.response.body
|
84
|
+
end
|
85
|
+
|
86
|
+
# Fetches a CommentSummary for WordList objects.
|
87
|
+
# The CommentSummary is sorted by comment count, descending
|
88
|
+
#
|
89
|
+
def find_most_commented_on(*args)
|
90
|
+
http_method = :get
|
91
|
+
path = '/wordLists/mostCommentedOn'
|
92
|
+
|
93
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
94
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
95
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
96
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
97
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
98
|
+
last_arg ||= {}
|
99
|
+
|
100
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
101
|
+
# that we want the request itself back, not the response body
|
102
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
103
|
+
request_only = true
|
104
|
+
last_arg.delete(:request_only)
|
105
|
+
end
|
106
|
+
|
107
|
+
params = last_arg
|
108
|
+
body ||= {}
|
109
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
110
|
+
request_only ? request : request.response.body
|
111
|
+
end
|
112
|
+
|
113
|
+
# Fetches recently created WordList objects.
|
114
|
+
#
|
115
|
+
def find_recent_lists(*args)
|
116
|
+
http_method = :get
|
117
|
+
path = '/wordLists/recentLists'
|
118
|
+
|
119
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
120
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
121
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
122
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
123
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
124
|
+
last_arg ||= {}
|
125
|
+
|
126
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
127
|
+
# that we want the request itself back, not the response body
|
128
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
129
|
+
request_only = true
|
130
|
+
last_arg.delete(:request_only)
|
62
131
|
end
|
63
132
|
|
133
|
+
params = last_arg
|
134
|
+
body ||= {}
|
64
135
|
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
65
136
|
request_only ? request : request.response.body
|
66
137
|
end
|
@@ -3,11 +3,12 @@
|
|
3
3
|
|
4
4
|
module WordsMethods
|
5
5
|
|
6
|
-
#
|
6
|
+
# Searches words.
|
7
7
|
#
|
8
|
-
def
|
8
|
+
def search_words(*args)
|
9
9
|
http_method = :get
|
10
|
-
path = '/words/
|
10
|
+
path = '/words/search'
|
11
|
+
|
11
12
|
# Ruby turns all key-value arguments at the end into a single hash
|
12
13
|
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
13
14
|
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
@@ -22,23 +23,19 @@ module WordsMethods
|
|
22
23
|
last_arg.delete(:request_only)
|
23
24
|
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
body = last_arg
|
28
|
-
else
|
29
|
-
params = last_arg
|
30
|
-
body = nil
|
31
|
-
end
|
32
|
-
|
26
|
+
params = last_arg
|
27
|
+
body ||= {}
|
33
28
|
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
34
29
|
request_only ? request : request.response.body
|
35
30
|
end
|
36
31
|
|
37
|
-
#
|
32
|
+
# Fetches a WordOfTheDayList by ID
|
38
33
|
#
|
39
|
-
def
|
34
|
+
def get_word_of_the_day_list(permalink, *args)
|
40
35
|
http_method = :get
|
41
|
-
path = '/words/
|
36
|
+
path = '/words/wordOfTheDayList/{permalink}'
|
37
|
+
path.sub!('{permalink}', permalink.to_s)
|
38
|
+
|
42
39
|
# Ruby turns all key-value arguments at the end into a single hash
|
43
40
|
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
44
41
|
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
@@ -53,23 +50,18 @@ module WordsMethods
|
|
53
50
|
last_arg.delete(:request_only)
|
54
51
|
end
|
55
52
|
|
56
|
-
|
57
|
-
|
58
|
-
body = last_arg
|
59
|
-
else
|
60
|
-
params = last_arg
|
61
|
-
body = nil
|
62
|
-
end
|
63
|
-
|
53
|
+
params = last_arg
|
54
|
+
body ||= {}
|
64
55
|
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
65
56
|
request_only ? request : request.response.body
|
66
57
|
end
|
67
58
|
|
68
|
-
#
|
59
|
+
# Returns a specific WordOfTheDay
|
69
60
|
#
|
70
|
-
def
|
61
|
+
def get_word_of_the_day(*args)
|
71
62
|
http_method = :get
|
72
|
-
path = '/words/
|
63
|
+
path = '/words/wordOfTheDay'
|
64
|
+
|
73
65
|
# Ruby turns all key-value arguments at the end into a single hash
|
74
66
|
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
75
67
|
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
@@ -84,23 +76,18 @@ module WordsMethods
|
|
84
76
|
last_arg.delete(:request_only)
|
85
77
|
end
|
86
78
|
|
87
|
-
|
88
|
-
|
89
|
-
body = last_arg
|
90
|
-
else
|
91
|
-
params = last_arg
|
92
|
-
body = nil
|
93
|
-
end
|
94
|
-
|
79
|
+
params = last_arg
|
80
|
+
body ||= {}
|
95
81
|
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
96
82
|
request_only ? request : request.response.body
|
97
83
|
end
|
98
84
|
|
99
|
-
#
|
85
|
+
# Returns information about API parameters
|
100
86
|
#
|
101
|
-
def
|
87
|
+
def get_help(*args)
|
102
88
|
http_method = :get
|
103
|
-
path = '/words
|
89
|
+
path = '/words'
|
90
|
+
|
104
91
|
# Ruby turns all key-value arguments at the end into a single hash
|
105
92
|
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
106
93
|
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
@@ -115,24 +102,43 @@ module WordsMethods
|
|
115
102
|
last_arg.delete(:request_only)
|
116
103
|
end
|
117
104
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
105
|
+
params = last_arg
|
106
|
+
body ||= {}
|
107
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
108
|
+
request_only ? request : request.response.body
|
109
|
+
end
|
110
|
+
|
111
|
+
# Searches definitions.
|
112
|
+
#
|
113
|
+
def search_definitions(*args)
|
114
|
+
http_method = :get
|
115
|
+
path = '/words/searchDefinitions'
|
116
|
+
|
117
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
118
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
119
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
120
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
121
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
122
|
+
last_arg ||= {}
|
123
|
+
|
124
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
125
|
+
# that we want the request itself back, not the response body
|
126
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
127
|
+
request_only = true
|
128
|
+
last_arg.delete(:request_only)
|
124
129
|
end
|
125
130
|
|
131
|
+
params = last_arg
|
132
|
+
body ||= {}
|
126
133
|
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
127
134
|
request_only ? request : request.response.body
|
128
135
|
end
|
129
136
|
|
130
|
-
#
|
137
|
+
# Searches dictionary entries.
|
131
138
|
#
|
132
|
-
def
|
139
|
+
def search_entries(*args)
|
133
140
|
http_method = :get
|
134
|
-
path = '/words/
|
135
|
-
path.sub!('{date}', date)
|
141
|
+
path = '/words/searchEntries'
|
136
142
|
|
137
143
|
# Ruby turns all key-value arguments at the end into a single hash
|
138
144
|
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
@@ -148,24 +154,43 @@ module WordsMethods
|
|
148
154
|
last_arg.delete(:request_only)
|
149
155
|
end
|
150
156
|
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
+
params = last_arg
|
158
|
+
body ||= {}
|
159
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
160
|
+
request_only ? request : request.response.body
|
161
|
+
end
|
162
|
+
|
163
|
+
# Fetches corpus-level word frequency
|
164
|
+
#
|
165
|
+
def get_frequency(*args)
|
166
|
+
http_method = :get
|
167
|
+
path = '/words/frequency'
|
168
|
+
|
169
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
170
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
171
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
172
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
173
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
174
|
+
last_arg ||= {}
|
175
|
+
|
176
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
177
|
+
# that we want the request itself back, not the response body
|
178
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
179
|
+
request_only = true
|
180
|
+
last_arg.delete(:request_only)
|
157
181
|
end
|
158
182
|
|
183
|
+
params = last_arg
|
184
|
+
body ||= {}
|
159
185
|
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
160
186
|
request_only ? request : request.response.body
|
161
187
|
end
|
162
188
|
|
163
|
-
#
|
189
|
+
# Fetches surface forms of a word
|
164
190
|
#
|
165
|
-
def
|
166
|
-
http_method = :
|
167
|
-
path = '/words/
|
168
|
-
path.sub!('{permalink}', permalink)
|
191
|
+
def get_surface_forms(*args)
|
192
|
+
http_method = :get
|
193
|
+
path = '/words/surfaceForms'
|
169
194
|
|
170
195
|
# Ruby turns all key-value arguments at the end into a single hash
|
171
196
|
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
@@ -181,23 +206,46 @@ module WordsMethods
|
|
181
206
|
last_arg.delete(:request_only)
|
182
207
|
end
|
183
208
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
209
|
+
params = last_arg
|
210
|
+
body ||= {}
|
211
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
212
|
+
request_only ? request : request.response.body
|
213
|
+
end
|
214
|
+
|
215
|
+
# Fetches a word by ID
|
216
|
+
# Deprecated.
|
217
|
+
#
|
218
|
+
def get_word_by_id(id, *args)
|
219
|
+
http_method = :get
|
220
|
+
path = '/words/id/{id}'
|
221
|
+
path.sub!('{id}', id.to_s)
|
222
|
+
|
223
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
224
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
225
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
226
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
227
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
228
|
+
last_arg ||= {}
|
229
|
+
|
230
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
231
|
+
# that we want the request itself back, not the response body
|
232
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
233
|
+
request_only = true
|
234
|
+
last_arg.delete(:request_only)
|
190
235
|
end
|
191
236
|
|
237
|
+
params = last_arg
|
238
|
+
body ||= {}
|
192
239
|
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
193
240
|
request_only ? request : request.response.body
|
194
241
|
end
|
195
242
|
|
196
|
-
#
|
243
|
+
# Returns a WordOfTheDay range
|
197
244
|
#
|
198
|
-
def
|
245
|
+
def get_word_of_the_day_range(*args)
|
199
246
|
http_method = :get
|
200
|
-
path = '/words/
|
247
|
+
path = '/words/wordOfTheDay/range'
|
248
|
+
|
201
249
|
# Ruby turns all key-value arguments at the end into a single hash
|
202
250
|
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
203
251
|
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
@@ -212,23 +260,45 @@ module WordsMethods
|
|
212
260
|
last_arg.delete(:request_only)
|
213
261
|
end
|
214
262
|
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
263
|
+
params = last_arg
|
264
|
+
body ||= {}
|
265
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
266
|
+
request_only ? request : request.response.body
|
267
|
+
end
|
268
|
+
|
269
|
+
# Fetches canonical forms of a word
|
270
|
+
#
|
271
|
+
def get_canonical_forms(*args)
|
272
|
+
http_method = :get
|
273
|
+
path = '/words/canonicalForms'
|
274
|
+
|
275
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
276
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
277
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
278
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
279
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
280
|
+
last_arg ||= {}
|
281
|
+
|
282
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
283
|
+
# that we want the request itself back, not the response body
|
284
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
285
|
+
request_only = true
|
286
|
+
last_arg.delete(:request_only)
|
221
287
|
end
|
222
288
|
|
289
|
+
params = last_arg
|
290
|
+
body ||= {}
|
223
291
|
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
224
292
|
request_only ? request : request.response.body
|
225
293
|
end
|
226
294
|
|
227
|
-
# Searches
|
295
|
+
# Searches words.
|
228
296
|
#
|
229
|
-
def
|
297
|
+
def search_words_new(query, *args)
|
230
298
|
http_method = :get
|
231
|
-
path = '/words/
|
299
|
+
path = '/words/search/{query}'
|
300
|
+
path.sub!('{query}', query.to_s)
|
301
|
+
|
232
302
|
# Ruby turns all key-value arguments at the end into a single hash
|
233
303
|
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
234
304
|
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
@@ -243,23 +313,44 @@ module WordsMethods
|
|
243
313
|
last_arg.delete(:request_only)
|
244
314
|
end
|
245
315
|
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
316
|
+
params = last_arg
|
317
|
+
body ||= {}
|
318
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
319
|
+
request_only ? request : request.response.body
|
320
|
+
end
|
321
|
+
|
322
|
+
# Returns an array of random WordObjects, in the format specified by the URL
|
323
|
+
#
|
324
|
+
def get_random_words(*args)
|
325
|
+
http_method = :get
|
326
|
+
path = '/words/randomWords'
|
327
|
+
|
328
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
329
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
330
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
331
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
332
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
333
|
+
last_arg ||= {}
|
334
|
+
|
335
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
336
|
+
# that we want the request itself back, not the response body
|
337
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
338
|
+
request_only = true
|
339
|
+
last_arg.delete(:request_only)
|
252
340
|
end
|
253
341
|
|
342
|
+
params = last_arg
|
343
|
+
body ||= {}
|
254
344
|
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
255
345
|
request_only ? request : request.response.body
|
256
346
|
end
|
257
347
|
|
258
|
-
#
|
348
|
+
# Returns a single random WordObject, in the format specified by the URL
|
259
349
|
#
|
260
|
-
def
|
350
|
+
def get_random_word(*args)
|
261
351
|
http_method = :get
|
262
|
-
path = '/words/
|
352
|
+
path = '/words/randomWord'
|
353
|
+
|
263
354
|
# Ruby turns all key-value arguments at the end into a single hash
|
264
355
|
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
265
356
|
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
@@ -274,23 +365,45 @@ module WordsMethods
|
|
274
365
|
last_arg.delete(:request_only)
|
275
366
|
end
|
276
367
|
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
368
|
+
params = last_arg
|
369
|
+
body ||= {}
|
370
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
371
|
+
request_only ? request : request.response.body
|
372
|
+
end
|
373
|
+
|
374
|
+
# Fetches examples for multiple words.
|
375
|
+
#
|
376
|
+
def get_examples_for_words(body, *args)
|
377
|
+
http_method = :post
|
378
|
+
path = '/words/examples'
|
379
|
+
|
380
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
381
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
382
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
383
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
384
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
385
|
+
last_arg ||= {}
|
386
|
+
|
387
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
388
|
+
# that we want the request itself back, not the response body
|
389
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
390
|
+
request_only = true
|
391
|
+
last_arg.delete(:request_only)
|
283
392
|
end
|
284
393
|
|
394
|
+
params = last_arg
|
395
|
+
body ||= {}
|
285
396
|
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
286
397
|
request_only ? request : request.response.body
|
287
398
|
end
|
288
399
|
|
289
|
-
#
|
400
|
+
# Fetches words most commented on.
|
401
|
+
# Set the dayInterval to determine the time frame.
|
290
402
|
#
|
291
|
-
def
|
403
|
+
def get_words_most_commented_on(*args)
|
292
404
|
http_method = :get
|
293
|
-
path = '/words/
|
405
|
+
path = '/words/mostCommentedOn'
|
406
|
+
|
294
407
|
# Ruby turns all key-value arguments at the end into a single hash
|
295
408
|
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
296
409
|
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
@@ -305,23 +418,21 @@ module WordsMethods
|
|
305
418
|
last_arg.delete(:request_only)
|
306
419
|
end
|
307
420
|
|
308
|
-
|
309
|
-
|
310
|
-
body = last_arg
|
311
|
-
else
|
312
|
-
params = last_arg
|
313
|
-
body = nil
|
314
|
-
end
|
315
|
-
|
421
|
+
params = last_arg
|
422
|
+
body ||= {}
|
316
423
|
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
317
424
|
request_only ? request : request.response.body
|
318
425
|
end
|
319
426
|
|
320
|
-
#
|
427
|
+
# Fetches words most commented on.
|
428
|
+
# Set the dayInterval to determine the time frame.
|
321
429
|
#
|
322
|
-
def
|
430
|
+
def get_words_most_commented_on(statsType, object, *args)
|
323
431
|
http_method = :get
|
324
|
-
path = '/words/
|
432
|
+
path = '/words/firstUsed/{statsType}/{object}'
|
433
|
+
path.sub!('{statsType}', statsType.to_s)
|
434
|
+
path.sub!('{object}', object.to_s)
|
435
|
+
|
325
436
|
# Ruby turns all key-value arguments at the end into a single hash
|
326
437
|
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
327
438
|
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
@@ -336,24 +447,45 @@ module WordsMethods
|
|
336
447
|
last_arg.delete(:request_only)
|
337
448
|
end
|
338
449
|
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
450
|
+
params = last_arg
|
451
|
+
body ||= {}
|
452
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
453
|
+
request_only ? request : request.response.body
|
454
|
+
end
|
455
|
+
|
456
|
+
# Invites users to a WordOfTheDayList
|
457
|
+
# A user can invite up to 20 people in a single day. The users being invited will be checked to see if they have opted out of email communications
|
458
|
+
#
|
459
|
+
def invite_to_word_of_the_day_list(permalink, body, *args)
|
460
|
+
http_method = :post
|
461
|
+
path = '/words/wordOfTheDayList/{permalink}/invite'
|
462
|
+
path.sub!('{permalink}', permalink.to_s)
|
463
|
+
|
464
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
465
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
466
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
467
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
468
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
469
|
+
last_arg ||= {}
|
470
|
+
|
471
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
472
|
+
# that we want the request itself back, not the response body
|
473
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
474
|
+
request_only = true
|
475
|
+
last_arg.delete(:request_only)
|
345
476
|
end
|
346
477
|
|
478
|
+
params = last_arg
|
479
|
+
body ||= {}
|
347
480
|
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
348
481
|
request_only ? request : request.response.body
|
349
482
|
end
|
350
483
|
|
351
|
-
# Fetches
|
484
|
+
# Fetches recently created WordOfTheDayLists
|
352
485
|
#
|
353
|
-
def
|
486
|
+
def get_recent_word_of_the_day_lists(*args)
|
354
487
|
http_method = :get
|
355
|
-
path = '/words/
|
356
|
-
path.sub!('{permalink}', permalink)
|
488
|
+
path = '/words/wordOfTheDayLists/recent'
|
357
489
|
|
358
490
|
# Ruby turns all key-value arguments at the end into a single hash
|
359
491
|
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
@@ -369,14 +501,8 @@ module WordsMethods
|
|
369
501
|
last_arg.delete(:request_only)
|
370
502
|
end
|
371
503
|
|
372
|
-
|
373
|
-
|
374
|
-
body = last_arg
|
375
|
-
else
|
376
|
-
params = last_arg
|
377
|
-
body = nil
|
378
|
-
end
|
379
|
-
|
504
|
+
params = last_arg
|
505
|
+
body ||= {}
|
380
506
|
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
381
507
|
request_only ? request : request.response.body
|
382
508
|
end
|
@@ -386,9 +512,8 @@ module WordsMethods
|
|
386
512
|
def get_word_of_the_day_list_item(permalink, specifier, *args)
|
387
513
|
http_method = :get
|
388
514
|
path = '/words/wordOfTheDayList/{permalink}/{specifier}'
|
389
|
-
path.sub!('{permalink}', permalink)
|
390
|
-
|
391
|
-
path.sub!('{specifier}', specifier)
|
515
|
+
path.sub!('{permalink}', permalink.to_s)
|
516
|
+
path.sub!('{specifier}', specifier.to_s)
|
392
517
|
|
393
518
|
# Ruby turns all key-value arguments at the end into a single hash
|
394
519
|
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
@@ -404,23 +529,18 @@ module WordsMethods
|
|
404
529
|
last_arg.delete(:request_only)
|
405
530
|
end
|
406
531
|
|
407
|
-
|
408
|
-
|
409
|
-
body = last_arg
|
410
|
-
else
|
411
|
-
params = last_arg
|
412
|
-
body = nil
|
413
|
-
end
|
414
|
-
|
532
|
+
params = last_arg
|
533
|
+
body ||= {}
|
415
534
|
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
416
535
|
request_only ? request : request.response.body
|
417
536
|
end
|
418
537
|
|
419
|
-
# Fetches
|
538
|
+
# Fetches an array of WordOfTheDayList basd on a criteria
|
420
539
|
#
|
421
|
-
def
|
540
|
+
def get_word_of_the_day_lists_containing_word(*args)
|
422
541
|
http_method = :get
|
423
|
-
path = '/words/wordOfTheDayLists
|
542
|
+
path = '/words/wordOfTheDayLists'
|
543
|
+
|
424
544
|
# Ruby turns all key-value arguments at the end into a single hash
|
425
545
|
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
426
546
|
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
@@ -435,14 +555,8 @@ module WordsMethods
|
|
435
555
|
last_arg.delete(:request_only)
|
436
556
|
end
|
437
557
|
|
438
|
-
|
439
|
-
|
440
|
-
body = last_arg
|
441
|
-
else
|
442
|
-
params = last_arg
|
443
|
-
body = nil
|
444
|
-
end
|
445
|
-
|
558
|
+
params = last_arg
|
559
|
+
body ||= {}
|
446
560
|
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
447
561
|
request_only ? request : request.response.body
|
448
562
|
end
|
@@ -453,6 +567,7 @@ module WordsMethods
|
|
453
567
|
def get_word_of_the_day_list_subscription_process_status(*args)
|
454
568
|
http_method = :get
|
455
569
|
path = '/words/wordOfTheDayLists/subscriptionProcess'
|
570
|
+
|
456
571
|
# Ruby turns all key-value arguments at the end into a single hash
|
457
572
|
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
458
573
|
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
@@ -467,14 +582,62 @@ module WordsMethods
|
|
467
582
|
last_arg.delete(:request_only)
|
468
583
|
end
|
469
584
|
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
585
|
+
params = last_arg
|
586
|
+
body ||= {}
|
587
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
588
|
+
request_only ? request : request.response.body
|
589
|
+
end
|
590
|
+
|
591
|
+
# Subscribes a user to a WordOfTheDayList
|
592
|
+
#
|
593
|
+
def subscribe_to_list(permalink, body, *args)
|
594
|
+
http_method = :post
|
595
|
+
path = '/words/wordOfTheDayList/{permalink}/subscription'
|
596
|
+
path.sub!('{permalink}', permalink.to_s)
|
597
|
+
|
598
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
599
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
600
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
601
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
602
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
603
|
+
last_arg ||= {}
|
604
|
+
|
605
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
606
|
+
# that we want the request itself back, not the response body
|
607
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
608
|
+
request_only = true
|
609
|
+
last_arg.delete(:request_only)
|
610
|
+
end
|
611
|
+
|
612
|
+
params = last_arg
|
613
|
+
body ||= {}
|
614
|
+
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
615
|
+
request_only ? request : request.response.body
|
616
|
+
end
|
617
|
+
|
618
|
+
# Fetches WordOfTheDay objects for a specific date
|
619
|
+
#
|
620
|
+
def get_word_of_the_day_lists_for_date(date, *args)
|
621
|
+
http_method = :get
|
622
|
+
path = '/words/wordOfTheDayLists/{date}'
|
623
|
+
path.sub!('{date}', date.to_s)
|
624
|
+
|
625
|
+
# Ruby turns all key-value arguments at the end into a single hash
|
626
|
+
# e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
|
627
|
+
# becomes {:limit => 10, :part_of_speech => 'verb'}
|
628
|
+
last_arg = args.pop if args.last.is_a?(Hash)
|
629
|
+
last_arg = args.pop if args.last.is_a?(Array)
|
630
|
+
last_arg ||= {}
|
631
|
+
|
632
|
+
# Look for a kwarg called :request_only, whose presence indicates
|
633
|
+
# that we want the request itself back, not the response body
|
634
|
+
if last_arg.is_a?(Hash) && last_arg[:request_only].present?
|
635
|
+
request_only = true
|
636
|
+
last_arg.delete(:request_only)
|
476
637
|
end
|
477
638
|
|
639
|
+
params = last_arg
|
640
|
+
body ||= {}
|
478
641
|
request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
|
479
642
|
request_only ? request : request.response.body
|
480
643
|
end
|