Giter Club home page Giter Club logo

dumb_quotes's Introduction

Dumb Quotes

For some reason I’m yet discern, I’m irrationally annoyed by “smart quotes”, the non-ASCII single and double quotes imposed on our databases by windows users.

There’s no real reason to hate them, but I do. Maybe it’s the extra few bytes they consume when encoded as UTF-8, or maybe it’s the way they get converted to numeric entities in my XML exports. In any case, this ActiveRecord plugin makes the following changes to your model attributes before validation:

U+2018 (‘) -> '
U+2019 (’) -> '
U+02BC (ʼ) -> '
U+201C (“) -> "
U+201D (”) -> "
U+02EE (ˮ) -> "

Examples

class Product < ActiveRecord::Base
  dumb_quotes!
end

class Product < ActiveRecord::Base
  dumb_quotes!, :except => :title
end

class Product < ActiveRecord::Base
  dumb_quotes!, :only => :description
end

Installation

Option 1. Load the plugin as a gem

gem install dumb_quotes
add "config.gem 'dumb_quotes'" to your environment.rb

Option 2. Use the standard Rails plugin install (assuming Rails 2.1).

./script/plugin install git://github.com/yob/dumb_quotes.git

Caveats

The translation is done with raw bytes. If you happen to be using anything other than UTF-8 in your models, you’re likely to munge data.

This also means it’s almost certainly not ruby 1.9 compatible. Patches welcome.

Credits

This plugin is essentially a fork of the strip attributes plugin, released under the MIT License by Ryan McGeary.

github.com/rmm5t/strip_attributes

License

Copyright © 2007-2008 Ryan McGeary released under the MIT license Copyright © 2009 James Healy released under the MIT license

en.wikipedia.org/wiki/MIT_License

dumb_quotes's People

Contributors

yob avatar

Stargazers

Angus H. avatar  avatar Colin Schlueter avatar

Watchers

 avatar James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.