Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jmdeldin/scrubba
A tiny gem to strip and normalize whitespace from ActiveWhatevers.
https://github.com/jmdeldin/scrubba
Last synced: about 1 month ago
JSON representation
A tiny gem to strip and normalize whitespace from ActiveWhatevers.
- Host: GitHub
- URL: https://github.com/jmdeldin/scrubba
- Owner: jmdeldin
- License: mit
- Created: 2015-08-28T23:45:44.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2019-07-26T18:07:31.000Z (over 5 years ago)
- Last Synced: 2024-09-14T13:29:44.914Z (2 months ago)
- Language: Ruby
- Homepage:
- Size: 20.5 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Scrubba: Clean your strings!
[![Build Status](https://travis-ci.org/jmdeldin/scrubba.svg)](https://travis-ci.org/jmdeldin/scrubba) [![Code Climate](https://codeclimate.com/github/jmdeldin/scrubba/badges/gpa.svg)](https://codeclimate.com/github/jmdeldin/scrubba)
Scrubba is a tiny gem to strip and normalize whitespace. It provides a few convenient methods for working with ActiveRecord/ActiveModel/ActiveAttr/ActiveNode attributes too.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'scrubba'
```And then execute:
$ bundle
Or install it yourself as:
$ gem install scrubba
## Usage
Standalone:
```ruby
require "scrubba"some_str = " foo \t bar "
Scrubba.strip(some_str) #=> "foo \t bar"
Scrubba.collapse(some_str) #=> " foo bar "
```In an ActiveRecord model:
```ruby
require "scrubba"class Post < ActiveRecord::Base
include Scrubba::ActiveMethodsscrub :title, :slug, strip: true
scrub :body, collapse: true
end
```## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/jmdeldin/scrubba.
Protip: If you use Emacs, insert a Unicode space in your test data with M-x insert-char and verify it with M-x describe-char.
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
## Author
[Jon-Michael Deldin](http://www.jmdeldin.com), [@jmdeldin](http://twitter.com/jmdeldin)