Sha256: 606706ed71338823210a43a6ae1aff9738aea4d5b046469ea846a67f58f9a146
Contents?: true
Size: 1.31 KB
Versions: 2
Compression:
Stored size: 1.31 KB
Contents
# Okay, because about 99.9% of the usage is with Rails/AS, I guess it should # have better/deeper support for it, like support for Multibyte stuff and some # (useful) inflections. # # Please note that the +TransliterateNormalizer+ requires rails 3.0.0.beta3 and # when run with ruby 1.9. # if defined?(::ActiveSupport) require 'active_support/inflector' require 'vacuum_cleaner/normalizations/method' module VacuumCleaner module Normalizations # Calls `ActiveSupport::Inflector.transliterate` if supplied # +value+ responds to +to_str+, so it basically only works on strings. class TransliterateNormalizer < Normalizer def normalize_value(value) ::ActiveSupport::Inflector.transliterate(value.to_str).to_s if value.respond_to?(:to_str) end end # Calls the `titleize` method from AS on the supplied value, if possible. TitleizeNormalizer = MethodNormalizer.build(:titleize) # Calls the `humanize` method from AS on the supplied value. HumanizeNormalizer = MethodNormalizer.build(:humanize) end end # Set the multibyte proxy class to AS::Multibyte::Chars, which in turn works perfectly with UTF8 chars et al. VacuumCleaner::Normalizations::MethodNormalizer.multibyte_wrapper = ::ActiveSupport::Multibyte::Chars end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vacuum_cleaner-1.0.3 | lib/vacuum_cleaner/normalizations/active_support.rb |
vacuum_cleaner-1.0.1 | lib/vacuum_cleaner/normalizations/active_support.rb |