Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/artemeff/slugg
Make safety urls from strings
https://github.com/artemeff/slugg
Last synced: 12 days ago
JSON representation
Make safety urls from strings
- Host: GitHub
- URL: https://github.com/artemeff/slugg
- Owner: artemeff
- License: mit
- Created: 2013-06-22T14:49:44.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2013-06-25T08:31:45.000Z (over 11 years ago)
- Last Synced: 2024-03-14T21:46:01.399Z (10 months ago)
- Language: Ruby
- Size: 129 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Slugg
[![Gem version](https://badge.fury.io/rb/slugg.png)](https://rubygems.org/gems/slugg)
[![Build Status](https://secure.travis-ci.org/artemeff/slugg.png)](https://travis-ci.org/artemeff/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
```ruby
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