When the developer has specifically defined the singular and plural forms via the Inflections#irregular method, then there is no justification for the singularize and pluralize methods to return some other inflection attempt that isn't part of the English language rather than using the inflections has been taught. This certainly violates the principle of least surprise.
I've given you a code snippet to fix this. Please include it in Sequel. Thanks, Shawn On May 22, 12:46 am, Jeremy Evans <[email protected]> wrote: > On May 20, 10:22 pm, Shawn <[email protected]> wrote: > > > > > > > String.inflections do |inflect| > > inflect.irregular 'focus', 'foci' > > inflect.irregular 'criterion', 'criteria' > > end > > > 'focus'.plural => 'foci' # good > > 'foci'.singular => 'focus' # good > > 'focus'.singular => 'focu' # wrong! > > 'foci'.plural => 'focis' # wrong! > > > The irregular method of the String::Inflections module needs create > > rules to map the singular and plural forms to themselves. Here's the > > patch: > > > def self.irregular(singular, plural) > > + singular(Regexp.new("(#{singular[0,1]})#{singular[1..-1]}$", > > "i"), '\1' + singular[1..-1]) > > plural(Regexp.new("(#{singular[0,1]})#{singular[1..-1]}$", "i"), > > '\1' + plural[1..-1]) > > > singular(Regexp.new("(#{plural[0,1]})#{plural[1..-1]}$", "i"), > > '\1' + singular[1..-1]) > > + plural(Regexp.new("(#{plural[0,1]})#{plural[1..-1]}$", "i"), > > '\1' + plural[1..-1]) > > end > > This isn't a bug IMO. Attempting to singularize an already singular > word or pluralize an already plural word will cause problems in many > cases, not just for irregulars. > > Jeremy > > -- > You received this message because you are subscribed to the Google Groups > "sequel-talk" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group > athttp://groups.google.com/group/sequel-talk?hl=en. -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en.
