No commit activity in last 3 years
No release in over 3 years
Let String instances be conviently normalized
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies
 Project Readme

Normalizacion Build Status

This gem provides a Refinement for the String class. It adds String#normalize which transliterates non-ASCII characters using a static collation table. It also replaces whitespaces with - and optionally downcases the string value.

It is very similar to what ActiveSupport's #parameterize does, only more customizable (and without depending on ActiveSupport).

Installation

Add this line to your application's Gemfile:

gem 'normalizacion'

And then execute:

$ bundle

Or install it yourself as:

$ gem install normalizacion

Usage

class YourClass
  using Normalizacion

  def to_s
    "Schöneberger Straße"
  end
end

YourClass.new.to_s # => "Schoenberger-Strasse"

.plan

  • support custom collation hash
  • support more special chars by default
  • handle punctuation marks

Changelog

v1.0.0

  • Uses Ruby 2.1 idioms: Keyword Arguments and Refinments
  • Renamed gem

v0.3.0

  • Added #normalize! for in-place normalization
  • Adds downcase option

v0.2.0

  • Normalization can now be customized via an options hash.

Copyright (c) 2010-2016 Carsten Zimmermann, released under a BSD-type license