Project

striptease

0.0
No commit activity in last 3 years
No release in over 3 years
A simple library for stripping whitespace from model attributes
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies
 Project Readme

Whitespace stripper dance party!

Striptease is a very simple library for stripping leading and trailing whitespace from model attributes.

Installation:

Rails:

Add the following line to your Gemfile:

gem 'striptease'

Then run bundle install and you're ready to go.

Usage:

Striptease includes a helper for ActiveRecord models that defines which attributes are to be stripped, as well as an Rspec matcher to test that the attributes are indeed being stripped as expected.

AR Models:

Just call strip_whitespace in your model class, passing one or more attributes you want stripped of leading and trailing whitespace. Striptease does this in a before_validation hook.

class SomeClass < ActiveRecord::Base
  strip_whitespace :foo, :bar
end

Rspec:

To make sure you are actually stripping whitespace from your attributes, just use the strip_whitespace_from matcher in your unit tests:

describe SomeClass do
  it { should strip_whitespace_from(:foo) }
  it { should strip_whitespace_from(:bar) }
end

That's it! Dead simple whitespace stripping for AR model attributes.