Permalink
Browse files

Added to_s when doing Hash#to_param so that numbers don't throw error…

… when then get encoded.
  • Loading branch information...
jnunemaker committed Dec 7, 2008
1 parent 0b55797 commit 05c388dc72895cd0719a030269cf9c54966d6f2c
Showing with 8 additions and 7 deletions.
  1. +4 −4 examples/rubyurl.rb
  2. +1 −1 examples/twitter.rb
  3. +2 −1 examples/whoismyrep.rb
  4. +1 −1 lib/core_extensions.rb
View
@@ -1,14 +1,14 @@
dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
require File.join(dir, 'httparty')
+require 'pp'
class Rubyurl
include HTTParty
base_uri 'rubyurl.com'
- def self.shorten(website_url)
- xml = post('/api/links.json', :query => {'link[website_url]' => website_url})
- xml['link'] && xml['link']['permalink']
+ def self.shorten( website_url )
+ post( '/api/links.json', :query => { :link => { :website_url => website_url } } )
end
end
-puts Rubyurl.shorten( 'http://istwitterdown.com/' ).inspect
+pp Rubyurl.shorten( 'http://istwitterdown.com/' )
View
@@ -28,4 +28,4 @@ def post(text)
pp twitter.timeline
# pp twitter.timeline(:friends, :query => {:since_id => 868482746})
# pp twitter.timeline(:friends, :query => 'since_id=868482746')
-pp twitter.post('this is a test of 0.2.0')
+# pp twitter.post('this is a test of 0.2.0')
View
@@ -6,4 +6,5 @@ class Rep
include HTTParty
end
-puts Rep.get('http://whoismyrepresentative.com/whoismyrep.php?zip=46544').inspect
+pp Rep.get('http://whoismyrepresentative.com/whoismyrep.php?zip=46544')
+pp Rep.get('http://whoismyrepresentative.com/whoismyrep.php', :query => {:zip => 46544})
View
@@ -322,7 +322,7 @@ def normalize_param(key, value)
elsif value.is_a?(Hash)
stack << [key,value]
else
- param << "#{key}=#{URI.encode(value)}&"
+ param << "#{key}=#{URI.encode(value.to_s)}&"
end
stack.each do |parent, hash|

0 comments on commit 05c388d

Please sign in to comment.