Sha256: 3b9c07839df0fd08dd7b7fcac7e7d148cb5ea895f10b50b86653e564ea0e04a0

Contents?: true

Size: 1.56 KB

Versions: 129

Compression:

Stored size: 1.56 KB

Contents

# frozen-string-literal: true

module Sequel
  # Proc that is instance_execed to create the default inflections for both the
  # model inflector and the inflector extension.
  DEFAULT_INFLECTIONS_PROC = proc do
    plural(/$/, 's')
    plural(/s$/i, 's')
    plural(/(alias|(?:stat|octop|vir|b)us)$/i, '\1es')
    plural(/(buffal|tomat)o$/i, '\1oes')
    plural(/([ti])um$/i, '\1a')
    plural(/sis$/i, 'ses')
    plural(/(?:([^f])fe|([lr])f)$/i, '\1\2ves')
    plural(/(hive)$/i, '\1s')
    plural(/([^aeiouy]|qu)y$/i, '\1ies')
    plural(/(x|ch|ss|sh)$/i, '\1es')
    plural(/(matr|vert|ind)ix|ex$/i, '\1ices')
    plural(/([m|l])ouse$/i, '\1ice')

    singular(/s$/i, '')
    singular(/([ti])a$/i, '\1um')
    singular(/(analy|ba|cri|diagno|parenthe|progno|synop|the)ses$/i, '\1sis')
    singular(/([^f])ves$/i, '\1fe')
    singular(/([h|t]ive)s$/i, '\1')
    singular(/([lr])ves$/i, '\1f')
    singular(/([^aeiouy]|qu)ies$/i, '\1y')
    singular(/(m)ovies$/i, '\1ovie')
    singular(/(x|ch|ss|sh)es$/i, '\1')
    singular(/([m|l])ice$/i, '\1ouse')
    singular(/buses$/i, 'bus')
    singular(/oes$/i, 'o')
    singular(/shoes$/i, 'shoe')
    singular(/(alias|(?:stat|octop|vir|b)us)es$/i, '\1')
    singular(/(vert|ind)ices$/i, '\1ex')
    singular(/matrices$/i, 'matrix')

    irregular('person', 'people')
    irregular('man', 'men')
    irregular('child', 'children')
    irregular('sex', 'sexes')
    irregular('move', 'moves')
    irregular('quiz', 'quizzes')
    irregular('testis', 'testes')

    uncountable(%w(equipment information rice money species series fish sheep news))
  end
end

Version data entries

129 entries across 112 versions & 2 rubygems

Version Path
sequel-5.88.0 lib/sequel/model/default_inflections.rb
sequel-5.87.0 lib/sequel/model/default_inflections.rb
sequel-5.86.0 lib/sequel/model/default_inflections.rb
sequel-5.85.0 lib/sequel/model/default_inflections.rb
sequel-5.84.0 lib/sequel/model/default_inflections.rb
sequel-5.83.1 lib/sequel/model/default_inflections.rb
sequel-5.83.0 lib/sequel/model/default_inflections.rb
sequel-5.82.0 lib/sequel/model/default_inflections.rb
sequel-5.81.0 lib/sequel/model/default_inflections.rb
sequel-5.80.0 lib/sequel/model/default_inflections.rb
sequel-5.79.0 lib/sequel/model/default_inflections.rb
sequel-5.78.0 lib/sequel/model/default_inflections.rb
sequel-5.77.0 lib/sequel/model/default_inflections.rb
sequel-5.76.0 lib/sequel/model/default_inflections.rb
sequel-5.75.0 lib/sequel/model/default_inflections.rb
sequel-5.74.0 lib/sequel/model/default_inflections.rb
sequel-5.73.0 lib/sequel/model/default_inflections.rb
sequel-5.72.0 lib/sequel/model/default_inflections.rb
sequel-5.71.0 lib/sequel/model/default_inflections.rb
sequel-5.70.0 lib/sequel/model/default_inflections.rb