string-utils: sanitificazione e trasformazione url friendly
Scritto da Silvio Relli circa 2 anni fa. Jun8

Oggi ho rilasciato la mia prima gemma, string-utils: essa contiene una semplice libreria che utilizzo in alcuni dei miei progetti.
Il suo compito principale è permettere la sanitificazione delle stringhe tramite l'helper sanitize (integrato in Rails a partire dalla versione 2.3.6 e 3.0 beta) anche all'interno di modelli e controllori.
Infatti come tutti gli helper, sanitize sarebbe disponibile solo all'interno delle viste, ma a volte mi è tornato utile sanitificare un input utente nel controllore, prima di lavorarci sopra, o magari anche nei modelli prima di salvarlo.
Una volta installata la gemma è possibile chiamare la funzione sanitize su qualsiasi stringa, in quanto la gemma consiste fondamentalmente in un'estensione della classe String.
Inoltre vengono rese disponibili due scorciatoie, "mia stringa".san che richiama sanitize effettuando la sanitificazione del testo e "mia stringa".hs che richiama html_safe.
Attenzione all'utilizzo di quest'ultima, in quanto non effettua la sanitificazione ma forza la stringa come html_safe senza effettuare controlli, utile soltanto quando si vuole evitare che venga effettuato l'escape di codice.
Infine la gemma fornisce la funzione urlify che rende una stringa url friendly sostituendo o cancellando caratteri indesiderati come lettere accentati e punteggiatura. Utile per creare pretty url!
Ad esempio "O come l'è GANZA 'sta gemma!".urlify restituisce "o-come-l-e-ganza-sta-gemma".
Potete installare la gemma tramite
sudo gem install string-utils --source http://gemcutter.org
oppure integrarla nel vostro progetto aggiungendola nel config/environment.rb con
config.gem 'string-utils', :source => "http://gemcutter.org"
Ulteriori esempi e sorgenti della gemma su Github: http://github.com/silviorelli/string-utils

A versatile and ultra striking pair of Ray Ban Uk sunglasses for women, the Ray Ban Wayfarer are highly reminiscent of a cat-eye style but with a more subtle shape, allowing you to channel the iconic look but in a more understated fashion. The sunglasses feature a thick acetate frame that becomes thicker at the outer vertical edges and draws to a point at the upper outer corners creating a suggestion of the cat-eye flick. The arms become narrower towards the ear stems and display the signature Ray-Ban logo in raised metal lettering positioned adjacent to the hinge. The overall aesthetic detailing remains minimal accentuating the versatility of the sunglasses. The Ray Ban Aviators are available in neutral and flattering colours including a shiny havana and tortoiseshell patterned frame with crystal green lenses and a shiny black frame with crystal green lenses. Some styles are also available with polarised lenses for the ultimate in visual quality and protection.
to overcome the primary market economy exist of the polarization between the rich and the serious defects such as, in the basis of civilization and not in the savage basis of realizing economic sustainable development. In the nineteenth century marxist theory after establishment, Christian Louboutin London the market economy after continuous adjusting production the relationship to adapt to the development of productive forces, Cheap Louboutin Shoes from the original market economy’s misconduct, in social fairness and justice and the distribution of wealth has made rapid progress, this is the key to understanding modern market economy. Economic basis determine superstructure. GHD UK We can’t build a base of market economy, but refused to market economy of superstructure, or put the two separated, GHD Rare Leopard Print the planned economy superstructure in market economy, the grafting basis, it was against the objective law of, can develop a pantomime horse of a freak. China at present, there exist a series of social problems that is not caused by the market economy, GHD IV Salon on the contrary, because of the market economy is not perfect or the market economic factors. Plan control, prerogative,Salvatore Ferragamo the economy, the government to market the unscrupulous control and intervention, cause market disorder mechanism is the main reason for the distribution of distortion deformity.