owly 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/owly.rb +6 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00728cdb23752a98a713b096bd10e9d8147c5fad
|
4
|
+
data.tar.gz: 6dc646847e856c56d0d3f2b2c86795579e799b74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad51327d1cd45398d2e4f01b17a5dd00a26c8cdd6705188b5561bc5c53febe05b759c2aa3376d5a089c34ac13b3bc6925958470509831476522001db0638dab0
|
7
|
+
data.tar.gz: 679ca2c13e190b639e327ffc5ce4da283954fb052f7cd014351ec4fefb941ff060f510501f5ca7cd98823e8bc361408a1e1139d7e374d0b75d358d67cddfb3a4
|
data/lib/owly.rb
CHANGED
@@ -3,10 +3,14 @@ require 'json'
|
|
3
3
|
|
4
4
|
module Owly
|
5
5
|
class Shortener
|
6
|
-
def self.shorten(key, url)
|
6
|
+
def self.shorten(key, url, options={})
|
7
7
|
response = HTTParty.get("http://ow.ly/api/1.1/url/shorten?apiKey=#{key}&longUrl=#{url}")
|
8
8
|
json = JSON.parse(response.body)
|
9
|
-
|
9
|
+
shortUrl = CGI::unescape(json['results']['shortUrl'])
|
10
|
+
if options[:base_url]
|
11
|
+
shortUrl = shortUrl.sub('http://ow.ly', options[:base_url])
|
12
|
+
end
|
13
|
+
return shortUrl
|
10
14
|
end
|
11
15
|
end
|
12
16
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: owly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam England
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|