wordnik 4.06.10 → 4.06.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. data/.gitignore +2 -1
  2. data/Gemfile.lock +23 -22
  3. data/README.md +14 -5
  4. data/api_docs/account.json +1 -1
  5. data/api_docs/analytics.json +1 -1
  6. data/api_docs/corpus.json +1 -1
  7. data/api_docs/document.json +1 -1
  8. data/api_docs/feeds.json +1 -0
  9. data/api_docs/glossary.json +1 -1
  10. data/api_docs/suggest.json +1 -1
  11. data/api_docs/system.json +1 -1
  12. data/api_docs/tag.json +1 -1
  13. data/api_docs/user.json +1 -1
  14. data/api_docs/users.json +1 -1
  15. data/api_docs/word.json +1 -1
  16. data/api_docs/wordList.json +1 -1
  17. data/api_docs/wordLists.json +1 -1
  18. data/api_docs/words.json +1 -1
  19. data/lib/wordnik.rb +8 -2
  20. data/lib/wordnik/configuration.rb +10 -4
  21. data/lib/wordnik/request.rb +20 -33
  22. data/lib/wordnik/resource_modules/corpus.rb +2 -2
  23. data/lib/wordnik/resource_modules/glossary.rb +33 -35
  24. data/lib/wordnik/resource_modules/word.rb +27 -27
  25. data/lib/wordnik/resource_modules/words.rb +2 -2
  26. data/lib/wordnik/response.rb +5 -5
  27. data/lib/wordnik/version.rb +1 -1
  28. data/spec/operation_parameter_spec.rb +0 -4
  29. data/spec/request_spec.rb +1 -1
  30. data/spec/resource_spec.rb +1 -1
  31. data/spec/response_spec.rb +2 -2
  32. data/spec/spec_helper.rb +4 -3
  33. data/wordnik.gemspec +2 -2
  34. metadata +105 -127
  35. data/spec/vcr/crazier_json_request.yml +0 -31
  36. data/spec/vcr/default_response.yml +0 -25
  37. data/spec/vcr/get_dog_images.yml +0 -21
  38. data/spec/vcr/get_word_dynamo.yml +0 -33
  39. data/spec/vcr/unauthorized_response.yml +0 -25
  40. data/spec/vcr/word_resource.yml +0 -25
  41. data/spec/vcr/wordnik_authenticate.yml +0 -31
  42. data/spec/vcr/wordnik_authenticate_fail.yml +0 -172
  43. data/spec/vcr/xml_response_request.yml +0 -25
@@ -411,33 +411,6 @@ module WordMethods
411
411
  request_only ? request : request.response.body
412
412
  end
413
413
 
414
- # Return related words (thesaurus data) for a word
415
- #
416
- def get_related_words(word, *args)
417
- http_method = :get
418
- path = '/word/{word}/related'
419
- path.sub!('{word}', word.to_s)
420
-
421
- # Ruby turns all key-value arguments at the end into a single hash
422
- # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
423
- # becomes {:limit => 10, :part_of_speech => 'verb'}
424
- last_arg = args.pop if args.last.is_a?(Hash)
425
- last_arg = args.pop if args.last.is_a?(Array)
426
- last_arg ||= {}
427
-
428
- # Look for a kwarg called :request_only, whose presence indicates
429
- # that we want the request itself back, not the response body
430
- if last_arg.is_a?(Hash) && last_arg[:request_only].present?
431
- request_only = true
432
- last_arg.delete(:request_only)
433
- end
434
-
435
- params = last_arg
436
- body ||= {}
437
- request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
438
- request_only ? request : request.response.body
439
- end
440
-
441
414
  # Returns WordLists containing a word
442
415
  #
443
416
  def get_listed_in(word, *args)
@@ -1086,6 +1059,33 @@ module WordMethods
1086
1059
  request_only ? request : request.response.body
1087
1060
  end
1088
1061
 
1062
+ # Return related words (thesaurus data) for a word
1063
+ #
1064
+ def get_related(word, *args)
1065
+ http_method = :get
1066
+ path = '/word/{word}/related'
1067
+ path.sub!('{word}', word.to_s)
1068
+
1069
+ # Ruby turns all key-value arguments at the end into a single hash
1070
+ # e.g. Wordnik.word.get_examples('dingo', :limit => 10, :part_of_speech => 'verb')
1071
+ # becomes {:limit => 10, :part_of_speech => 'verb'}
1072
+ last_arg = args.pop if args.last.is_a?(Hash)
1073
+ last_arg = args.pop if args.last.is_a?(Array)
1074
+ last_arg ||= {}
1075
+
1076
+ # Look for a kwarg called :request_only, whose presence indicates
1077
+ # that we want the request itself back, not the response body
1078
+ if last_arg.is_a?(Hash) && last_arg[:request_only].present?
1079
+ request_only = true
1080
+ last_arg.delete(:request_only)
1081
+ end
1082
+
1083
+ params = last_arg
1084
+ body ||= {}
1085
+ request = Wordnik::Request.new(http_method, path, :params => params, :body => body)
1086
+ request_only ? request : request.response.body
1087
+ end
1088
+
1089
1089
  # Fetches etymology data
1090
1090
  #
1091
1091
  def get_etymologies(word, *args)
@@ -239,7 +239,7 @@ module WordsMethods
239
239
  request_only ? request : request.response.body
240
240
  end
241
241
 
242
- # Returns an array of random WordObjects, in the format specified by the URL
242
+ # Returns an array of random WordObjects
243
243
  #
244
244
  def get_random_words(*args)
245
245
  http_method = :get
@@ -265,7 +265,7 @@ module WordsMethods
265
265
  request_only ? request : request.response.body
266
266
  end
267
267
 
268
- # Returns a single random WordObject, in the format specified by the URL
268
+ # Returns a single random WordObject
269
269
  #
270
270
  def get_random_word(*args)
271
271
  http_method = :get
@@ -50,23 +50,23 @@ module Wordnik
50
50
  # Extract the response format from the header hash
51
51
  # e.g. {'Content-Type' => 'application/json'}
52
52
  def format
53
- headers['Content-Type'].split("/").last.to_sym
53
+ headers['Content-Type'].split("/").last.to_s
54
54
  end
55
55
 
56
56
  def json?
57
- format == :json
57
+ format == 'json'
58
58
  end
59
59
 
60
60
  def xml?
61
- format == :xml
61
+ format == 'xml'
62
62
  end
63
63
 
64
64
  def pretty_body
65
65
  return unless body.present?
66
66
  case format
67
- when :json
67
+ when 'json'
68
68
  JSON.pretty_generate(body).gsub(/\n/, '<br/>')
69
- when :xml
69
+ when 'xml'
70
70
  xsl = Nokogiri::XSLT(File.open(File.join(File.dirname(__FILE__), "../../config/pretty_print.xsl")))
71
71
  xml = Nokogiri(body)
72
72
  coder = HTMLEntities.new
@@ -1,4 +1,4 @@
1
1
  module Wordnik
2
- VERSION = "4.06.10"
2
+ VERSION = "4.06.11"
3
3
  end
4
4
 
@@ -28,10 +28,6 @@ describe Wordnik::OperationParameter do
28
28
  end
29
29
  end
30
30
 
31
- it "has an array of allowable values" do
32
- @operation_parameter.allowable_values.should be_an(Array)
33
- end
34
-
35
31
  it "is required if it's a path param" do
36
32
  @operation_parameter.should_receive(:required).and_return(false)
37
33
  @operation_parameter.should_receive(:param_type).and_return('path')
data/spec/request_spec.rb CHANGED
@@ -13,7 +13,7 @@ describe Wordnik::Request do
13
13
 
14
14
  describe "initialization" do
15
15
  it "sets default response format to json" do
16
- @request.format.should == :json
16
+ @request.format.should == 'json'
17
17
  end
18
18
 
19
19
  it "allows params to be nil" do
@@ -50,7 +50,7 @@ describe Wordnik::Resource do
50
50
  @response_body = Wordnik.word.get_word('dynamo')
51
51
  end
52
52
  @response_body.class.should == Hash
53
- @response_body.keys.sort.should == %w(canonicalForm word)
53
+ @response_body.keys.sort.should == %w(canonicalForm id word)
54
54
  end
55
55
 
56
56
  it "allows the same auto-generated method to be called with different parameters" do
@@ -39,7 +39,7 @@ describe Wordnik::Response do
39
39
  describe "format" do
40
40
 
41
41
  it "recognizes json" do
42
- @response.format.should == :json
42
+ @response.format.should == 'json'
43
43
  @response.json?.should == true
44
44
  end
45
45
 
@@ -48,7 +48,7 @@ describe Wordnik::Response do
48
48
  @raw = Typhoeus::Request.get("http://localhost:8001/admin/api/word.xml")
49
49
  end
50
50
  @response = Wordnik::Response.new(@raw)
51
- @response.format.should == :xml
51
+ @response.format.should == 'xml'
52
52
  @response.xml?.should == true
53
53
  end
54
54
 
data/spec/spec_helper.rb CHANGED
@@ -18,9 +18,9 @@ end
18
18
 
19
19
  def help
20
20
  puts "\nOh noes! You gotta stuff your wordnik credentials in ~/.wordnik.yml like so:\n\n"
21
- puts "api_key: '12345abcdefg'"
22
- puts "username: 'fumanchu'"
23
- puts "password: 'kalamazoo'\n\n"
21
+ puts "api_key: '12345abcdefg' (required)"
22
+ puts "username: 'fumanchu' (optional)"
23
+ puts "password: 'kalamazoo' (optional)\n\n"
24
24
  exit
25
25
  end
26
26
 
@@ -39,6 +39,7 @@ def configure_wordnik
39
39
  config.api_key = CREDENTIALS[:api_key]
40
40
  config.username = CREDENTIALS[:username]
41
41
  config.password = CREDENTIALS[:password]
42
+ config.logger = Logger.new('/dev/null')
42
43
 
43
44
  # Normal..
44
45
  # config.host = 'beta.wordnik.com'
data/wordnik.gemspec CHANGED
@@ -21,8 +21,8 @@ Gem::Specification.new do |s|
21
21
  s.add_dependency 'activemodel', '>=3.0.3'
22
22
  s.add_dependency 'json', '>=1.4.6'
23
23
 
24
- s.add_development_dependency 'rspec', '>=2.5.0'
25
- s.add_development_dependency 'vcr', '>=1.5.1'
24
+ s.add_development_dependency 'rspec', '~> 2.7.0'
25
+ s.add_development_dependency 'vcr', '~> 1.11.3'
26
26
  s.add_development_dependency 'webmock', '>=1.6.2'
27
27
  s.add_development_dependency 'autotest'
28
28
  s.add_development_dependency 'autotest-rails-pure'
metadata CHANGED
@@ -1,150 +1,148 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: wordnik
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 4.06.11
4
5
  prerelease:
5
- version: 4.06.10
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Zeke Sikelianos
9
9
  - John McGrath
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
-
14
- date: 2011-10-27 00:00:00 Z
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
13
+ date: 2011-12-03 00:00:00.000000000Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
17
16
  name: typhoeus
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
17
+ requirement: &70209736540900 !ruby/object:Gem::Requirement
20
18
  none: false
21
- requirements:
22
- - - ">="
23
- - !ruby/object:Gem::Version
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
24
22
  version: 0.2.1
25
23
  type: :runtime
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: htmlentities
29
24
  prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
25
+ version_requirements: *70209736540900
26
+ - !ruby/object:Gem::Dependency
27
+ name: htmlentities
28
+ requirement: &70209736540400 !ruby/object:Gem::Requirement
31
29
  none: false
32
- requirements:
33
- - - ">="
34
- - !ruby/object:Gem::Version
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
35
33
  version: 4.2.4
36
34
  type: :runtime
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: addressable
40
35
  prerelease: false
41
- requirement: &id003 !ruby/object:Gem::Requirement
36
+ version_requirements: *70209736540400
37
+ - !ruby/object:Gem::Dependency
38
+ name: addressable
39
+ requirement: &70209736539940 !ruby/object:Gem::Requirement
42
40
  none: false
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
46
44
  version: 2.2.4
47
45
  type: :runtime
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
50
- name: nokogiri
51
46
  prerelease: false
52
- requirement: &id004 !ruby/object:Gem::Requirement
47
+ version_requirements: *70209736539940
48
+ - !ruby/object:Gem::Dependency
49
+ name: nokogiri
50
+ requirement: &70209736539480 !ruby/object:Gem::Requirement
53
51
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
52
+ requirements:
53
+ - - ! '>='
54
+ - !ruby/object:Gem::Version
57
55
  version: 1.4.4
58
56
  type: :runtime
59
- version_requirements: *id004
60
- - !ruby/object:Gem::Dependency
61
- name: activemodel
62
57
  prerelease: false
63
- requirement: &id005 !ruby/object:Gem::Requirement
58
+ version_requirements: *70209736539480
59
+ - !ruby/object:Gem::Dependency
60
+ name: activemodel
61
+ requirement: &70209736539020 !ruby/object:Gem::Requirement
64
62
  none: false
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
63
+ requirements:
64
+ - - ! '>='
65
+ - !ruby/object:Gem::Version
68
66
  version: 3.0.3
69
67
  type: :runtime
70
- version_requirements: *id005
71
- - !ruby/object:Gem::Dependency
72
- name: json
73
68
  prerelease: false
74
- requirement: &id006 !ruby/object:Gem::Requirement
69
+ version_requirements: *70209736539020
70
+ - !ruby/object:Gem::Dependency
71
+ name: json
72
+ requirement: &70209736538560 !ruby/object:Gem::Requirement
75
73
  none: false
76
- requirements:
77
- - - ">="
78
- - !ruby/object:Gem::Version
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
79
77
  version: 1.4.6
80
78
  type: :runtime
81
- version_requirements: *id006
82
- - !ruby/object:Gem::Dependency
83
- name: rspec
84
79
  prerelease: false
85
- requirement: &id007 !ruby/object:Gem::Requirement
80
+ version_requirements: *70209736538560
81
+ - !ruby/object:Gem::Dependency
82
+ name: rspec
83
+ requirement: &70209736538100 !ruby/object:Gem::Requirement
86
84
  none: false
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- version: 2.5.0
85
+ requirements:
86
+ - - ~>
87
+ - !ruby/object:Gem::Version
88
+ version: 2.7.0
91
89
  type: :development
92
- version_requirements: *id007
93
- - !ruby/object:Gem::Dependency
94
- name: vcr
95
90
  prerelease: false
96
- requirement: &id008 !ruby/object:Gem::Requirement
91
+ version_requirements: *70209736538100
92
+ - !ruby/object:Gem::Dependency
93
+ name: vcr
94
+ requirement: &70209736537640 !ruby/object:Gem::Requirement
97
95
  none: false
98
- requirements:
99
- - - ">="
100
- - !ruby/object:Gem::Version
101
- version: 1.5.1
96
+ requirements:
97
+ - - ~>
98
+ - !ruby/object:Gem::Version
99
+ version: 1.11.3
102
100
  type: :development
103
- version_requirements: *id008
104
- - !ruby/object:Gem::Dependency
105
- name: webmock
106
101
  prerelease: false
107
- requirement: &id009 !ruby/object:Gem::Requirement
102
+ version_requirements: *70209736537640
103
+ - !ruby/object:Gem::Dependency
104
+ name: webmock
105
+ requirement: &70209736537180 !ruby/object:Gem::Requirement
108
106
  none: false
109
- requirements:
110
- - - ">="
111
- - !ruby/object:Gem::Version
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
112
110
  version: 1.6.2
113
111
  type: :development
114
- version_requirements: *id009
115
- - !ruby/object:Gem::Dependency
116
- name: autotest
117
112
  prerelease: false
118
- requirement: &id010 !ruby/object:Gem::Requirement
113
+ version_requirements: *70209736537180
114
+ - !ruby/object:Gem::Dependency
115
+ name: autotest
116
+ requirement: &70209736536800 !ruby/object:Gem::Requirement
119
117
  none: false
120
- requirements:
121
- - - ">="
122
- - !ruby/object:Gem::Version
123
- version: "0"
118
+ requirements:
119
+ - - ! '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
124
122
  type: :development
125
- version_requirements: *id010
126
- - !ruby/object:Gem::Dependency
127
- name: autotest-rails-pure
128
123
  prerelease: false
129
- requirement: &id011 !ruby/object:Gem::Requirement
124
+ version_requirements: *70209736536800
125
+ - !ruby/object:Gem::Dependency
126
+ name: autotest-rails-pure
127
+ requirement: &70209736536340 !ruby/object:Gem::Requirement
130
128
  none: false
131
- requirements:
132
- - - ">="
133
- - !ruby/object:Gem::Version
134
- version: "0"
129
+ requirements:
130
+ - - ! '>='
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
135
133
  type: :development
136
- version_requirements: *id011
137
- description: This gem provides a simple interface to the entire Wordnik API. Its methods are defined by the documentation that comes from the API itself, so it's guaranteed to be up to date.
138
- email:
134
+ prerelease: false
135
+ version_requirements: *70209736536340
136
+ description: This gem provides a simple interface to the entire Wordnik API. Its methods
137
+ are defined by the documentation that comes from the API itself, so it's guaranteed
138
+ to be up to date.
139
+ email:
139
140
  - zeke@wordnik.com
140
141
  - john@wordnik.com
141
142
  executables: []
142
-
143
143
  extensions: []
144
-
145
144
  extra_rdoc_files: []
146
-
147
- files:
145
+ files:
148
146
  - .gitignore
149
147
  - .rspec
150
148
  - .rspec-tm
@@ -157,6 +155,7 @@ files:
157
155
  - api_docs/analytics.json
158
156
  - api_docs/corpus.json
159
157
  - api_docs/document.json
158
+ - api_docs/feeds.json
160
159
  - api_docs/glossary.json
161
160
  - api_docs/suggest.json
162
161
  - api_docs/system.json
@@ -201,45 +200,33 @@ files:
201
200
  - spec/response_spec.rb
202
201
  - spec/spec.opts
203
202
  - spec/spec_helper.rb
204
- - spec/vcr/crazier_json_request.yml
205
- - spec/vcr/default_response.yml
206
- - spec/vcr/get_dog_images.yml
207
- - spec/vcr/get_word_dynamo.yml
208
- - spec/vcr/unauthorized_response.yml
209
- - spec/vcr/word_resource.yml
210
- - spec/vcr/wordnik_authenticate.yml
211
- - spec/vcr/wordnik_authenticate_fail.yml
212
- - spec/vcr/xml_response_request.yml
213
203
  - spec/wordnik_spec.rb
214
204
  - wordnik.gemspec
215
205
  homepage: http://developer.wordnik.com
216
206
  licenses: []
217
-
218
207
  post_install_message:
219
208
  rdoc_options: []
220
-
221
- require_paths:
209
+ require_paths:
222
210
  - lib
223
- required_ruby_version: !ruby/object:Gem::Requirement
211
+ required_ruby_version: !ruby/object:Gem::Requirement
224
212
  none: false
225
- requirements:
226
- - - ">="
227
- - !ruby/object:Gem::Version
228
- version: "0"
229
- required_rubygems_version: !ruby/object:Gem::Requirement
213
+ requirements:
214
+ - - ! '>='
215
+ - !ruby/object:Gem::Version
216
+ version: '0'
217
+ required_rubygems_version: !ruby/object:Gem::Requirement
230
218
  none: false
231
- requirements:
232
- - - ">="
233
- - !ruby/object:Gem::Version
234
- version: "0"
219
+ requirements:
220
+ - - ! '>='
221
+ - !ruby/object:Gem::Version
222
+ version: '0'
235
223
  requirements: []
236
-
237
224
  rubyforge_project: wordnik
238
225
  rubygems_version: 1.8.10
239
226
  signing_key:
240
227
  specification_version: 3
241
228
  summary: A ruby wrapper for the Wordnik API
242
- test_files:
229
+ test_files:
243
230
  - spec/active_support_spec.rb
244
231
  - spec/endpoint_spec.rb
245
232
  - spec/operation_parameter_spec.rb
@@ -249,13 +236,4 @@ test_files:
249
236
  - spec/response_spec.rb
250
237
  - spec/spec.opts
251
238
  - spec/spec_helper.rb
252
- - spec/vcr/crazier_json_request.yml
253
- - spec/vcr/default_response.yml
254
- - spec/vcr/get_dog_images.yml
255
- - spec/vcr/get_word_dynamo.yml
256
- - spec/vcr/unauthorized_response.yml
257
- - spec/vcr/word_resource.yml
258
- - spec/vcr/wordnik_authenticate.yml
259
- - spec/vcr/wordnik_authenticate_fail.yml
260
- - spec/vcr/xml_response_request.yml
261
239
  - spec/wordnik_spec.rb