Project

scrubba

0.0
No commit activity in last 3 years
No release in over 3 years
Strip and normalize strings for ActiveModel/ActiveAttr
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0
~> 10.0
 Project Readme

Scrubba: Clean your strings!

Build Status Code Climate

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:

gem 'scrubba'

And then execute:

$ bundle

Or install it yourself as:

$ gem install scrubba

Usage

Standalone:

require "scrubba"

some_str = " foo \t bar "
Scrubba.strip(some_str) #=> "foo \t bar"
Scrubba.collapse(some_str) #=> " foo bar "

In an ActiveRecord model:

require "scrubba"

class Post < ActiveRecord::Base
  include Scrubba::ActiveMethods

  scrub :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.

Author

Jon-Michael Deldin, @jmdeldin