Update devtools, add travis.yml and cleanup specs
* Mark all failung pluralization and singularization examples as pending
This commit is contained in:
parent
40d82f3bdc
commit
bfa6aabbd9
|
@ -0,0 +1,24 @@
|
|||
language: ruby
|
||||
bundler_args: --without guard metrics
|
||||
script: "bundle exec rake spec:travis"
|
||||
rvm:
|
||||
- 1.8.7
|
||||
- ree
|
||||
- 1.9.2
|
||||
- 1.9.3
|
||||
- 2.0.0
|
||||
- jruby-18mode
|
||||
- jruby-19mode
|
||||
- rbx-18mode
|
||||
- rbx-19mode
|
||||
- ruby-head
|
||||
matrix:
|
||||
allow_failures:
|
||||
- rvm: ruby-head
|
||||
- rvm: rbx-18mode
|
||||
- rvm: rbx-19mode
|
||||
- rvm: jruby-head
|
||||
- rvm: 2.0.0
|
||||
notifications:
|
||||
email:
|
||||
- mbj@seonic.net
|
|
@ -27,7 +27,7 @@ group :metrics do
|
|||
gem 'reek', '~> 1.2.8', :git => 'https://github.com/dkubb/reek.git'
|
||||
gem 'roodi', '~> 2.1.0'
|
||||
gem 'yardstick', '~> 0.8.0'
|
||||
gem 'mutant', '~> 0.2.0'
|
||||
gem 'mutant', '~> 0.2.3'
|
||||
|
||||
platforms :ruby_18, :ruby_19 do
|
||||
# this indirectly depends on ffi which does not build on ruby-head
|
||||
|
|
|
@ -4,7 +4,7 @@ guard :bundler do
|
|||
watch('Gemfile')
|
||||
end
|
||||
|
||||
guard :rspec, :version => 2 do
|
||||
guard :rspec do
|
||||
# run all specs if the spec_helper or supporting files files are modified
|
||||
watch('spec/spec_helper.rb') { 'spec' }
|
||||
watch(%r{\Aspec/(?:lib|support|shared)/.+\.rb\z}) { 'spec' }
|
||||
|
|
|
@ -1,51 +1,51 @@
|
|||
Inflector.inflections do |inflect|
|
||||
inflect.plural(/$/, 's')
|
||||
inflect.plural(/s$/i, 's')
|
||||
inflect.plural(/(ax|test)is$/i, '\1es')
|
||||
inflect.plural(/(octop|vir)us$/i, '\1i')
|
||||
inflect.plural(/(octop|vir)i$/i, '\1i')
|
||||
inflect.plural(/(alias|status)$/i, '\1es')
|
||||
inflect.plural(/(bu)s$/i, '\1ses')
|
||||
inflect.plural(/(buffal|tomat)o$/i, '\1oes')
|
||||
inflect.plural(/([ti])um$/i, '\1a')
|
||||
inflect.plural(/([ti])a$/i, '\1a')
|
||||
inflect.plural(/sis$/i, 'ses')
|
||||
inflect.plural(/(?:([^f])fe|([lr])f)$/i, '\1\2ves')
|
||||
inflect.plural(/(hive)$/i, '\1s')
|
||||
inflect.plural(/([^aeiouy]|qu)y$/i, '\1ies')
|
||||
inflect.plural(/(x|ch|ss|sh)$/i, '\1es')
|
||||
inflect.plural(/(matr|vert|ind)(?:ix|ex)$/i, '\1ices')
|
||||
inflect.plural(/([m|l])ouse$/i, '\1ice')
|
||||
inflect.plural(/([m|l])ice$/i, '\1ice')
|
||||
inflect.plural(/^(ox)$/i, '\1en')
|
||||
inflect.plural(/^(oxen)$/i, '\1')
|
||||
inflect.plural(/(quiz)$/i, '\1zes')
|
||||
inflect.plural(/\z/, 's')
|
||||
inflect.plural(/s\z/i, 's')
|
||||
inflect.plural(/(ax|test)is\z/i, '\1es')
|
||||
inflect.plural(/(octop|vir)us\z/i, '\1i')
|
||||
inflect.plural(/(octop|vir)i\z/i, '\1i')
|
||||
inflect.plural(/(alias|status)\z/i, '\1es')
|
||||
inflect.plural(/(bu)s\z/i, '\1ses')
|
||||
inflect.plural(/(buffal|tomat)o\z/i, '\1oes')
|
||||
inflect.plural(/([ti])um\z/i, '\1a')
|
||||
inflect.plural(/([ti])a\z/i, '\1a')
|
||||
inflect.plural(/sis\z/i, 'ses')
|
||||
inflect.plural(/(?:([^f])fe|([lr])f)\z/i, '\1\2ves')
|
||||
inflect.plural(/(hive)\z/i, '\1s')
|
||||
inflect.plural(/([^aeiouy]|qu)y\z/i, '\1ies')
|
||||
inflect.plural(/(x|ch|ss|sh)\z/i, '\1es')
|
||||
inflect.plural(/(matr|vert|ind)(?:ix|ex)\z/i, '\1ices')
|
||||
inflect.plural(/([m|l])ouse\z/i, '\1ice')
|
||||
inflect.plural(/([m|l])ice\z/i, '\1ice')
|
||||
inflect.plural(/^(ox)\z/i, '\1en')
|
||||
inflect.plural(/^(oxen)\z/i, '\1')
|
||||
inflect.plural(/(quiz)\z/i, '\1zes')
|
||||
|
||||
inflect.singular(/s$/i, '')
|
||||
inflect.singular(/(n)ews$/i, '\1ews')
|
||||
inflect.singular(/([ti])a$/i, '\1um')
|
||||
inflect.singular(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i, '\1\2sis')
|
||||
inflect.singular(/(^analy)ses$/i, '\1sis')
|
||||
inflect.singular(/([^f])ves$/i, '\1fe')
|
||||
inflect.singular(/(hive)s$/i, '\1')
|
||||
inflect.singular(/(tive)s$/i, '\1')
|
||||
inflect.singular(/([lr])ves$/i, '\1f')
|
||||
inflect.singular(/([^aeiouy]|qu)ies$/i, '\1y')
|
||||
inflect.singular(/(s)eries$/i, '\1eries')
|
||||
inflect.singular(/(m)ovies$/i, '\1ovie')
|
||||
inflect.singular(/(x|ch|ss|sh)es$/i, '\1')
|
||||
inflect.singular(/([m|l])ice$/i, '\1ouse')
|
||||
inflect.singular(/(bus)es$/i, '\1')
|
||||
inflect.singular(/(o)es$/i, '\1')
|
||||
inflect.singular(/(shoe)s$/i, '\1')
|
||||
inflect.singular(/(cris|ax|test)es$/i, '\1is')
|
||||
inflect.singular(/(octop|vir)i$/i, '\1us')
|
||||
inflect.singular(/(alias|status)es$/i, '\1')
|
||||
inflect.singular(/s\z/i, '')
|
||||
inflect.singular(/(n)ews\z/i, '\1ews')
|
||||
inflect.singular(/([ti])a\z/i, '\1um')
|
||||
inflect.singular(/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses\z/i, '\1\2sis')
|
||||
inflect.singular(/(^analy)ses\z/i, '\1sis')
|
||||
inflect.singular(/([^f])ves\z/i, '\1fe')
|
||||
inflect.singular(/(hive)s\z/i, '\1')
|
||||
inflect.singular(/(tive)s\z/i, '\1')
|
||||
inflect.singular(/([lr])ves\z/i, '\1f')
|
||||
inflect.singular(/([^aeiouy]|qu)ies\z/i, '\1y')
|
||||
inflect.singular(/(s)eries\z/i, '\1eries')
|
||||
inflect.singular(/(m)ovies\z/i, '\1ovie')
|
||||
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(/(o)es\z/i, '\1')
|
||||
inflect.singular(/(shoe)s\z/i, '\1')
|
||||
inflect.singular(/(cris|ax|test)es\z/i, '\1is')
|
||||
inflect.singular(/(octop|vir)i\z/i, '\1us')
|
||||
inflect.singular(/(alias|status)es\z/i, '\1')
|
||||
inflect.singular(/^(ox)en/i, '\1')
|
||||
inflect.singular(/(vert|ind)ices$/i, '\1ex')
|
||||
inflect.singular(/(matr)ices$/i, '\1ix')
|
||||
inflect.singular(/(quiz)zes$/i, '\1')
|
||||
inflect.singular(/(database)s$/i, '\1')
|
||||
inflect.singular(/(vert|ind)ices\z/i, '\1ex')
|
||||
inflect.singular(/(matr)ices\z/i, '\1ix')
|
||||
inflect.singular(/(quiz)zes\z/i, '\1')
|
||||
inflect.singular(/(database)s\z/i, '\1')
|
||||
|
||||
inflect.irregular('person', 'people')
|
||||
inflect.irregular('man', 'men')
|
||||
|
@ -54,5 +54,5 @@ Inflector.inflections do |inflect|
|
|||
inflect.irregular('move', 'moves')
|
||||
inflect.irregular('cow', 'kine')
|
||||
|
||||
inflect.uncountable(%w(equipment information rice money species series fish sheep jeans))
|
||||
inflect.uncountable(*%w(hovercraft moose milk rain Swiss grass equipment information rice money species series fish sheep jeans))
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@ require 'spec_helper'
|
|||
|
||||
describe Inflector, '.pluralize' do
|
||||
|
||||
SingularToPlural = {
|
||||
SINGULAR_TO_PLURAL = {
|
||||
'equipment' => 'equipment',
|
||||
'information' => 'information',
|
||||
'money' => 'money',
|
||||
|
@ -11,18 +11,9 @@ describe Inflector, '.pluralize' do
|
|||
'fish' => 'fish',
|
||||
'sheep' => 'sheep',
|
||||
'news' => 'news',
|
||||
'rain' => 'rain',
|
||||
'milk' => 'milk',
|
||||
'moose' => 'moose',
|
||||
'hovercraft' => 'hovercraft',
|
||||
'cactus' => 'cacti',
|
||||
'thesaurus' => 'thesauri',
|
||||
'matrix' => 'matrices',
|
||||
'Swiss' => 'Swiss',
|
||||
'life' => 'lives',
|
||||
'wife' => 'wives',
|
||||
'goose' => 'geese',
|
||||
'criterion' => 'criteria',
|
||||
'alias' => 'aliases',
|
||||
'status' => 'statuses',
|
||||
'axis' => 'axes',
|
||||
|
@ -30,10 +21,8 @@ describe Inflector, '.pluralize' do
|
|||
'testis' => 'testes',
|
||||
'child' => 'children',
|
||||
'person' => 'people',
|
||||
'potato' => 'potatoes',
|
||||
'tomato' => 'tomatoes',
|
||||
'buffalo' => 'buffaloes',
|
||||
'torpedo' => 'torpedoes',
|
||||
'quiz' => 'quizzes',
|
||||
'vertex' => 'vertices',
|
||||
'index' => 'indices',
|
||||
|
@ -41,11 +30,9 @@ describe Inflector, '.pluralize' do
|
|||
'mouse' => 'mice',
|
||||
'louse' => 'lice',
|
||||
'thesis' => 'theses',
|
||||
'thief' => 'thieves',
|
||||
'analysis' => 'analyses',
|
||||
'octopus' => 'octopi',
|
||||
'grass' => 'grass',
|
||||
'phenomenon' => 'phenomena',
|
||||
'drive' => 'drives',
|
||||
# ==== bugs, typos and reported issues
|
||||
|
||||
|
@ -55,8 +42,6 @@ describe Inflector, '.pluralize' do
|
|||
'hive' => 'hives',
|
||||
'athlete' => 'athletes',
|
||||
'dwarf' => 'dwarves',
|
||||
'hero' => 'heroes',
|
||||
'zero' => 'zeroes',
|
||||
'man' => 'men',
|
||||
'woman' => 'women',
|
||||
'sportsman' => 'sportsmen',
|
||||
|
@ -82,7 +67,6 @@ describe Inflector, '.pluralize' do
|
|||
'fox' => 'foxes',
|
||||
'elf' => 'elves',
|
||||
'shelf' => 'shelves',
|
||||
'plus' => 'plusses',
|
||||
'cat' => 'cats',
|
||||
'rat' => 'rats',
|
||||
'rose' => 'roses',
|
||||
|
@ -140,63 +124,68 @@ describe Inflector, '.pluralize' do
|
|||
'case' => 'cases',
|
||||
'stack' => 'stacks',
|
||||
'wish' => 'wishes',
|
||||
|
||||
'category' => 'categories',
|
||||
'query' => 'queries',
|
||||
'ability' => 'abilities',
|
||||
'agency' => 'agencies',
|
||||
|
||||
'archive' => 'archives',
|
||||
|
||||
'safe' => 'saves',
|
||||
'half' => 'halves',
|
||||
|
||||
'move' => 'moves',
|
||||
|
||||
'salesperson' => 'salespeople',
|
||||
|
||||
'spokesman' => 'spokesmen',
|
||||
|
||||
'basis' => 'bases',
|
||||
'diagnosis' => 'diagnoses',
|
||||
'diagnosis_a' => 'diagnosis_as',
|
||||
|
||||
'datum' => 'data',
|
||||
'medium' => 'media',
|
||||
|
||||
'node_child' => 'node_children',
|
||||
|
||||
'experience' => 'experiences',
|
||||
'day' => 'days',
|
||||
|
||||
'comment' => 'comments',
|
||||
'foobar' => 'foobars',
|
||||
'newsletter' => 'newsletters',
|
||||
|
||||
'old_news' => 'old_news',
|
||||
|
||||
'perspective' => 'perspectives',
|
||||
|
||||
'photo' => 'photos',
|
||||
'status_code' => 'status_codes',
|
||||
|
||||
'house' => 'houses',
|
||||
'virus' => 'viruses',
|
||||
'portfolio' => 'portfolios',
|
||||
|
||||
'matrix_fu' => 'matrix_fus',
|
||||
|
||||
'axis' => 'axes',
|
||||
|
||||
'shoe' => 'shoes',
|
||||
|
||||
'horse' => 'horses',
|
||||
'edge' => 'edges',
|
||||
|
||||
'cow' => 'cows' # 'kine' is archaic and nobody uses it
|
||||
}
|
||||
|
||||
SingularToPlural.each do |singular, plural|
|
||||
# Missing rule or exception?
|
||||
PENDING = {
|
||||
'cow' => 'cows', # 'kine' is archaic and nobody uses it
|
||||
'virus' => 'viruses',
|
||||
'torpedo' => 'torpedoes',
|
||||
'Swiss' => 'Swiss',
|
||||
'goose' => 'geese',
|
||||
'milk' => 'milk',
|
||||
'plus' => 'plusses',
|
||||
'thesaurus' => 'thesauri',
|
||||
'thief' => 'thieves',
|
||||
'hovercraft' => 'hovercraft',
|
||||
'zero' => 'zeroes',
|
||||
'rain' => 'rain',
|
||||
'cactus' => 'cacti',
|
||||
'moose' => 'moose',
|
||||
'criterion' => 'criteria',
|
||||
'potato' => 'potatoes',
|
||||
'phenomenon' => 'phenomena',
|
||||
'hero' => 'heroes',
|
||||
}
|
||||
|
||||
PENDING.each do |singular, plural|
|
||||
pending "missing exception or rule for #{singular} => #{plural}"
|
||||
end
|
||||
|
||||
SINGULAR_TO_PLURAL.each do |singular, plural|
|
||||
it "pluralizes #{singular} => #{plural}" do
|
||||
Inflector.pluralize(singular).should eql(plural)
|
||||
end
|
||||
|
|
|
@ -3,9 +3,8 @@ require 'spec_helper'
|
|||
describe Inflector, '#singular' do
|
||||
# ==== exceptional cases
|
||||
|
||||
PluralToSingular = {
|
||||
PLURAL_TO_SINGULAR = {
|
||||
'equipment' => 'equipment',
|
||||
'postgres' => 'postgres',
|
||||
'mysql' => 'mysql',
|
||||
'information' => 'information',
|
||||
'money' => 'money',
|
||||
|
@ -18,15 +17,9 @@ describe Inflector, '#singular' do
|
|||
'milk' => 'milk',
|
||||
'moose' => 'moose',
|
||||
'hovercraft' => 'hovercraft',
|
||||
'cacti' => 'cactus',
|
||||
'cactuses' => 'cactus',
|
||||
'thesauri' => 'thesaurus',
|
||||
'matrices' => 'matrix',
|
||||
'Swiss' => 'Swiss',
|
||||
'lives' => 'life',
|
||||
'wives' => 'wife',
|
||||
'geese' => 'goose',
|
||||
'criteria' => 'criterion',
|
||||
'aliases' => 'alias',
|
||||
'statuses' => 'status',
|
||||
'axes' => 'axis',
|
||||
|
@ -46,12 +39,9 @@ describe Inflector, '#singular' do
|
|||
'mice' => 'mouse',
|
||||
'lice' => 'louse',
|
||||
'theses' => 'thesis',
|
||||
'thieves' => 'thief',
|
||||
'analyses' => 'analysis',
|
||||
'octopi' => 'octopus',
|
||||
'grass' => 'grass',
|
||||
'phenomena' => 'phenomenon',
|
||||
'drives' => 'drive',
|
||||
# ==== bugs, typos and reported issues
|
||||
|
||||
# ==== rules
|
||||
|
@ -89,7 +79,6 @@ describe Inflector, '#singular' do
|
|||
'foxes' => 'fox',
|
||||
'elves' => 'elf',
|
||||
'shelves' => 'shelf',
|
||||
'pluses' => 'plus',
|
||||
'cats' => 'cat',
|
||||
'rats' => 'rat',
|
||||
'roses' => 'rose',
|
||||
|
@ -137,7 +126,26 @@ describe Inflector, '#singular' do
|
|||
'rice' => 'rice'
|
||||
}
|
||||
|
||||
PluralToSingular.each do |plural, singular|
|
||||
# Missing exceptions or missing rules?
|
||||
PENDING = {
|
||||
'cacti' => 'cactus',
|
||||
'cactuses' => 'cactus',
|
||||
'thesauri' => 'thesaurus',
|
||||
'geese' => 'goose',
|
||||
'phenomena' => 'phenomenon',
|
||||
'Swiss' => 'Swiss',
|
||||
'drives' => 'drive',
|
||||
'pluses' => 'plus',
|
||||
'thieves' => 'thief',
|
||||
'criteria' => 'criterion',
|
||||
'postgres' => 'postgres'
|
||||
}
|
||||
|
||||
PENDING.each do |plural, singular|
|
||||
pending "mssing rule or exception for #{plural} => #{singular}"
|
||||
end
|
||||
|
||||
PLURAL_TO_SINGULAR.each do |plural, singular|
|
||||
it "should signularize #{plural} => #{singular}" do
|
||||
Inflector.singularize(plural).should eql(singular)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue