Skip to content

Commit

Permalink
Merge pull request #38 from cllns/improve-singularizing-suffix-us
Browse files Browse the repository at this point in the history
[changelog]

version: unreleased
fixed: "Fix singularizing -us suffix (issue #33 via #38) (@cllns)"
  • Loading branch information
solnic authored Jun 18, 2021
2 parents 5244af0 + bd41377 commit e99ab9c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/dry/inflector/inflections/defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def self.singular(inflect)
inflect.singular(/(ss)\z/i, '\1')
inflect.singular(/(x|ch|ss|sh)es\z/i, '\1')
inflect.singular(/([m|l])ice\z/i, '\1ouse')
inflect.singular(/(bus)(es)?\z/i, '\1')
inflect.singular(/(us)(es)?\z/i, '\1')
inflect.singular(/(o)es\z/i, '\1')
inflect.singular(/(shoe)s\z/i, '\1')
inflect.singular(/(cris|ax|test)(is|es)\z/i, '\1is')
Expand Down
9 changes: 6 additions & 3 deletions spec/support/fixtures/singularize.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ def self.pending
"testis" => "testis",
"thesis" => "thesis",
"analysis" => "analysis",
"octopus" => "octopus",
"octopuses" => "octopus",
"pluses" => "plus",
"cactuses" => "cactus",
"bonuses" => "bonus",
"geniuses" => "genius",
"walruses" => "walrus",

# ==== rules

Expand Down Expand Up @@ -166,11 +171,9 @@ def self.pending
# Missing exceptions or missing rules?
PENDING = {
"cacti" => "cactus",
"cactuses" => "cactus",
"thesauri" => "thesaurus",
"phenomena" => "phenomenon",
"drives" => "drive",
"pluses" => "plus",
"thieves" => "thief",
"criteria" => "criterion",
"postgres" => "postgres"
Expand Down

0 comments on commit e99ab9c

Please sign in to comment.