module ShortURL
Defined in:
shorturl.crshorturl/cli.cr
shorturl/exceptions.cr
shorturl/service.cr
shorturl/services/isgd.cr
shorturl/services/shorl.cr
shorturl/services/tinyurl.cr
shorturl/services/vgd.cr
shorturl/version.cr
Constant Summary
-
SERVICES =
{"isgd" => Services::Isgd.new, "tinyurl" => Services::TinyURL.new, "vgd" => Services::Vgd.new, "shorl" => Services::Shorl.new} -
VERSION =
"0.2.1"
Class Method Summary
-
.all_services
Returns all available shortening services.
-
.expand(short_url : String)
Expands shortened url via http get request.
-
.shorten(url : String, service = :tinyurl)
Shortens an url using one of the available services.
Class Method Detail
def self.all_services
#
Returns all available shortening services.
ShortURL.all_services # => [:isgd, :tinyurl, ...]
def self.expand(short_url : String)
#
Expands shortened url via http get request.
ShortURL.expand("http://tinyurl.com/2tx") # => "http://google.com"
Raises ShortURL::InvalidShortURL if short_url is invalid and it
can not be expanded.
def self.shorten(url : String, service = :tinyurl)
#
Shortens an url using one of the available services.
ShortURL.shorten("http://google.com") # => "http://tinyurl.com/2tx"
ShortURL.shorten("http://google.com", :isgd) # => "http://is.gd/OwycZW"
# ...