wordnik 0.3.7 → 0.3.8

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- wordnik (0.3.6)
4
+ wordnik (0.3.8)
5
5
  activemodel (>= 3.0.3)
6
6
  addressable (>= 2.2.4)
7
7
  htmlentities (>= 4.2.4)
@@ -89,9 +89,10 @@ module Wordnik
89
89
  def query_string_params(obfuscated=false)
90
90
  qsp = {}
91
91
  self.params.each_pair do |key, value|
92
- next if self.path.include? "{#{key}}"
93
- next if value.blank?
94
- value = "YOUR_API_KEY" if key.to_sym == :api_key && obfuscated
92
+ next if self.path.include? "{#{key}}" # skip path params
93
+ next if value.blank? # skip empties
94
+ value = "YOUR_API_KEY" if key.to_sym == :api_key && obfuscated # obscure the API key
95
+ key = key.to_s.camelize(:lower).to_sym unless key.to_sym == :api_key # api_key is not a camelCased param
95
96
  qsp[key] = value.to_s
96
97
  end
97
98
  qsp
@@ -25,9 +25,9 @@ module Wordnik
25
25
  # TODO: If body is XML, parse it
26
26
  # Otherwise return raw string
27
27
  def body
28
- JSON.parse(raw.body)
28
+ JSON.parse raw.body.encode(::Encoding::UTF_8, undef: :replace)
29
29
  rescue
30
- raw.body
30
+ raw.body.encode(::Encoding::UTF_8, undef: :replace)
31
31
  end
32
32
 
33
33
  def headers
@@ -1,3 +1,3 @@
1
1
  module Wordnik
2
- VERSION = "0.3.7"
2
+ VERSION = "0.3.8"
3
3
  end
data/spec/request_spec.rb CHANGED
@@ -133,7 +133,15 @@ describe Wordnik::Request do
133
133
  @request.url_with_query_string.should =~ /\?limit=100/
134
134
  end
135
135
 
136
- it "camelCases parameters"
136
+ it "camelCases parameters" do
137
+ @request = Wordnik::Request.new(@default_http_method, @default_path, @default_params.merge({
138
+ :params => {
139
+ :bad_dog => 'bud',
140
+ :goodDog => "dud"
141
+ }
142
+ }))
143
+ @request.query_string.should == "?badDog=bud&goodDog=dud"
144
+ end
137
145
 
138
146
  end
139
147
 
@@ -52,6 +52,15 @@ describe Wordnik::Response do
52
52
  @response.pretty_body.should =~ /\{.*\}/
53
53
  end
54
54
 
55
+ it "has a pretty XML body even in the face of adverse characters" do
56
+ configure_wordnik
57
+ VCR.use_cassette('crazier_json_request', :record => :new_episodes) do
58
+ # @request = Wordnik::Request.new(:get, "word.xml/cat/definitions", :params => {:source_dictionaries => "century"})
59
+ @request = Wordnik::Request.new(:get, "word.xml/hero/pronunciations", :params => {:limit => 1})
60
+ end
61
+ @request.response.pretty_body.should =~ /\?xml/
62
+ end
63
+
55
64
  it "has a pretty xml body" do
56
65
  VCR.use_cassette('xml_response_request', :record => :new_episodes) do
57
66
  @raw = Typhoeus::Request.get("http://api.wordnik.com/v4/word.xml/help")
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: wordnik
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.7
5
+ version: 0.3.8
6
6
  platform: ruby
7
7
  authors:
8
8
  - Zeke Sikelianos