inflections 3.3.0 → 4.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/CHANGELOG.markdown +2 -15
- data/Gemfile +0 -1
- data/README.markdown +23 -22
- data/Rakefile +1 -7
- data/inflections.gemspec +1 -1
- data/lib/inflections.rb +6 -1
- data/lib/inflections/en-GB.rb +22 -0
- data/lib/inflections/en.rb +22 -0
- data/lib/inflections/es.rb +1 -1
- data/lib/inflections/kk.rb +1 -1
- data/lib/inflections/nb.rb +1 -1
- data/lib/inflections/tr.rb +1 -1
- data/lib/inflections/version.rb +4 -3
- data/test/en-GB_test.rb +70 -0
- data/test/en_test.rb +70 -0
- data/test/es_test.rb +14 -14
- data/test/kk_test.rb +22 -22
- data/test/nb_test.rb +16 -16
- data/test/test_helper.rb +0 -3
- data/test/tr_test.rb +18 -18
- metadata +22 -21
- data/lib/inflections/fr.rb +0 -31
- data/lib/inflections/railtie.rb +0 -15
- data/test/fr_test.rb +0 -67
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2acbe516c4c7093e03e0a6107d6ae84d2e08a10
|
4
|
+
data.tar.gz: a2a35cb0666b7c59731b860be9dbf8d8454ef188
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bfa96dfbda73265a7290fdd1db2404cb43e65f0e9a4ed52708314485a5d6585a65e4226d11f14bcd94f0f0e88e1588da01351e6b96d11ec346623e01ba13234d
|
7
|
+
data.tar.gz: a9cf7136d9bc73ceef4afdef06ae72b7c80cb78b9b39e155d2b82da121bf8a7eb9a2f040ab056da8ad24d10380396ec01deed6699a495da56c77af2061580afc
|
data/.travis.yml
CHANGED
data/CHANGELOG.markdown
CHANGED
@@ -1,17 +1,5 @@
|
|
1
|
-
3.2.
|
2
|
-
|
3
|
-
* Support for French (thanks to [Olivier Laviale](https://github.com/olvlvl) of [ICanBoogie](https://github.com/ICanBoogie/Inflector))
|
4
|
-
|
5
|
-
3.2.12.20130305
|
6
|
-
===============
|
7
|
-
* Fix #9 - a bug that was causing all strings to pluralize and singularize in Turkish.
|
8
|
-
|
9
|
-
3.2.12
|
10
|
-
======
|
11
|
-
* Support for Turkish (thanks to [Ferhat Elmas](https://github.com/ferhatelmas))
|
12
|
-
|
13
|
-
3.2.9.20121206
|
14
|
-
==============
|
1
|
+
3.2.9.20121206 (current version)
|
2
|
+
================================
|
15
3
|
* Support for Kazakh (thanks to [Galymzhan Kozhayev](https://github.com/galymzhan))
|
16
4
|
|
17
5
|
3.2.9
|
@@ -20,7 +8,6 @@
|
|
20
8
|
|
21
9
|
3.2.8
|
22
10
|
=====
|
23
|
-
>>>>>>> 6a241a8... Update docs to reflect Kazakh support
|
24
11
|
* Support for British English (thanks to [creativetags](https://github.com/creativetags))
|
25
12
|
* Now versioning alongside ActiveSupport
|
26
13
|
|
data/Gemfile
CHANGED
data/README.markdown
CHANGED
@@ -1,25 +1,17 @@
|
|
1
1
|
# Inflections [![Build Status](https://secure.travis-ci.org/davidcelis/inflections.png)](http://travis-ci.org/davidcelis/inflections)
|
2
2
|
|
3
|
-
|
3
|
+
This gem's purpose is twofold: to remove the cruft from ActiveSupport's inflections and provide a more sane set of defaults for Ruby/Rails applications in English while also providing default rules for other languages.
|
4
4
|
|
5
|
-
|
5
|
+
At the time of this gem's publication, the English list of inflections in ActiveSupport is a mess. It is riddled with special cases such as a special pluralization rule for "octopus" and "virus", even though they follow a regular rule (as octopi and viri are disputed terms). Similar pluralization rules exist for "ox", "quiz", "mouse", "louse", etc.
|
6
6
|
|
7
|
-
|
8
|
-
* British English (en-GB)
|
9
|
-
* Spanish (es)
|
10
|
-
* French (fr)
|
11
|
-
* Kazakh (kk)
|
12
|
-
* Norwegian Bokmål (nb)
|
13
|
-
* Turkish (tr)
|
14
|
-
|
15
|
-
If you are fluent in a language not yet included in this gem, _please_ consider creating a list of inflections and submitting a pull request.
|
7
|
+
Many of the special cases that ActiveSupport defines will not see the light of day in an application. Other rules exist that are actually gramatical exceptions, such as changing "f" to a "v" when encountered at the end of the word (which then requires even more rules to fix special words such as "drive", "safe", "hive", etc.). And, of course, who can forget the special pluralization of "cow" to the archaic term of Scottish origin, "kine" (the plural of "kye")?
|
16
8
|
|
17
9
|
## Installation
|
18
10
|
|
19
11
|
Add the following to your application's Gemfile:
|
20
12
|
|
21
13
|
```ruby
|
22
|
-
gem 'inflections'
|
14
|
+
gem 'inflections'
|
23
15
|
```
|
24
16
|
|
25
17
|
And then execute:
|
@@ -32,33 +24,42 @@ $ bundle
|
|
32
24
|
|
33
25
|
### Ruby on Rails
|
34
26
|
|
35
|
-
If you're using Rails, you're done. The default inflections defined in ActiveSupport will be overwritten, and you can continue to define your own special cases in `config/intializers/inflections.rb`. I18n's default locale (set in `config/application.rb`) will determine which inflections are loaded.
|
36
|
-
|
37
|
-
```ruby
|
38
|
-
gem 'inflections', require: 'inflections/es'
|
39
|
-
```
|
40
|
-
|
41
|
-
Note that this will override the default set of English rules that come with Rails. You should do this only if you plan on your constants and code itself not being in English. If you wish for your code itself to remain in English, it's recommended that you do not include this gem.
|
27
|
+
If you're using Rails, you're done. The default inflections defined in ActiveSupport will be overwritten, and you can continue to define your own special cases in `config/intializers/inflections.rb`. I18n's default locale (set in `config/application.rb`) will determine which inflections are loaded.
|
42
28
|
|
43
29
|
### Otherwise
|
44
30
|
|
45
31
|
Wherever you need 'em:
|
46
32
|
|
47
33
|
```ruby
|
48
|
-
require 'inflections/
|
34
|
+
require 'inflections/en' # Replace 'en' with your preferred locale.
|
49
35
|
```
|
50
36
|
|
51
|
-
Define your own
|
37
|
+
Define your own additional rules as such:
|
52
38
|
|
53
39
|
```ruby
|
54
40
|
ActiveSupport::Inflector.inflections do |inflect|
|
55
|
-
inflect.singular /(phase)s$/i, '\1'
|
41
|
+
inflect.singular /(phase)s$/i, '\1'
|
56
42
|
inflect.plural /(shel|kni)fe/, '\1ves'
|
57
43
|
inflect.irregular 'foot', 'feet'
|
58
44
|
inflect.uncountable %w( money )
|
59
45
|
end
|
60
46
|
```
|
61
47
|
|
48
|
+
### Edge
|
49
|
+
|
50
|
+
If you're using the edge version of ActiveSupport (4.0.0.beta), the multilingual Inflector will be supported. You can use each set of inflection rules without needing to require them or worry about conflicts between languages. Just point your Gemfile to this git repository; each locale's set of inflection rules will be kept separately and you can use any of them side-by-side. [Read more about the multilingual Inflector](http://davidcelis.com/blog/2012/07/31/edge-rails-a-multilingual-inflector/).
|
51
|
+
|
52
|
+
## Languages Currently Supported
|
53
|
+
|
54
|
+
* English (en)
|
55
|
+
* British English (en-GB)
|
56
|
+
* Spanish (es)
|
57
|
+
* Kazakh (kk)
|
58
|
+
* Norwegian Bokmål (nb)
|
59
|
+
* Turkish (tr)
|
60
|
+
|
61
|
+
If you are fluent in a language not yet included in this gem, _please_ consider creating a list of inflections and submitting a pull request.
|
62
|
+
|
62
63
|
## Contributing
|
63
64
|
|
64
65
|
Please note that pull requests for already supported languages will only be accepted for rules that are in error or a potentially missed rule. If your change is an exception to an existing rule, that exception must occur _frequently_ and must involve words used more frequently than the regular plurals. If your change is an irregularity, it must be a word that is arguably _frequently_ encountered in applications that would use ActiveSupport. The default list of inflections is meant to be short.
|
data/Rakefile
CHANGED
@@ -4,14 +4,8 @@ require 'bundler/gem_tasks'
|
|
4
4
|
require 'rake/testtask'
|
5
5
|
|
6
6
|
task :default => :test
|
7
|
-
task :test do
|
8
|
-
Dir.glob('test/*_test.rb').each do |test_file|
|
9
|
-
ENV['TEST'] = test_file
|
10
|
-
Rake::Task['each_test'].execute
|
11
|
-
end
|
12
|
-
end
|
13
7
|
|
14
|
-
Rake::TestTask.new(:
|
8
|
+
Rake::TestTask.new(:test) do |t|
|
15
9
|
t.libs << 'test'
|
16
10
|
t.test_files = Dir.glob('test/*_test.rb')
|
17
11
|
t.verbose = true
|
data/inflections.gemspec
CHANGED
data/lib/inflections.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
module Inflections
|
2
|
+
ActiveSupport::Inflector.inflections(:'en-GB') do |inflect|
|
3
|
+
inflect.clear
|
4
|
+
|
5
|
+
inflect.plural(/$/, 's')
|
6
|
+
inflect.plural(/([sxz]|[cs]h)$/i, '\1es')
|
7
|
+
inflect.plural(/([^aeiouy]o)$/i, '\1es')
|
8
|
+
inflect.plural(/([^aeiouy])y$/i, '\1ies')
|
9
|
+
|
10
|
+
inflect.singular(/s$/i, '')
|
11
|
+
inflect.singular(/(ss)$/i, '\1')
|
12
|
+
inflect.singular(/([sxz]|[cs]h)es$/, '\1')
|
13
|
+
inflect.singular(/([^aeiouy]o)es$/, '\1')
|
14
|
+
inflect.singular(/([^aeiouy])ies$/i, '\1y')
|
15
|
+
|
16
|
+
inflect.irregular('child', 'children')
|
17
|
+
inflect.irregular('person', 'people')
|
18
|
+
inflect.irregular('self', 'selves')
|
19
|
+
|
20
|
+
inflect.uncountable(%w(series))
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Inflections
|
2
|
+
ActiveSupport::Inflector.inflections(:en) do |inflect|
|
3
|
+
inflect.clear
|
4
|
+
|
5
|
+
inflect.plural(/$/, 's')
|
6
|
+
inflect.plural(/([sxz]|[cs]h)$/i, '\1es')
|
7
|
+
inflect.plural(/([^aeiouy]o)$/i, '\1es')
|
8
|
+
inflect.plural(/([^aeiouy])y$/i, '\1ies')
|
9
|
+
|
10
|
+
inflect.singular(/s$/i, '')
|
11
|
+
inflect.singular(/(ss)$/i, '\1')
|
12
|
+
inflect.singular(/([sxz]|[cs]h)es$/, '\1')
|
13
|
+
inflect.singular(/([^aeiouy]o)es$/, '\1')
|
14
|
+
inflect.singular(/([^aeiouy])ies$/i, '\1y')
|
15
|
+
|
16
|
+
inflect.irregular('child', 'children')
|
17
|
+
inflect.irregular('person', 'people')
|
18
|
+
inflect.irregular('self', 'selves')
|
19
|
+
|
20
|
+
inflect.uncountable(%w(series))
|
21
|
+
end
|
22
|
+
end
|
data/lib/inflections/es.rb
CHANGED
data/lib/inflections/kk.rb
CHANGED
data/lib/inflections/nb.rb
CHANGED
data/lib/inflections/tr.rb
CHANGED
data/lib/inflections/version.rb
CHANGED
data/test/en-GB_test.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'inflections/en-GB'
|
3
|
+
|
4
|
+
class TestEnglishInflections < MiniTest::Unit::TestCase
|
5
|
+
def test_regular_plurals
|
6
|
+
assert_equal 'dogs', 'dog'.pluralize(:'en-GB')
|
7
|
+
assert_equal 'dog', 'dogs'.singularize(:'en-GB')
|
8
|
+
|
9
|
+
assert_equal 'days', 'day'.pluralize(:'en-GB')
|
10
|
+
assert_equal 'day', 'days'.singularize(:'en-GB')
|
11
|
+
|
12
|
+
assert_equal 'tests', 'test'.pluralize(:'en-GB')
|
13
|
+
assert_equal 'test', 'tests'.singularize(:'en-GB')
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_sibilant_sounds
|
17
|
+
assert_equal 'addresses', 'address'.pluralize(:'en-GB')
|
18
|
+
assert_equal 'address', 'addresses'.singularize(:'en-GB')
|
19
|
+
|
20
|
+
assert_equal 'phases', 'phase'.pluralize(:'en-GB')
|
21
|
+
|
22
|
+
assert_equal 'buzzes', 'buzz'.pluralize(:'en-GB')
|
23
|
+
assert_equal 'buzz', 'buzzes'.singularize(:'en-GB')
|
24
|
+
|
25
|
+
assert_equal 'boxes', 'box'.pluralize(:'en-GB')
|
26
|
+
assert_equal 'box', 'boxes'.singularize(:'en-GB')
|
27
|
+
|
28
|
+
assert_equal 'benches', 'bench'.pluralize(:'en-GB')
|
29
|
+
assert_equal 'bench', 'benches'.singularize(:'en-GB')
|
30
|
+
|
31
|
+
assert_equal 'dishes', 'dish'.pluralize(:'en-GB')
|
32
|
+
assert_equal 'dish', 'dishes'.singularize(:'en-GB')
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_oes_rule
|
36
|
+
assert_equal 'heroes', 'hero'.pluralize(:'en-GB')
|
37
|
+
assert_equal 'hero', 'heroes'.singularize(:'en-GB')
|
38
|
+
|
39
|
+
assert_equal 'igloos', 'igloo'.pluralize(:'en-GB')
|
40
|
+
assert_equal 'igloo', 'igloos'.singularize(:'en-GB')
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_ies_rule
|
44
|
+
assert_equal 'berries', 'berry'.pluralize(:'en-GB')
|
45
|
+
assert_equal 'berry', 'berries'.singularize(:'en-GB')
|
46
|
+
|
47
|
+
assert_equal 'days', 'day'.pluralize(:'en-GB')
|
48
|
+
assert_equal 'day', 'days'.singularize(:'en-GB')
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_irregulars
|
52
|
+
assert_equal 'children', 'child'.pluralize(:'en-GB')
|
53
|
+
assert_equal 'child', 'children'.singularize(:'en-GB')
|
54
|
+
|
55
|
+
assert_equal 'people', 'person'.pluralize(:'en-GB')
|
56
|
+
assert_equal 'person', 'people'.singularize(:'en-GB')
|
57
|
+
|
58
|
+
assert_equal 'selves', 'self'.pluralize(:'en-GB')
|
59
|
+
assert_equal 'self', 'selves'.singularize(:'en-GB')
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_uncountables
|
63
|
+
assert_equal 'series', 'series'.pluralize(:'en-GB')
|
64
|
+
assert_equal 'series', 'series'.singularize(:'en-GB')
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_stupid_inflections_removed
|
68
|
+
assert_equal 'cows', 'cow'.pluralize(:'en-GB')
|
69
|
+
end
|
70
|
+
end
|
data/test/en_test.rb
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'inflections/en'
|
3
|
+
|
4
|
+
class TestEnglishInflections < MiniTest::Unit::TestCase
|
5
|
+
def test_regular_plurals
|
6
|
+
assert_equal 'dogs', 'dog'.pluralize(:en)
|
7
|
+
assert_equal 'dog', 'dogs'.singularize(:en)
|
8
|
+
|
9
|
+
assert_equal 'days', 'day'.pluralize(:en)
|
10
|
+
assert_equal 'day', 'days'.singularize(:en)
|
11
|
+
|
12
|
+
assert_equal 'tests', 'test'.pluralize(:en)
|
13
|
+
assert_equal 'test', 'tests'.singularize(:en)
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_sibilant_sounds
|
17
|
+
assert_equal 'addresses', 'address'.pluralize(:en)
|
18
|
+
assert_equal 'address', 'addresses'.singularize(:en)
|
19
|
+
|
20
|
+
assert_equal 'phases', 'phase'.pluralize(:en)
|
21
|
+
|
22
|
+
assert_equal 'buzzes', 'buzz'.pluralize(:en)
|
23
|
+
assert_equal 'buzz', 'buzzes'.singularize(:en)
|
24
|
+
|
25
|
+
assert_equal 'boxes', 'box'.pluralize(:en)
|
26
|
+
assert_equal 'box', 'boxes'.singularize(:en)
|
27
|
+
|
28
|
+
assert_equal 'benches', 'bench'.pluralize(:en)
|
29
|
+
assert_equal 'bench', 'benches'.singularize(:en)
|
30
|
+
|
31
|
+
assert_equal 'dishes', 'dish'.pluralize(:en)
|
32
|
+
assert_equal 'dish', 'dishes'.singularize(:en)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_oes_rule
|
36
|
+
assert_equal 'heroes', 'hero'.pluralize(:en)
|
37
|
+
assert_equal 'hero', 'heroes'.singularize(:en)
|
38
|
+
|
39
|
+
assert_equal 'igloos', 'igloo'.pluralize(:en)
|
40
|
+
assert_equal 'igloo', 'igloos'.singularize(:en)
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_ies_rule
|
44
|
+
assert_equal 'berries', 'berry'.pluralize(:en)
|
45
|
+
assert_equal 'berry', 'berries'.singularize(:en)
|
46
|
+
|
47
|
+
assert_equal 'days', 'day'.pluralize(:en)
|
48
|
+
assert_equal 'day', 'days'.singularize(:en)
|
49
|
+
end
|
50
|
+
|
51
|
+
def test_irregulars
|
52
|
+
assert_equal 'children', 'child'.pluralize(:en)
|
53
|
+
assert_equal 'child', 'children'.singularize(:en)
|
54
|
+
|
55
|
+
assert_equal 'people', 'person'.pluralize(:en)
|
56
|
+
assert_equal 'person', 'people'.singularize(:en)
|
57
|
+
|
58
|
+
assert_equal 'selves', 'self'.pluralize(:en)
|
59
|
+
assert_equal 'self', 'selves'.singularize(:en)
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_uncountables
|
63
|
+
assert_equal 'series', 'series'.pluralize(:en)
|
64
|
+
assert_equal 'series', 'series'.singularize(:en)
|
65
|
+
end
|
66
|
+
|
67
|
+
def test_stupid_inflections_removed
|
68
|
+
assert_equal 'cows', 'cow'.pluralize(:en)
|
69
|
+
end
|
70
|
+
end
|
data/test/es_test.rb
CHANGED
@@ -5,31 +5,31 @@ require 'inflections/es'
|
|
5
5
|
|
6
6
|
class TestSpanishInflections < MiniTest::Unit::TestCase
|
7
7
|
def test_plurales_regulares
|
8
|
-
assert_equal 'libros', 'libro'.pluralize
|
9
|
-
assert_equal 'libro', 'libros'.singularize
|
8
|
+
assert_equal 'libros', 'libro'.pluralize(:es)
|
9
|
+
assert_equal 'libro', 'libros'.singularize(:es)
|
10
10
|
|
11
|
-
assert_equal 'radios', 'radio'.pluralize
|
12
|
-
assert_equal 'radio', 'radios'.singularize
|
11
|
+
assert_equal 'radios', 'radio'.pluralize(:es)
|
12
|
+
assert_equal 'radio', 'radios'.singularize(:es)
|
13
13
|
|
14
|
-
assert_equal 'señores', 'señor'.pluralize
|
15
|
-
assert_equal 'señor', 'señores'.singularize
|
14
|
+
assert_equal 'señores', 'señor'.pluralize(:es)
|
15
|
+
assert_equal 'señor', 'señores'.singularize(:es)
|
16
16
|
|
17
|
-
assert_equal 'leyes', 'ley'.pluralize
|
18
|
-
assert_equal 'ley', 'leyes'.singularize
|
17
|
+
assert_equal 'leyes', 'ley'.pluralize(:es)
|
18
|
+
assert_equal 'ley', 'leyes'.singularize(:es)
|
19
19
|
end
|
20
20
|
|
21
21
|
def test_plurales_que_terminar_en_z
|
22
|
-
assert_equal 'meces', 'mez'.pluralize
|
23
|
-
assert_equal 'luces', 'luz'.pluralize
|
22
|
+
assert_equal 'meces', 'mez'.pluralize(:es)
|
23
|
+
assert_equal 'luces', 'luz'.pluralize(:es)
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_plurales_que_terminar_en_n_o_s_con_acentos
|
27
|
-
assert_equal 'aviones', 'avión'.pluralize
|
28
|
-
assert_equal 'intereses', 'interés'.pluralize
|
27
|
+
assert_equal 'aviones', 'avión'.pluralize(:es)
|
28
|
+
assert_equal 'intereses', 'interés'.pluralize(:es)
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_plurales_irregulares
|
32
|
-
assert_equal 'los', 'el'.pluralize
|
33
|
-
assert_equal 'el', 'los'.singularize
|
32
|
+
assert_equal 'los', 'el'.pluralize(:es)
|
33
|
+
assert_equal 'el', 'los'.singularize(:es)
|
34
34
|
end
|
35
35
|
end
|
data/test/kk_test.rb
CHANGED
@@ -5,43 +5,43 @@ require 'inflections/kk'
|
|
5
5
|
|
6
6
|
class TestKazakhInflections < MiniTest::Unit::TestCase
|
7
7
|
def test_voiceless
|
8
|
-
assert_equal 'сабақтар', 'сабақ'.pluralize
|
9
|
-
assert_equal 'сабақ', 'сабақтар'.singularize
|
8
|
+
assert_equal 'сабақтар', 'сабақ'.pluralize(:kk)
|
9
|
+
assert_equal 'сабақ', 'сабақтар'.singularize(:kk)
|
10
10
|
|
11
|
-
assert_equal 'мектептер', 'мектеп'.pluralize
|
12
|
-
assert_equal 'мектеп', 'мектептер'.singularize
|
11
|
+
assert_equal 'мектептер', 'мектеп'.pluralize(:kk)
|
12
|
+
assert_equal 'мектеп', 'мектептер'.singularize(:kk)
|
13
13
|
end
|
14
14
|
|
15
15
|
def test_voiced
|
16
|
-
assert_equal 'қағаздар', 'қағаз'.pluralize
|
17
|
-
assert_equal 'қағаз', 'қағаздар'.singularize
|
16
|
+
assert_equal 'қағаздар', 'қағаз'.pluralize(:kk)
|
17
|
+
assert_equal 'қағаз', 'қағаздар'.singularize(:kk)
|
18
18
|
|
19
|
-
assert_equal 'кілемдер', 'кілем'.pluralize
|
20
|
-
assert_equal 'кілем', 'кілемдер'.singularize
|
19
|
+
assert_equal 'кілемдер', 'кілем'.pluralize(:kk)
|
20
|
+
assert_equal 'кілем', 'кілемдер'.singularize(:kk)
|
21
21
|
|
22
|
-
assert_equal 'гүлдер', 'гүл'.pluralize
|
23
|
-
assert_equal 'гүл', 'гүлдер'.singularize
|
22
|
+
assert_equal 'гүлдер', 'гүл'.pluralize(:kk)
|
23
|
+
assert_equal 'гүл', 'гүлдер'.singularize(:kk)
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_sonor
|
27
|
-
assert_equal 'балалар', 'бала'.pluralize
|
28
|
-
assert_equal 'бала', 'балалар'.singularize
|
27
|
+
assert_equal 'балалар', 'бала'.pluralize(:kk)
|
28
|
+
assert_equal 'бала', 'балалар'.singularize(:kk)
|
29
29
|
|
30
|
-
assert_equal 'дәрігерлер', 'дәрігер'.pluralize
|
31
|
-
assert_equal 'дәрігер', 'дәрігерлер'.singularize
|
30
|
+
assert_equal 'дәрігерлер', 'дәрігер'.pluralize(:kk)
|
31
|
+
assert_equal 'дәрігер', 'дәрігерлер'.singularize(:kk)
|
32
32
|
|
33
|
-
assert_equal 'үйлер', 'үй'.pluralize
|
34
|
-
assert_equal 'үй', 'үйлер'.singularize
|
33
|
+
assert_equal 'үйлер', 'үй'.pluralize(:kk)
|
34
|
+
assert_equal 'үй', 'үйлер'.singularize(:kk)
|
35
35
|
|
36
|
-
assert_equal 'ескертулер', 'ескерту'.pluralize
|
37
|
-
assert_equal 'ескерту', 'ескертулер'.singularize
|
36
|
+
assert_equal 'ескертулер', 'ескерту'.pluralize(:kk)
|
37
|
+
assert_equal 'ескерту', 'ескертулер'.singularize(:kk)
|
38
38
|
|
39
|
-
assert_equal 'аурулар', 'ауру'.pluralize
|
40
|
-
assert_equal 'ауру', 'аурулар'.singularize
|
39
|
+
assert_equal 'аурулар', 'ауру'.pluralize(:kk)
|
40
|
+
assert_equal 'ауру', 'аурулар'.singularize(:kk)
|
41
41
|
end
|
42
42
|
|
43
43
|
def test_looks_like_plural
|
44
|
-
assert_equal 'дәптерлер', 'дәптер'.pluralize
|
45
|
-
assert_equal 'дәптер', 'дәптерлер'.singularize
|
44
|
+
assert_equal 'дәптерлер', 'дәптер'.pluralize(:kk)
|
45
|
+
assert_equal 'дәптер', 'дәптерлер'.singularize(:kk)
|
46
46
|
end
|
47
47
|
end
|
data/test/nb_test.rb
CHANGED
@@ -5,35 +5,35 @@ require 'inflections/nb'
|
|
5
5
|
|
6
6
|
class TestNorwegianBokmalInflections < MiniTest::Unit::TestCase
|
7
7
|
def test_svake_substantiv_er
|
8
|
-
assert_equal 'hunder', 'hund'.pluralize
|
9
|
-
assert_equal 'hund', 'hunder'.singularize
|
8
|
+
assert_equal 'hunder', 'hund'.pluralize(:nb)
|
9
|
+
assert_equal 'hund', 'hunder'.singularize(:nb)
|
10
10
|
|
11
|
-
assert_equal 'dager', 'dag'.pluralize
|
12
|
-
assert_equal 'dag', 'dager'.singularize
|
11
|
+
assert_equal 'dager', 'dag'.pluralize(:nb)
|
12
|
+
assert_equal 'dag', 'dager'.singularize(:nb)
|
13
13
|
|
14
|
-
assert_equal 'tester', 'test'.pluralize
|
15
|
-
assert_equal 'test', 'tester'.singularize
|
14
|
+
assert_equal 'tester', 'test'.pluralize(:nb)
|
15
|
+
assert_equal 'test', 'tester'.singularize(:nb)
|
16
16
|
end
|
17
17
|
|
18
18
|
def test_svake_substantiv_r
|
19
|
-
assert_equal 'lærere', 'lærer'.pluralize
|
20
|
-
assert_equal 'lærer', 'lærere'.singularize
|
19
|
+
assert_equal 'lærere', 'lærer'.pluralize(:nb)
|
20
|
+
assert_equal 'lærer', 'lærere'.singularize(:nb)
|
21
21
|
|
22
|
-
assert_equal 'kalendere', 'kalender'.pluralize
|
23
|
-
assert_equal 'kalender', 'kalendere'.singularize
|
22
|
+
assert_equal 'kalendere', 'kalender'.pluralize(:nb)
|
23
|
+
assert_equal 'kalender', 'kalendere'.singularize(:nb)
|
24
24
|
end
|
25
25
|
|
26
26
|
def test_svake_substantiv_e
|
27
|
-
assert_equal 'bakker', 'bakke'.pluralize
|
27
|
+
assert_equal 'bakker', 'bakke'.pluralize(:nb)
|
28
28
|
# TODO: Fix this. How do we keep this form apart from "hunder"?
|
29
|
-
# assert_equal 'bakke', 'bakker'.singularize
|
29
|
+
# assert_equal 'bakke', 'bakker'.singularize(:nb)
|
30
30
|
|
31
|
-
assert_equal 'epler', 'eple'.pluralize
|
32
|
-
# assert_equal 'eple', 'epler'.singularize
|
31
|
+
assert_equal 'epler', 'eple'.pluralize(:nb)
|
32
|
+
# assert_equal 'eple', 'epler'.singularize(:nb)
|
33
33
|
end
|
34
34
|
|
35
35
|
def test_sterke_verb
|
36
|
-
assert_equal 'konti', 'konto'.pluralize
|
37
|
-
assert_equal 'konto', 'konti'.singularize
|
36
|
+
assert_equal 'konti', 'konto'.pluralize(:nb)
|
37
|
+
assert_equal 'konto', 'konti'.singularize(:nb)
|
38
38
|
end
|
39
39
|
end
|
data/test/test_helper.rb
CHANGED
data/test/tr_test.rb
CHANGED
@@ -5,33 +5,33 @@ require 'inflections/tr'
|
|
5
5
|
|
6
6
|
class TestTurkishInflections < MiniTest::Unit::TestCase
|
7
7
|
def test_regular_plurals
|
8
|
-
assert_equal 'günler', 'gün'.pluralize
|
9
|
-
assert_equal 'gün', 'günler'.singularize
|
8
|
+
assert_equal 'günler', 'gün'.pluralize(:tr)
|
9
|
+
assert_equal 'gün', 'günler'.singularize(:tr)
|
10
10
|
|
11
|
-
assert_equal 'kirazlar', 'kiraz'.pluralize
|
12
|
-
assert_equal 'kiraz', 'kirazlar'.singularize
|
11
|
+
assert_equal 'kirazlar', 'kiraz'.pluralize(:tr)
|
12
|
+
assert_equal 'kiraz', 'kirazlar'.singularize(:tr)
|
13
13
|
|
14
|
-
assert_equal 'kitaplar', 'kitap'.pluralize
|
15
|
-
assert_equal 'kitap', 'kitaplar'.singularize
|
14
|
+
assert_equal 'kitaplar', 'kitap'.pluralize(:tr)
|
15
|
+
assert_equal 'kitap', 'kitaplar'.singularize(:tr)
|
16
16
|
|
17
|
-
assert_equal 'köpekler', 'köpek'.pluralize
|
18
|
-
assert_equal 'köpek', 'köpekler'.singularize
|
17
|
+
assert_equal 'köpekler', 'köpek'.pluralize(:tr)
|
18
|
+
assert_equal 'köpek', 'köpekler'.singularize(:tr)
|
19
19
|
|
20
|
-
assert_equal 'testler', 'test'.pluralize
|
21
|
-
assert_equal 'test', 'testler'.singularize
|
20
|
+
assert_equal 'testler', 'test'.pluralize(:tr)
|
21
|
+
assert_equal 'test', 'testler'.singularize(:tr)
|
22
22
|
|
23
|
-
assert_equal 'üçgenler', 'üçgen'.pluralize
|
24
|
-
assert_equal 'üçgen', 'üçgenler'.singularize
|
23
|
+
assert_equal 'üçgenler', 'üçgen'.pluralize(:tr)
|
24
|
+
assert_equal 'üçgen', 'üçgenler'.singularize(:tr)
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_irregulars
|
28
|
-
assert_equal 'biz', 'ben'.pluralize
|
29
|
-
assert_equal 'ben', 'biz'.singularize
|
28
|
+
assert_equal 'biz', 'ben'.pluralize(:tr)
|
29
|
+
assert_equal 'ben', 'biz'.singularize(:tr)
|
30
30
|
|
31
|
-
assert_equal 'siz', 'sen'.pluralize
|
32
|
-
assert_equal 'sen', 'siz'.singularize
|
31
|
+
assert_equal 'siz', 'sen'.pluralize(:tr)
|
32
|
+
assert_equal 'sen', 'siz'.singularize(:tr)
|
33
33
|
|
34
|
-
assert_equal 'o', 'onlar'.singularize
|
35
|
-
assert_equal 'onlar', 'o'.pluralize
|
34
|
+
assert_equal 'o', 'onlar'.singularize(:tr)
|
35
|
+
assert_equal 'onlar', 'o'.pluralize(:tr)
|
36
36
|
end
|
37
37
|
end
|
metadata
CHANGED
@@ -1,57 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inflections
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Celis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2013-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: minitest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - '>='
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - '>='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: activesupport
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: 4.0.0.beta1
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 4.0.0.beta1
|
55
55
|
description: A better set of singularization and pluralization rules for Ruby/Rails
|
56
56
|
applications using ActiveSupport.
|
57
57
|
email:
|
@@ -60,8 +60,8 @@ executables: []
|
|
60
60
|
extensions: []
|
61
61
|
extra_rdoc_files: []
|
62
62
|
files:
|
63
|
-
-
|
64
|
-
-
|
63
|
+
- .gitignore
|
64
|
+
- .travis.yml
|
65
65
|
- CHANGELOG.markdown
|
66
66
|
- Gemfile
|
67
67
|
- LICENSE
|
@@ -69,15 +69,16 @@ files:
|
|
69
69
|
- Rakefile
|
70
70
|
- inflections.gemspec
|
71
71
|
- lib/inflections.rb
|
72
|
+
- lib/inflections/en-GB.rb
|
73
|
+
- lib/inflections/en.rb
|
72
74
|
- lib/inflections/es.rb
|
73
|
-
- lib/inflections/fr.rb
|
74
75
|
- lib/inflections/kk.rb
|
75
76
|
- lib/inflections/nb.rb
|
76
|
-
- lib/inflections/railtie.rb
|
77
77
|
- lib/inflections/tr.rb
|
78
78
|
- lib/inflections/version.rb
|
79
|
+
- test/en-GB_test.rb
|
80
|
+
- test/en_test.rb
|
79
81
|
- test/es_test.rb
|
80
|
-
- test/fr_test.rb
|
81
82
|
- test/kk_test.rb
|
82
83
|
- test/nb_test.rb
|
83
84
|
- test/test_helper.rb
|
@@ -91,24 +92,24 @@ require_paths:
|
|
91
92
|
- lib
|
92
93
|
required_ruby_version: !ruby/object:Gem::Requirement
|
93
94
|
requirements:
|
94
|
-
- -
|
95
|
+
- - '>='
|
95
96
|
- !ruby/object:Gem::Version
|
96
97
|
version: '0'
|
97
98
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
99
|
requirements:
|
99
|
-
- -
|
100
|
+
- - '>'
|
100
101
|
- !ruby/object:Gem::Version
|
101
|
-
version:
|
102
|
+
version: 1.3.1
|
102
103
|
requirements: []
|
103
104
|
rubyforge_project:
|
104
|
-
rubygems_version: 2.
|
105
|
+
rubygems_version: 2.0.0
|
105
106
|
signing_key:
|
106
107
|
specification_version: 4
|
107
108
|
summary: Sane inflection rules for ActiveSupport.
|
108
109
|
test_files:
|
110
|
+
- test/en-GB_test.rb
|
111
|
+
- test/en_test.rb
|
109
112
|
- test/es_test.rb
|
110
|
-
- test/fr_test.rb
|
111
113
|
- test/kk_test.rb
|
112
114
|
- test/nb_test.rb
|
113
115
|
- test/tr_test.rb
|
114
|
-
has_rdoc:
|
data/lib/inflections/fr.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
#
|
3
|
-
# These rules come from a port of ActiveSupport's Inflector to PHP:
|
4
|
-
# https://github.com/ICanBoogie/Inflector/blob/master/lib/inflections/fr.php
|
5
|
-
|
6
|
-
module Inflections
|
7
|
-
ActiveSupport::Inflector.inflections do |inflect|
|
8
|
-
inflect.clear
|
9
|
-
|
10
|
-
inflect.plural(/$/, 's')
|
11
|
-
inflect.singular(/s$/, '')
|
12
|
-
|
13
|
-
inflect.plural(/(bijou|caillou|chou|genou|hibou|joujou|pou|au|eu|eau)$/, '\1x')
|
14
|
-
inflect.singular(/(bijou|caillou|chou|genou|hibou|joujou|pou|au|eu|eau)x$/, '\1')
|
15
|
-
|
16
|
-
inflect.plural(/(bleu|émeu|landau|lieu|pneu|sarrau)$/, '\1s')
|
17
|
-
inflect.plural(/al$/, 'aux')
|
18
|
-
inflect.plural(/ail$/, 'ails')
|
19
|
-
inflect.singular(/(journ|chev)aux$/, '\1al')
|
20
|
-
inflect.singular(/ails$/, 'ail')
|
21
|
-
|
22
|
-
inflect.plural(/(b|cor|ém|gemm|soupir|trav|vant|vitr)ail$/, '\1aux')
|
23
|
-
inflect.singular(/(b|cor|ém|gemm|soupir|trav|vant|vitr)aux$/, '\1ail')
|
24
|
-
|
25
|
-
inflect.plural(/(s|x|z)$/, '\1')
|
26
|
-
|
27
|
-
inflect.irregular('monsieur', 'messieurs')
|
28
|
-
inflect.irregular('madame', 'mesdames')
|
29
|
-
inflect.irregular('mademoiselle', 'mesdemoiselles')
|
30
|
-
end
|
31
|
-
end
|
data/lib/inflections/railtie.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
module Inflections
|
2
|
-
class Railtie < Rails::Railtie
|
3
|
-
initializer 'inflections.require_inflections' do
|
4
|
-
begin
|
5
|
-
require "inflections/#{Rails.configuration.i18n.default_locale}"
|
6
|
-
rescue LoadError => e
|
7
|
-
if Rails.configuration.i18n.default_locale.nil?
|
8
|
-
warn "Inflections: no default locale set. Defaulting to English (en)."
|
9
|
-
else
|
10
|
-
warn "Inflections: no support for #{Rails.configuration.i18n.default_locale}. Defaulting to English (en)."
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
data/test/fr_test.rb
DELETED
@@ -1,67 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'test_helper'
|
4
|
-
require 'inflections/fr'
|
5
|
-
|
6
|
-
class TestFrenchInflections < MiniTest::Unit::TestCase
|
7
|
-
def test_regular_plurals
|
8
|
-
assert_equal 'amis', 'ami'.pluralize
|
9
|
-
assert_equal 'ami', 'amis'.singularize
|
10
|
-
|
11
|
-
assert_equal 'fidèles', 'fidèle'.pluralize
|
12
|
-
assert_equal 'fidèle', 'fidèles'.singularize
|
13
|
-
|
14
|
-
assert_equal 'rapports', 'rapport'.pluralize
|
15
|
-
assert_equal 'rapport', 'rapports'.singularize
|
16
|
-
end
|
17
|
-
|
18
|
-
def test_appending_x
|
19
|
-
# -au
|
20
|
-
assert_equal 'tuyaux', 'tuyau'.pluralize
|
21
|
-
assert_equal 'tuyau', 'tuyaux'.singularize
|
22
|
-
|
23
|
-
# -ou
|
24
|
-
assert_equal 'genoux', 'genou'.pluralize
|
25
|
-
assert_equal 'genou', 'genoux'.singularize
|
26
|
-
|
27
|
-
# -eu
|
28
|
-
assert_equal 'aveux', 'aveu'.pluralize
|
29
|
-
assert_equal 'aveu', 'aveux'.singularize
|
30
|
-
|
31
|
-
# -eau
|
32
|
-
assert_equal 'nouveaux', 'nouveau'.pluralize
|
33
|
-
assert_equal 'nouveau', 'nouveaux'.singularize
|
34
|
-
end
|
35
|
-
|
36
|
-
def test_exceptions_to_appending_x
|
37
|
-
assert_equal 'bleus', 'bleu'.pluralize
|
38
|
-
assert_equal 'bleu', 'bleus'.singularize
|
39
|
-
|
40
|
-
assert_equal 'landaus', 'landau'.pluralize
|
41
|
-
assert_equal 'landau', 'landaus'.singularize
|
42
|
-
|
43
|
-
assert_equal 'genoux', 'genou'.pluralize
|
44
|
-
assert_equal 'genou', 'genoux'.singularize
|
45
|
-
end
|
46
|
-
|
47
|
-
def test_ending_in_al
|
48
|
-
assert_equal 'journaux', 'journal'.pluralize
|
49
|
-
assert_equal 'journal', 'journaux'.singularize
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_ending_in_ail
|
53
|
-
assert_equal 'détails', 'détail'.pluralize
|
54
|
-
assert_equal 'détail', 'détails'.singularize
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_exceptions_to_ending_in_ail
|
58
|
-
assert_equal 'travaux', 'travail'.pluralize
|
59
|
-
assert_equal 'travail', 'travaux'.singularize
|
60
|
-
|
61
|
-
assert_equal 'baux', 'bail'.pluralize
|
62
|
-
assert_equal 'bail', 'baux'.singularize
|
63
|
-
|
64
|
-
assert_equal 'émaux', 'émail'.pluralize
|
65
|
-
assert_equal 'émail', 'émaux'.singularize
|
66
|
-
end
|
67
|
-
end
|