errata

Correct strings based on remote errata files.

UTF-8

Assumes all input strings are UTF-8. Otherwise there can be problems with Ruby 1.9 and Regexp::FIXEDENCODING. Specifically, ASCII-8BIT regexps might be applied to UTF-8 strings (or vice-versa), resulting in Encoding::CompatibilityError.

Real-life usage

Used by data_miner (github.com/seamusabshere/data_miner)

Example

Taken from #{GEMDIR}/test/test_old_syntax.rb:

errata = Errata.new(:url => 'http://static.brighterplanet.com/science/data/transport/automobiles/make_fleet_years/errata.csv')
rover = { 'manufacturer_name' => 'foobar Austin Rover foobar' }
mercedes = { 'manufacturer_name' => 'MERCEDES' }
errata.correct! mercedes
errata.correct! rover

Now you will have

rover['manufacturer_name']    #=> 'Rover'         (used to be 'foobar Austin Rover foobar')
mercedes['manufacturer_name'] #=> 'Mercedes-Benz' (used to be 'MERCEDES')

Authors

Copyright © 2011 Brighter Planet. See LICENSE for details.