shortly 0.2.6 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.textile +20 -4
- data/VERSION +1 -0
- data/bin/shortly +21 -5
- data/lib/shortly.rb +7 -1
- data/lib/shortly/client.rb +16 -3
- data/lib/shortly/clients/bitly.rb +14 -7
- data/lib/shortly/clients/googl.rb +36 -3
- data/lib/shortly/clients/isgd.rb +2 -2
- data/lib/shortly/clients/tinyurl.rb +2 -2
- data/lib/shortly/clients/vgd.rb +33 -0
- data/lib/shortly/helper.rb +24 -3
- data/spec/shortly_spec.rb +71 -27
- metadata +30 -14
data/README.textile
CHANGED
@@ -29,13 +29,20 @@ Optionally you can set apiKey and login beforehand (it would be more DRY i think
|
|
29
29
|
*Goo.gl*
|
30
30
|
|
31
31
|
@googl = Shortly::Clients::Googl@
|
32
|
-
@googl.shorten('http://justatest.com').
|
32
|
+
@googl.shorten('http://justatest.com').shortUrl@
|
33
|
+
@googl.expand('http://goo.gl/shrt').longUrl@
|
34
|
+
@googl.analytics('http://goo.gl/shrt').analytics@
|
33
35
|
|
34
36
|
*Is.gd*
|
35
37
|
|
36
38
|
@isgd = Shortly::Clients::Isgd@
|
37
39
|
@isgd.shorten('http://justatest.com').shorturl@
|
38
40
|
|
41
|
+
*V.gd*
|
42
|
+
|
43
|
+
@vgd = Shortly::Clients::Vgd@
|
44
|
+
@vgd.shorten('http://justatest.com').shorturl@
|
45
|
+
|
39
46
|
*Tinyurl.com*
|
40
47
|
|
41
48
|
@tinyurl = Shortly::Clients::Tinyurl@
|
@@ -52,10 +59,19 @@ By default it uses Googl to short urls but you can specify which service to use.
|
|
52
59
|
here are options and there possible values:
|
53
60
|
|
54
61
|
| *Options* | *What value do they take* |
|
55
|
-
| -s or --service | Service to use(e.g. bitly, isgd(default)) |
|
56
|
-
| -m or --method | Method to use(e.g. expand or shorten(default)) |
|
62
|
+
| -s or --service | Service to use(e.g. bitly, isgd(default googl)) |
|
63
|
+
| -m or --method | Method to use(e.g. expand or shorten or analytics(default shorten)) |
|
57
64
|
| -l or --login | Login credential(required for bitly) |
|
58
|
-
| -p or --apiKey | API Key credentials (for bitly only) |
|
65
|
+
| -p or --apiKey | API Key credentials (for bitly and googl(optional) only) |
|
66
|
+
|
67
|
+
h5. Some more examples:
|
68
|
+
|
69
|
+
* Google analytics
|
70
|
+
@shortly 'http://averylong.url/that/can/frustate?you=many×=true' -p my_api_key -m analytics@
|
71
|
+
spits formatted json at CLI
|
72
|
+
|
73
|
+
* Bitly
|
74
|
+
@shortly 'http://bit.ly/shrt -s bitly -p my_api_key -l my_login -m expand@
|
59
75
|
|
60
76
|
h2. More Info
|
61
77
|
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.3.0
|
data/bin/shortly
CHANGED
@@ -5,6 +5,7 @@ STDOUT.sync = true
|
|
5
5
|
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
|
6
6
|
|
7
7
|
require 'rubygems'
|
8
|
+
require 'json'
|
8
9
|
require 'optparse'
|
9
10
|
require 'shortly'
|
10
11
|
|
@@ -13,16 +14,17 @@ ORIG_ARGV = ARGV.dup
|
|
13
14
|
services = {
|
14
15
|
:googl => Shortly::Clients::Googl,
|
15
16
|
:isgd => Shortly::Clients::Isgd,
|
17
|
+
:vgd => Shortly::Clients::Vgd,
|
16
18
|
:bitly => Shortly::Clients::Bitly,
|
17
19
|
:tinyurl => Shortly::Clients::Tinyurl
|
18
20
|
}
|
19
21
|
|
20
|
-
options = {:service => :googl, :method => :shorten}
|
22
|
+
options = {:service => :googl, :method => :shorten} #defaults to be used
|
21
23
|
|
22
24
|
opts = OptionParser.new do |opts|
|
23
25
|
opts.banner = <<-EOS
|
24
26
|
Usage:
|
25
|
-
shortly url -s service -m method -l login -p apikey
|
27
|
+
shortly url [-s service] [-m method] [-l login] [-p apikey]
|
26
28
|
|
27
29
|
Options:
|
28
30
|
EOS
|
@@ -55,7 +57,7 @@ end
|
|
55
57
|
opts.parse!
|
56
58
|
|
57
59
|
if options[:version]
|
58
|
-
abort("
|
60
|
+
abort("Shortly: v" + Shortly.version)
|
59
61
|
end
|
60
62
|
|
61
63
|
options[:url] = ARGV.first if ARGV.length == 1
|
@@ -80,9 +82,23 @@ end
|
|
80
82
|
response = command.send(options[:method], options[:url])
|
81
83
|
|
82
84
|
output = case options[:service]
|
83
|
-
when :bitly
|
84
|
-
|
85
|
+
when :bitly
|
86
|
+
case options[:method]
|
87
|
+
when :shorten
|
88
|
+
response.url
|
89
|
+
else response.long_url
|
90
|
+
end
|
91
|
+
when :googl
|
92
|
+
case options[:method]
|
93
|
+
when :shorten
|
94
|
+
response.shortUrl
|
95
|
+
when :expand
|
96
|
+
response.longUrl
|
97
|
+
else
|
98
|
+
response.analytics.to_json
|
99
|
+
end
|
85
100
|
when :isgd then response.shorturl
|
101
|
+
when :vgd then response.shorturl
|
86
102
|
when :tinyurl then response.shorturl
|
87
103
|
else abort("Something went wrong. Please raise an issue on Github")
|
88
104
|
end
|
data/lib/shortly.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'uri'
|
2
2
|
require 'ostruct'
|
3
|
+
require 'json'
|
3
4
|
require 'httparty'
|
4
5
|
require 'shortly'
|
5
6
|
require 'shortly/helper'
|
@@ -9,15 +10,20 @@ require 'shortly/clients/bitly'
|
|
9
10
|
require 'shortly/clients/googl'
|
10
11
|
require 'shortly/clients/isgd'
|
11
12
|
require 'shortly/clients/tinyurl'
|
13
|
+
require 'shortly/clients/vgd'
|
12
14
|
|
13
15
|
module Shortly
|
14
16
|
|
15
|
-
|
17
|
+
#gem version
|
18
|
+
def self.version #:nodoc
|
16
19
|
File.read(File.join(File.dirname(__FILE__), '..', 'VERSION'))
|
17
20
|
end
|
18
21
|
|
22
|
+
#returns active services
|
19
23
|
def self.active_services
|
20
24
|
Client.registered
|
21
25
|
end
|
22
26
|
|
27
|
+
Helper::MonkeyPatches.activate!
|
28
|
+
|
23
29
|
end
|
data/lib/shortly/client.rb
CHANGED
@@ -31,24 +31,37 @@ module Shortly
|
|
31
31
|
|
32
32
|
@@registered = []
|
33
33
|
|
34
|
-
def self.method_missing(method_sym, *params)
|
34
|
+
def self.method_missing(method_sym, *params) #:nodoc
|
35
35
|
raise MethodNotAvailableError.new("Sorry, #{method_sym} method is not implemented/available for this service.")
|
36
36
|
end
|
37
37
|
|
38
38
|
protected
|
39
39
|
|
40
|
-
def self.register!
|
40
|
+
def self.register! #:nodoc
|
41
41
|
@@registered = [] unless @@registered
|
42
42
|
@@registered << self.name.to_sym
|
43
43
|
end
|
44
44
|
|
45
|
-
def self.registered
|
45
|
+
def self.registered #:nodoc
|
46
46
|
@@registered
|
47
47
|
end
|
48
48
|
|
49
|
+
def self.validate_uri!(url)
|
50
|
+
raise InvalidURIError.new("provided URI is invalid.") unless valid_uri?(url)
|
51
|
+
end
|
52
|
+
|
53
|
+
#returns a uri is valid or not
|
49
54
|
def self.valid_uri?(url)
|
50
55
|
!!(url =~ URI::regexp)
|
51
56
|
end
|
52
57
|
|
58
|
+
def self.post_params(options = {})
|
59
|
+
{:body => options}
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.get_params(options = {})
|
63
|
+
{:query => options}
|
64
|
+
end
|
65
|
+
|
53
66
|
end
|
54
67
|
end
|
@@ -37,26 +37,33 @@ module Shortly
|
|
37
37
|
|
38
38
|
#shorts provided url by making call to bitly api with given options.
|
39
39
|
def self.shorten(url, options = {})
|
40
|
-
|
41
|
-
options = {:login => self.login, :apiKey => self.apiKey
|
42
|
-
|
40
|
+
validate_uri!(url)
|
41
|
+
options = {:login => self.login, :apiKey => self.apiKey,:longUrl => url, :format => "json"}.merge(options)
|
42
|
+
validate!(options)
|
43
|
+
response = get("/v3/shorten", get_params(options))
|
43
44
|
OpenStruct.new(response["data"])
|
44
45
|
end
|
45
46
|
|
46
47
|
#expands provided url by making call to bitly api with given options.
|
47
|
-
def self.expand(short_url, options ={})
|
48
|
-
|
48
|
+
def self.expand(short_url, options = {})
|
49
|
+
validate_uri!(short_url)
|
49
50
|
options = {:login => self.login, :apiKey => self.apiKey, :shortUrl => short_url, :format => "json"}.merge(options)
|
50
|
-
response = get("/v3/expand",
|
51
|
+
response = get("/v3/expand", get_params(options))
|
51
52
|
OpenStruct.new(response["data"]["expand"].first)
|
52
53
|
end
|
53
54
|
|
54
55
|
#validates given login(as x_login) and apiKey (as x_api_key)
|
55
56
|
#options = {:x_login => xlogin, :x_api_key => x_api_key, :apiKey => apiKey, :login => login, :format => "json"}
|
56
57
|
def self.validate(options = {})
|
57
|
-
response = get("/v3/validate",
|
58
|
+
response = get("/v3/validate", get_params(options))
|
58
59
|
OpenStruct.new(response["data"])
|
59
60
|
end
|
61
|
+
|
62
|
+
private
|
63
|
+
|
64
|
+
def self.validate!(options)
|
65
|
+
raise NotAuthorizedError.new("Credentials required(login and apiKey)") unless options.authenticable?
|
66
|
+
end
|
60
67
|
|
61
68
|
end
|
62
69
|
|
@@ -26,12 +26,45 @@ module Shortly
|
|
26
26
|
class Googl < Client
|
27
27
|
|
28
28
|
self.register!
|
29
|
-
|
29
|
+
class << self
|
30
|
+
#apiKey = "<your apiKey>"
|
31
|
+
attr_accessor :apiKey
|
32
|
+
end
|
33
|
+
|
34
|
+
base_uri 'https://www.googleapis.com' #'goo.gl/api/shorten'
|
35
|
+
headers "Content-Type" => "application/json"
|
30
36
|
|
31
37
|
#shorts provided url by making call to goo.gl api with given options.
|
32
38
|
def self.shorten(url, options = {})
|
33
|
-
|
34
|
-
response = post(
|
39
|
+
validate_uri!(url)
|
40
|
+
response = post(relative_path_with_key(options), post_params({:longUrl => url}.to_json))
|
41
|
+
OpenStruct.new(response.merge(:shortUrl => response["id"]))
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.expand(url, options ={})
|
45
|
+
validate_uri!(url)
|
46
|
+
info(options.merge(:shortUrl => url))
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.analytics(url, options ={})
|
50
|
+
validate_uri!(url)
|
51
|
+
info(options.merge(:shortUrl => url), true)
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def self.relative_path
|
57
|
+
"/urlshortener/v1/url"
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.relative_path_with_key(options)
|
61
|
+
self.apiKey ? [relative_path, {:key => self.apiKey}.to_params].join("?") : relative_path
|
62
|
+
end
|
63
|
+
|
64
|
+
def self.info(options, full = false)
|
65
|
+
options.merge!({:projection => 'FULL'}) if full
|
66
|
+
options.merge!({:key => self.apiKey}) if !!self.apiKey
|
67
|
+
response = get(relative_path, get_params(options))
|
35
68
|
OpenStruct.new(response)
|
36
69
|
end
|
37
70
|
|
data/lib/shortly/clients/isgd.rb
CHANGED
@@ -30,9 +30,9 @@ module Shortly
|
|
30
30
|
|
31
31
|
#shorts provided url by making call to is.gd api with given options.
|
32
32
|
def self.shorten(url, options = {})
|
33
|
-
|
33
|
+
validate_uri!(url)
|
34
34
|
options = {:format => "json", :url => url}.merge(options)
|
35
|
-
response = get("/create.php",
|
35
|
+
response = get("/create.php", get_params(options))
|
36
36
|
OpenStruct.new(response)
|
37
37
|
end
|
38
38
|
|
@@ -30,8 +30,8 @@ module Shortly
|
|
30
30
|
|
31
31
|
#shorts provided url by making call to tinyurl api with given options.
|
32
32
|
def self.shorten(url, options = {})
|
33
|
-
|
34
|
-
response = post("/api-create.php", {:
|
33
|
+
validate_uri!(url)
|
34
|
+
response = post("/api-create.php", post_params({:url => url})).chomp
|
35
35
|
OpenStruct.new({:shorturl => response})
|
36
36
|
end
|
37
37
|
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# Copyright (c) 2011 Bagwan Pankaj
|
2
|
+
#
|
3
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
# a copy of this software and associated documentation files (the
|
5
|
+
# "Software"), to deal in the Software without restriction, including
|
6
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
# the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be
|
12
|
+
# included in all copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
21
|
+
|
22
|
+
module Shortly
|
23
|
+
|
24
|
+
module Clients
|
25
|
+
|
26
|
+
class Vgd < Isgd
|
27
|
+
|
28
|
+
self.register!
|
29
|
+
base_uri 'v.gd'
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/shortly/helper.rb
CHANGED
@@ -23,10 +23,31 @@ module Shortly
|
|
23
23
|
|
24
24
|
module Helper
|
25
25
|
|
26
|
-
|
26
|
+
module MonkeyPatches
|
27
27
|
|
28
|
-
def
|
29
|
-
|
28
|
+
def self.activate!
|
29
|
+
Hash.send(:include, MonkeyHash)
|
30
|
+
Object.send(:include, MonkeyObject)
|
31
|
+
end
|
32
|
+
|
33
|
+
module MonkeyHash
|
34
|
+
|
35
|
+
def authenticable?
|
36
|
+
[:login, :apiKey].all?{|k| self.key?(k)} && !self.values.any?(&:blank?)
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
module MonkeyObject
|
42
|
+
|
43
|
+
def blank?
|
44
|
+
instance_of? Array ? empty? : nil?
|
45
|
+
end
|
46
|
+
|
47
|
+
def present?
|
48
|
+
!blank?
|
49
|
+
end
|
50
|
+
|
30
51
|
end
|
31
52
|
|
32
53
|
end
|
data/spec/shortly_spec.rb
CHANGED
@@ -5,99 +5,143 @@ describe "Shortly" do
|
|
5
5
|
#tests for client googl
|
6
6
|
describe "Googl" do
|
7
7
|
before(:all) do
|
8
|
-
@long_url = "http://bagwanpankaj.com"
|
8
|
+
@long_url = "http://bagwanpankaj.com/"
|
9
9
|
@invalid_url = "bagwanpankaj.com"
|
10
|
+
@short_url = "http://goo.gl/17pbM"
|
11
|
+
@googl = Shortly::Clients::Googl
|
10
12
|
end
|
11
13
|
|
12
14
|
it "should get a short url from googl(provided valid url)" do
|
13
|
-
res =
|
14
|
-
res.
|
15
|
-
res.
|
15
|
+
res = @googl.shorten(@long_url)
|
16
|
+
res.shortUrl.should_not be_empty
|
17
|
+
res.shortUrl.should == @short_url
|
16
18
|
end
|
17
19
|
|
18
|
-
it "result should be an instance of OpenStruct" do
|
19
|
-
res =
|
20
|
+
it "result of shorten should be an instance of OpenStruct" do
|
21
|
+
res = @googl.shorten(@long_url)
|
22
|
+
res.should be_an_instance_of(OpenStruct)
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should get a long url back for given valid short url" do
|
26
|
+
res = @googl.expand(@short_url)
|
27
|
+
res.longUrl.should_not be_empty
|
28
|
+
res.longUrl.should == @long_url
|
29
|
+
end
|
30
|
+
|
31
|
+
it "result of expand should be an instance of OpenStruct" do
|
32
|
+
res = @googl.expand(@short_url)
|
20
33
|
res.should be_an_instance_of(OpenStruct)
|
21
34
|
end
|
22
35
|
|
23
|
-
it "should
|
24
|
-
res =
|
25
|
-
res.
|
36
|
+
it "should give analytics for given short url" do
|
37
|
+
res = @googl.analytics(@short_url)
|
38
|
+
res.analytics.should_not be_empty
|
39
|
+
res.analytics.should be_an_instance_of(Hash)
|
26
40
|
end
|
27
41
|
|
28
42
|
it "should throw an error on wrong uri format" do
|
29
43
|
lambda do
|
30
|
-
|
44
|
+
@googl.shorten(@invalid_url)
|
31
45
|
end.should raise_error(Shortly::Errors::InvalidURIError)
|
32
46
|
end
|
33
47
|
|
34
|
-
it "should raise MethodNotAvailableError if method is not implemented for" do
|
35
|
-
lambda do
|
36
|
-
Shortly::Clients::Googl.expand(@long_url)
|
37
|
-
end.should raise_error(Shortly::Errors::MethodNotAvailableError)
|
38
|
-
end
|
39
48
|
end
|
40
49
|
|
41
50
|
#tests for client isgd
|
42
51
|
describe "Isgd" do
|
43
52
|
before(:all) do
|
53
|
+
@isgd = Shortly::Clients::Isgd
|
44
54
|
@long_url = "http://bagwanpankaj.com"
|
45
55
|
@invalid_url = "bagwanpankaj.com"
|
46
56
|
end
|
47
57
|
|
48
58
|
it "should get a short url from Is.gd(provided valid url)" do
|
49
|
-
res =
|
59
|
+
res = @isgd.shorten(@long_url)
|
50
60
|
res.shorturl.should_not be_empty
|
51
|
-
|
61
|
+
res.shorturl.should == @isgd.shorten(@long_url).shorturl
|
52
62
|
end
|
53
63
|
|
54
64
|
it "result should be an instance of OpenStruct" do
|
55
|
-
res =
|
65
|
+
res = @isgd.shorten(@long_url)
|
56
66
|
res.should be_an_instance_of(OpenStruct)
|
57
67
|
end
|
58
68
|
|
59
69
|
it "should throw an error on wrong uri format" do
|
60
70
|
lambda do
|
61
|
-
|
71
|
+
@isgd.shorten(@invalid_url)
|
62
72
|
end.should raise_error(Shortly::Errors::InvalidURIError)
|
63
73
|
end
|
64
74
|
|
65
75
|
it "should raise MethodNotAvailableError if method is not implemented for" do
|
66
76
|
lambda do
|
67
|
-
|
77
|
+
@isgd.expand(@long_url)
|
68
78
|
end.should raise_error(Shortly::Errors::MethodNotAvailableError)
|
69
79
|
end
|
70
80
|
end
|
71
81
|
|
82
|
+
#tests for client vgd
|
83
|
+
describe "Vgd" do
|
84
|
+
before(:all) do
|
85
|
+
@vgd = Shortly::Clients::Vgd
|
86
|
+
@long_url = "http://bagwanpankaj.com"
|
87
|
+
@invalid_url = "bagwanpankaj.com"
|
88
|
+
end
|
89
|
+
|
90
|
+
it "should get a short url from Is.gd(provided valid url)" do
|
91
|
+
res = @vgd.shorten(@long_url)
|
92
|
+
res.shorturl.should_not be_empty
|
93
|
+
res.shorturl.should == @vgd.shorten(@long_url).shorturl
|
94
|
+
end
|
95
|
+
|
96
|
+
it "result should be an instance of OpenStruct" do
|
97
|
+
res = @vgd.shorten(@long_url)
|
98
|
+
res.should be_an_instance_of(OpenStruct)
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should throw an error on wrong uri format" do
|
102
|
+
lambda do
|
103
|
+
@vgd.shorten(@invalid_url)
|
104
|
+
end.should raise_error(Shortly::Errors::InvalidURIError)
|
105
|
+
end
|
106
|
+
|
107
|
+
it "should raise MethodNotAvailableError if method is not implemented for" do
|
108
|
+
lambda do
|
109
|
+
@vgd.expand(@long_url)
|
110
|
+
end.should raise_error(Shortly::Errors::MethodNotAvailableError)
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
72
114
|
#tests for client bitly
|
73
115
|
describe "Bitly" do
|
74
116
|
|
75
117
|
before(:all) do
|
76
|
-
Shortly::Clients::Bitly
|
77
|
-
|
118
|
+
@bitly = Shortly::Clients::Bitly
|
119
|
+
@bitly.login = "modulo9"
|
120
|
+
@bitly.apiKey = "R_0f17f32f11de7e3e953de49c6f255104"
|
78
121
|
@long_url = "http://bagwanpankaj.com"
|
79
122
|
@invalid_url = "bagwanpankaj.com"
|
123
|
+
@short_url = "http://bit.ly/dUdiIJ"
|
80
124
|
end
|
81
125
|
|
82
126
|
it "should get a short url from googl(provided valid url)" do
|
83
|
-
res =
|
127
|
+
res = @bitly.shorten(@long_url)
|
84
128
|
res.url.should_not be_empty
|
85
|
-
res.url.should ==
|
129
|
+
res.url.should == @short_url
|
86
130
|
end
|
87
131
|
|
88
132
|
it "result should be an instance of OpenStruct" do
|
89
|
-
res =
|
133
|
+
res = @bitly.shorten(@long_url)
|
90
134
|
res.should be_an_instance_of(OpenStruct)
|
91
135
|
end
|
92
136
|
|
93
137
|
it "should throw an error on wrong uri format" do
|
94
138
|
lambda do
|
95
|
-
|
139
|
+
@bitly.shorten(@invalid_url)
|
96
140
|
end.should raise_error(Shortly::Errors::InvalidURIError)
|
97
141
|
end
|
98
142
|
|
99
143
|
it "should expand a given short url" do
|
100
|
-
res =
|
144
|
+
res = @bitly.expand("http://bit.ly/dUdiIJ")
|
101
145
|
res.long_url.should == @long_url
|
102
146
|
end
|
103
147
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shortly
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Bagwan Pankaj
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-22 00:00:00 +05:30
|
19
19
|
default_executable: shortly
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -32,11 +32,25 @@ dependencies:
|
|
32
32
|
- 0
|
33
33
|
version: "0"
|
34
34
|
requirement: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
name: json
|
39
|
+
version_requirements: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 3
|
45
|
+
segments:
|
46
|
+
- 0
|
47
|
+
version: "0"
|
48
|
+
requirement: *id002
|
35
49
|
- !ruby/object:Gem::Dependency
|
36
50
|
type: :development
|
37
51
|
prerelease: false
|
38
52
|
name: rspec
|
39
|
-
version_requirements: &
|
53
|
+
version_requirements: &id003 !ruby/object:Gem::Requirement
|
40
54
|
none: false
|
41
55
|
requirements:
|
42
56
|
- - ~>
|
@@ -47,12 +61,12 @@ dependencies:
|
|
47
61
|
- 1
|
48
62
|
- 0
|
49
63
|
version: 2.1.0
|
50
|
-
requirement: *
|
64
|
+
requirement: *id003
|
51
65
|
- !ruby/object:Gem::Dependency
|
52
66
|
type: :development
|
53
67
|
prerelease: false
|
54
68
|
name: bundler
|
55
|
-
version_requirements: &
|
69
|
+
version_requirements: &id004 !ruby/object:Gem::Requirement
|
56
70
|
none: false
|
57
71
|
requirements:
|
58
72
|
- - ~>
|
@@ -63,12 +77,12 @@ dependencies:
|
|
63
77
|
- 0
|
64
78
|
- 0
|
65
79
|
version: 1.0.0
|
66
|
-
requirement: *
|
80
|
+
requirement: *id004
|
67
81
|
- !ruby/object:Gem::Dependency
|
68
82
|
type: :development
|
69
83
|
prerelease: false
|
70
84
|
name: jeweler
|
71
|
-
version_requirements: &
|
85
|
+
version_requirements: &id005 !ruby/object:Gem::Requirement
|
72
86
|
none: false
|
73
87
|
requirements:
|
74
88
|
- - ~>
|
@@ -79,12 +93,12 @@ dependencies:
|
|
79
93
|
- 5
|
80
94
|
- 1
|
81
95
|
version: 1.5.1
|
82
|
-
requirement: *
|
96
|
+
requirement: *id005
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
type: :development
|
85
99
|
prerelease: false
|
86
100
|
name: rcov
|
87
|
-
version_requirements: &
|
101
|
+
version_requirements: &id006 !ruby/object:Gem::Requirement
|
88
102
|
none: false
|
89
103
|
requirements:
|
90
104
|
- - ">="
|
@@ -93,7 +107,7 @@ dependencies:
|
|
93
107
|
segments:
|
94
108
|
- 0
|
95
109
|
version: "0"
|
96
|
-
requirement: *
|
110
|
+
requirement: *id006
|
97
111
|
description: Ruby Wrapper for different Url Shortner Services Ruby Wrapper
|
98
112
|
email: bagwanpankaj@gmail.com
|
99
113
|
executables:
|
@@ -104,6 +118,8 @@ extra_rdoc_files:
|
|
104
118
|
- LICENSE.txt
|
105
119
|
- README.textile
|
106
120
|
files:
|
121
|
+
- LICENSE.txt
|
122
|
+
- VERSION
|
107
123
|
- bin/shortly
|
108
124
|
- lib/shortly.rb
|
109
125
|
- lib/shortly/client.rb
|
@@ -112,9 +128,9 @@ files:
|
|
112
128
|
- lib/shortly/clients/isgd.rb
|
113
129
|
- lib/shortly/clients/rubyurl.rb
|
114
130
|
- lib/shortly/clients/tinyurl.rb
|
131
|
+
- lib/shortly/clients/vgd.rb
|
115
132
|
- lib/shortly/errors.rb
|
116
133
|
- lib/shortly/helper.rb
|
117
|
-
- LICENSE.txt
|
118
134
|
- README.textile
|
119
135
|
- spec/shortly_spec.rb
|
120
136
|
- spec/spec_helper.rb
|