Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Make safety urls from strings
Ruby
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
lib
spec
.gitignore
.rspec
.travis.yml
Gemfile
LICENSE.txt
README.md
Rakefile
slugg.gemspec

README.md

Slugg

Gem version Build Status

Make safety urls from strings

Installation

Add this line to your application's Gemfile:

gem 'slugg'

And then execute:

$ bundle

Or install it yourself as:

$ gem install slugg

Usage

require 'slug'

Slugg.new "generate url, please"
# => "generate-url-please"

# Slugg.make is alias to Slugg.new
Slugg.make "generate url, please"
# => "generate-url-please"

# you may provide some options
Slugg.make "generate url, please", separator: "_"
# => "generate_url_please"

Slugg.make "generate url, please", stripper: "please"
# => "generate-url"

Slugg.make "strip 100$", stripper: /\d/
# => "strip"

# and you may use instance
slugg = Slugg::Sanitizer.new separator: "_"
slugg.safe "make url"
# => "make_url"

slugg.options[:separator] = "-"
slugg.safe "make url"
# => "make-url"

# options
{
  separator: '-', # define custom separator
  stripper: ''    # strip text, allows String and Regexp
}

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
Something went wrong with that request. Please try again.