Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

… when then get encoded.
  • Loading branch information...
commit 05c388dc72895cd0719a030269cf9c54966d6f2c 1 parent 0b55797
@jnunemaker authored
View
8 examples/rubyurl.rb
@@ -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
2  examples/twitter.rb
@@ -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
3  examples/whoismyrep.rb
@@ -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
2  lib/core_extensions.rb
@@ -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|
Please sign in to comment.
Something went wrong with that request. Please try again.