shorturl

Version, currently 0.2.14 versions

github.com/veelenga/shorturl.cr

A tiny library to use URL shortening services

14 stars
0 dependents
License: MIT

Installation

# Add this to your shard.yml
dependencies:
  shorturl:
    github: veelenga/shorturl.cr
    version: ~> 0.2.1

Then run:

shards install

shard.yml

Crystal
no constraint declared
Author
Vitalii Elenhaupt <velenhaupt@gmail.com>

Dependencies

Development Dependencies

  • ameba0.7.0github: veelenga/amebadev
  • webmock*github: manastech/webmock.crdev

README

# shorturl.cr [![Build Status](https://travis-ci.org/veelenga/shorturl.cr.svg?branch=master)](https://travis-ci.org/veelenga/shorturl.cr)

A simple library to use URL shortening services. Inspired by Robby Russell's [shorturl](https://github.com/robbyrussell/shorturl).

## Installation

As a dependency in `shards.yml`:

```yaml
dependencies:
  shorturl:
    github: veelenga/shorturl.cr
    branch: master
```

## Usage

As easy as it could be:

```crystal
require "shorturl"

# shorten
ShortURL.shorten "http://google.com"           # => "http://tinyurl.com/2tx"
ShortURL.shorten "http://google.com", :tinyurl # => "http://tinyurl.com/2tx"
ShortURL.shorten "http://google.com", :isgd    # => "http://is.gd/OwycZW"

# expand
ShortURL.expand "http://tinyurl.com/2tx"       # => "http://google.com"
```

## Binary

As an addition, `shorturl` binary available for you:

```sh
$ crystal build bin/shorturl && ./shorturl -h
Usage: shorturl [arguments]
    -u URL, --url=URL                URL to be shortened
    -s SERVICE, --service=SERVICE    Shortening service
    -V, --verbose                    Verbose output
    -v, --version                    Version
    -h, --help                       Prints this help

$ ./shorturl http://google.com
http://tinyurl.com/2tx
```

## Available services

Here is a list of available shortening services in shorturl.cr:

* [is.gd](http://is.gd)
* [shorl.com](http://shorl.com)
* [tinyurl.com](http://tinyurl.com)
* [v.gd](http://v.gd)

## Contributing

1. Fork it
1. Create your feature branch
1. Implement your feature
1. Run tests with `crystal spec`
1. Commit your changes
1. Push to the branch
1. Create a new Pull Request