README.md in data_cleansing-0.3.0 vs README.md in data_cleansing-0.3.1
- old
+ new
@@ -1,9 +1,9 @@
data_cleansing
==============
-Data Cleansing solution for Ruby with additional support for Rails and Mongoid
+Data Cleansing framework for Ruby with additional support for Rails and Mongoid
* http://github.com/reidmorrison/data_cleansing
## Introduction
@@ -25,11 +25,11 @@
Rails, Mongoid, or other model.
* Supports custom cleansing definitions for a single attribute
## Examples
-### Simple Example
+### Ruby Example
```ruby
require 'data_cleansing'
# Define a global cleaner
DataCleansing.register_cleaner(:strip) {|string| string.strip!}
@@ -52,13 +52,41 @@
u.cleanse_attributes!
puts "After data cleansing #{u.inspect}"
# After data cleansing After data cleansing #<User:0x007fc9f1081980 @first_name="joe", @last_name="black">
```
-### Ruby Example
+### Rails Example
```ruby
+# Define a global cleanser
+DataCleansing.register_cleaner(:strip) {|string| string.strip!}
+
+# 'users' table has the following columns :first_name, :last_name, :address1, :address2
+class User < ActiveRecord::Base
+ include DataCleansing::Cleanse
+
+ # Use a global cleaner
+ cleanse :first_name, :last_name, :cleaner => :strip
+
+ # Define a once off cleaner
+ cleanse :address1, :address2, :cleaner => Proc.new {|string| string.strip!}
+
+ # Automatically cleanse data before validation
+ before_validation :cleanse_attributes!
+end
+
+# Create a User instance
+u = User.new(:first_name => ' joe ', :last_name => "\n black\n", :address1 => "2632 Brown St \n")
+puts "Before data cleansing #{u.attributes.inspect}"
+u.validate
+puts "After data cleansing #{u.attributes.inspect}"
+u.save!
+```
+
+### Advanced Ruby Example
+
+```ruby
require 'data_cleansing'
# Define a global cleaners
DataCleansing.register_cleaner(:strip) {|string| string.strip!}
DataCleansing.register_cleaner(:upcase) {|string| string.upcase!}
@@ -104,38 +132,10 @@
u.cleanse_attributes!
puts "After data cleansing #{u.inspect}"
# After data cleansing #<User:0x007fdd5a83a8f8 @first_name="joe", @last_name="black", @address1="2632 Brown St", @title="MR.", @gender="Male">
```
-### Rails Example
-
-```ruby
-# Define a global cleanser
-DataCleansing.register_cleaner(:strip) {|string| string.strip!}
-
-# 'users' table has the following columns :first_name, :last_name, :address1, :address2
-class User < ActiveRecord::Base
- include DataCleansing::Cleanse
-
- # Use a global cleaner
- cleanse :first_name, :last_name, :cleaner => :strip
-
- # Define a once off cleaner
- cleanse :address1, :address2, :cleaner => Proc.new {|string| string.strip!}
-
- # Automatically cleanse data before validation
- before_validation :cleanse_attributes!
-end
-
-# Create a User instance
-u = User.new(:first_name => ' joe ', :last_name => "\n black\n", :address1 => "2632 Brown St \n")
-puts "Before data cleansing #{u.attributes.inspect}"
-u.validate
-puts "After data cleansing #{u.attributes.inspect}"
-u.save!
-```
-
## Notes
Cleaners are called in the order in which they are defined, so subsequent cleaners
can assume that the previous cleaners have run and can therefore access or even
modify previously cleaned attributes
@@ -170,28 +170,33 @@
For example, in Rails it obtains the raw data value before Rails has converted it.
Which is useful for cleansing integer or float fields as raw strings before Rails
tries to convert it to an integer or float.
-Meta
-----
+## Dependencies
+DataCleansing requires the following dependencies
+
+* Ruby V1.8.7, V1.9.3 or V2 and greater
+* Rails V2 or greater for Rails integration ( Only if Rails is being used )
+* Mongoid V2 or greater for Rails integration ( Only if Mongoid is being used )
+
+## Meta
+
* Code: `git clone git://github.com/reidmorrison/data_cleansing.git`
* Home: <https://github.com/reidmorrison/data_cleansing>
* Issues: <http://github.com/reidmorrison/data_cleansing/issues>
* Gems: <http://rubygems.org/gems/data_cleansing>
This project uses [Semantic Versioning](http://semver.org/).
-Authors
--------
+## Authors
Reid Morrison :: reidmo@gmail.com :: @reidmorrison
-License
--------
+## License
-Copyright 2013 Reid Morrison, Clarity Services, Inc.
+Copyright 2013 Reid Morrison
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at