module NameTamer

Constants

ADFIXES

These are the prefixes and suffixes we want to remove If you add to the list, you can use spaces and dots where appropriate Ensure any single letters are followed by a dot because we’ll add one to the string during processing, e.g. “y Cia.” should be “y. Cia.”

ADFIX_JOINERS
ADFIX_PATTERNS
ALPHA

Constants for parameterizing Unicode strings for IRIs

Allowed characters in an IRI segment are defined by RFC 3987 (tools.ietf.org/html/rfc3987#section-2.2) as follows:

isegment-nz-nc = 1*( iunreserved / pct-encoded / sub-delims
                     / "@" )
               ; non-zero-length segment without any colon ":"

iunreserved    = ALPHA / DIGIT / "-" / "." / "_" / "~" / ucschar

pct-encoded    = "%" HEXDIG HEXDIG

sub-delims     = "!" / "$" / "&" / "'" / "(" / ")"
               / "*" / "+" / "," / ";" / "="

ucschar        = %xA0-D7FF / %xF900-FDCF / %xFDF0-FFEF
               / %x10000-1FFFD / %x20000-2FFFD / %x30000-3FFFD
               / %x40000-4FFFD / %x50000-5FFFD / %x60000-6FFFD
               / %x70000-7FFFD / %x80000-8FFFD / %x90000-9FFFD
               / %xA0000-AFFFD / %xB0000-BFFFD / %xC0000-CFFFD
               / %xD0000-DFFFD / %xE1000-EFFFD

Note that we can’t use Unicode code points above uFFFF because of regex limitations, so we’ll ignore ucschar above that point.

We’re using the most restrictive segment definition (isegment-nz-nc) to avoid any possible problems with the IRI that it one day might get placed in.

ASCII_SPACE
DIGIT
FILTER_COMPAT
FILTER_RFC3987
ISEGMENT_NZ_NC
IUNRESERVED
NONBREAKING_SPACE
SLUG_DELIMITER
SUBDELIMS
UCSCHAR
VERSION
ZERO_WIDTH_FILTER

Public Class Methods

[](name, args = {}) click to toggle source
# File lib/name_tamer.rb, line 12
def [](name, args = {})
  NameTamer::Name.new name, args
end
parameterize(string, args = {}) click to toggle source

Make a slug from a string

# File lib/name_tamer.rb, line 17
def parameterize(string, args = {})
  NameTamer::Text.new(string, args).parameterize
end