Slugg
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.[:separator] = "-"
slugg.safe "make url"
# => "make-url"
# options
{
separator: '-', # define custom separator
stripper: '' # strip text, allows String and Regexp
}
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request