look-bitly-api 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{bitly-api}
5
- s.version = "0.1.0"
5
+ s.version = "0.1.1"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Ole Riesenberg"]
@@ -4,8 +4,9 @@ $:.unshift(File.dirname(__FILE__)) unless
4
4
  require 'rubygems'
5
5
  require 'httpclient'
6
6
  require 'json'
7
+ require 'cgi'
7
8
  require 'bitly-api/bitly-api'
8
9
 
9
10
  module BitlyApi
10
- VERSION = '0.1.0'
11
+ VERSION = '0.1.1'
11
12
  end
@@ -17,8 +17,9 @@ module BitlyApi
17
17
  @httpclient = HTTPClient.new
18
18
  end
19
19
 
20
+ # shorten +long_url+. +long_url+ is CGI escaped, so you shouldn't escape it yourself.
20
21
  def shorten(long_url)
21
- http_response = @httpclient.get_content(build_url("shorten", "longUrl=#{long_url}"))
22
+ http_response = @httpclient.get_content(build_url("shorten", "longUrl=#{CGI::escape(long_url)}"))
22
23
  data = JSON.parse(http_response)
23
24
  raise BitlyError.new(data["errorMessage"]) unless data["statusCode"] == "OK"
24
25
  data["results"][long_url]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: look-bitly-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ole Riesenberg