0.0
No commit activity in last 3 years
No release in over 3 years
Shrink those long and nasty links into a shorter URL
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
~> 0.6.7
>= 0
~> 2.14.1
~> 0.8.2
~> 2.8.0
~> 1.17.1

Runtime

~> 0.6.3
 Project Readme

LinkShrink

Build Status Gem Version Dependency Status Coverage Status Code Climate Inline docs Gitter chat

A Ruby Gem and Command-Line Application for shrinking those long and nasty links into a shorter URL

Supported Url Shortener APIs

  • Google
  • TinyUrl
  • IsGd
  • Owly
  • Karmacracy
  • More to come...

Installation

$ gem install link_shrink

Setup

You can use any shrinker listed without worrying about the api key except for Owly and Karmacracy. Google let's you use its api without an api key, but providing one will generate metrics in their dashboard.

Google

Works best with a Google URL API key. You can sign-up for a free one at Google URL API

  1. In the Services pane, activate the Google URL Shortener API; if the Terms of Service appear, read and accept them.

  2. Go to the API Access pane. The API key is near the bottom of that pane, in the section titled "Simple API Access."

Owly

Sign-up for a free API key at Owly.

Karmacracy

Sign-up for a free API key at Karmacracy.

Configuration

Set your apikey as an environment variable:

$ export GOOGLE_URL_KEY='your_api_key_here'

$ export OWLY_URL_KEY='your_api_key_here'

$ export KARMACRACY_URL_KEY='your_api_key_here'
$ export KARMACRACY_USERNAME='your_username_here'

You could also save it in your ~/.bash_profile or ~/.zshrc

Usage

Ruby:

require 'link_shrink'

LinkShrink.shrink_url("http://www.ruby-lang.org")
=> "http://goo.gl/QuXj"

To change the default shrinker (Google API):

LinkShrink.configure do |c|
  c.api = 'IsGd'
end

# or

LinkShrink::Config.api = 'TinyUrl'

LinkShrink.shrink_url('http://www.google.com')
=> "http://tinyurl.com/1c2"

In your terminal:

$ linkshrink http://www.rubyrogues.com
http://goo.gl/Noh9X

$ linkshrink --tinyurl http://www.rubyrogues.com
http://tinyurl.com/k2butj9

$ linkshrink --isgd http://www.rubyrogues.com
http://is.gd/6ZNRWe

$ linkshrink --owly http://www.rubyrogues.com
http://ow.ly/22rwSe

Command-Line Options

Shrinkers:

  • -t, --tinyurl - use TinyUrl API
  • -i, --isgd - use Is.gd API
  • -om --owly - use Owly API
  • -g, --google - use Google API (Default)
  • -k --karmacracy - use Karmacracy API

Additional options:

  • -h, --help - show help message

Todo

  • Batch list (with selected api or specified for operation)
  • Save to file (html, text)
  • Bitly Shrinker API
  • Parallel HTTP Requests

Author

Discussion

If you have any questions, ideas or jokes:

Gitter chat

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

Bitdeli Badge