inflections 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.markdown +6 -2
- data/README.markdown +4 -3
- data/Rakefile +8 -1
- data/inflections.gemspec +0 -1
- data/lib/inflections/en.rb +4 -4
- data/lib/inflections/es.rb +22 -0
- data/lib/inflections/version.rb +1 -1
- data/test/en_test.rb +1 -1
- data/test/es_test.rb +35 -0
- metadata +4 -1
data/CHANGELOG.markdown
CHANGED
@@ -1,5 +1,9 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.4 (current version)
|
2
2
|
=======================
|
3
|
+
* Support for Spanish (es)
|
4
|
+
|
5
|
+
0.0.3
|
6
|
+
=====
|
3
7
|
* Code reorganization. Inflections will now be located under `lib/inflections/` and will be named as according to their I18n abbreviation.
|
4
8
|
* Tests have also been reorganized. They live in the `test/` directory (big surprise) and, like the inflection files, should be named as according to their I18n abbreviation (`en_test.rb`, `es_test.rb`, `de_test.rb`, etc.)
|
5
9
|
|
@@ -9,4 +13,4 @@
|
|
9
13
|
|
10
14
|
0.0.1
|
11
15
|
=====
|
12
|
-
* Initial version: support for English
|
16
|
+
* Initial version: support for English (en)
|
data/README.markdown
CHANGED
@@ -11,7 +11,7 @@ Many of the special cases that ActiveSupport defines will not see the light of d
|
|
11
11
|
Add the following to your application's Gemfile:
|
12
12
|
|
13
13
|
```ruby
|
14
|
-
gem 'inflections', :require => 'inflections/en' # Or replace 'en' with your language's
|
14
|
+
gem 'inflections', :require => 'inflections/en' # Or replace 'en' with your language's I18n abbreviation
|
15
15
|
```
|
16
16
|
|
17
17
|
And then execute:
|
@@ -31,7 +31,7 @@ If you're using Rails, you're done. The default inflections defined in ActiveSup
|
|
31
31
|
Wherever you need 'em:
|
32
32
|
|
33
33
|
```ruby
|
34
|
-
require 'inflections'
|
34
|
+
require 'inflections/en'
|
35
35
|
```
|
36
36
|
|
37
37
|
Define your own defaults as such:
|
@@ -48,8 +48,9 @@ end
|
|
48
48
|
## Languages Currently Supported
|
49
49
|
|
50
50
|
* English (en)
|
51
|
+
* Spanish (es)
|
51
52
|
|
52
|
-
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.
|
53
|
+
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.
|
53
54
|
|
54
55
|
## Contributing
|
55
56
|
|
data/Rakefile
CHANGED
@@ -3,7 +3,14 @@ require 'bundler/gem_tasks'
|
|
3
3
|
require 'rake/testtask'
|
4
4
|
|
5
5
|
task :default => :test
|
6
|
-
|
6
|
+
task :test do
|
7
|
+
Dir.glob('test/*_test.rb').each do |test_file|
|
8
|
+
ENV['TEST'] = test_file
|
9
|
+
Rake::Task['each_test'].execute
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
Rake::TestTask.new(:each_test) do |t|
|
7
14
|
t.libs << 'test'
|
8
15
|
t.test_files = Dir.glob('test/*_test.rb')
|
9
16
|
t.verbose = true
|
data/inflections.gemspec
CHANGED
data/lib/inflections/en.rb
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
module Inflections
|
2
2
|
ActiveSupport::Inflector.inflections do |inflect|
|
3
3
|
inflect.clear
|
4
|
-
|
4
|
+
|
5
5
|
inflect.plural(/$/, 's')
|
6
6
|
inflect.plural(/([sxz]|[cs]h)$/i, '\1es')
|
7
7
|
inflect.plural(/([^aeiouy]o)$/i, '\1es')
|
8
8
|
inflect.plural(/([^aeiouy])y$/i, '\1ies')
|
9
|
-
|
9
|
+
|
10
10
|
inflect.singular(/s$/i, '')
|
11
11
|
inflect.singular(/(ss)$/i, '\1')
|
12
12
|
inflect.singular(/([sxz]|[cs]h)es$/, '\1')
|
13
13
|
inflect.singular(/([^aeiouy]o)es$/, '\1')
|
14
14
|
inflect.singular(/([^aeiouy])ies$/i, '\1y')
|
15
|
-
|
15
|
+
|
16
16
|
inflect.irregular('child', 'children')
|
17
17
|
inflect.irregular('person', 'people')
|
18
18
|
inflect.irregular('self', 'selves')
|
19
|
-
|
19
|
+
|
20
20
|
inflect.uncountable(%w(series))
|
21
21
|
end
|
22
22
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Inflections
|
4
|
+
ActiveSupport::Inflector.inflections do |inflect|
|
5
|
+
inflect.clear
|
6
|
+
|
7
|
+
inflect.plural(/$/, 's')
|
8
|
+
inflect.plural(/([^aeéiou])$/i, '\1es')
|
9
|
+
inflect.plural(/([aeiou]s)$/i, '\1')
|
10
|
+
inflect.plural(/z$/i, 'ces')
|
11
|
+
inflect.plural(/á([sn])$/i, 'a\1es')
|
12
|
+
inflect.plural(/é([sn])$/i, 'e\1es')
|
13
|
+
inflect.plural(/í([sn])$/i, 'i\1es')
|
14
|
+
inflect.plural(/ó([sn])$/i, 'o\1es')
|
15
|
+
inflect.plural(/ú([sn])$/i, 'u\1es')
|
16
|
+
|
17
|
+
inflect.singular(/s$/, '')
|
18
|
+
inflect.singular(/es$/, '')
|
19
|
+
|
20
|
+
inflect.irregular('el', 'los')
|
21
|
+
end
|
22
|
+
end
|
data/lib/inflections/version.rb
CHANGED
data/test/en_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
require 'inflections/en'
|
3
3
|
|
4
|
-
class
|
4
|
+
class TestEnglishInflections < MiniTest::Unit::TestCase
|
5
5
|
def test_regular_plurals
|
6
6
|
assert_equal 'dogs', 'dog'.pluralize
|
7
7
|
assert_equal 'dog', 'dogs'.singularize
|
data/test/es_test.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'test_helper'
|
4
|
+
require 'inflections/es'
|
5
|
+
|
6
|
+
class TestSpanishInflections < MiniTest::Unit::TestCase
|
7
|
+
def test_plurales_regulares
|
8
|
+
assert_equal 'libros', 'libro'.pluralize
|
9
|
+
assert_equal 'libro', 'libros'.singularize
|
10
|
+
|
11
|
+
assert_equal 'radios', 'radio'.pluralize
|
12
|
+
assert_equal 'radio', 'radios'.singularize
|
13
|
+
|
14
|
+
assert_equal 'señores', 'señor'.pluralize
|
15
|
+
assert_equal 'señor', 'señores'.singularize
|
16
|
+
|
17
|
+
assert_equal 'leyes', 'ley'.pluralize
|
18
|
+
assert_equal 'ley', 'leyes'.singularize
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_plurales_que_terminar_en_z
|
22
|
+
assert_equal 'meces', 'mez'.pluralize
|
23
|
+
assert_equal 'luces', 'luz'.pluralize
|
24
|
+
end
|
25
|
+
|
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
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_plurales_irregulares
|
32
|
+
assert_equal 'los', 'el'.pluralize
|
33
|
+
assert_equal 'el', 'los'.singularize
|
34
|
+
end
|
35
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inflections
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -76,8 +76,10 @@ files:
|
|
76
76
|
- Rakefile
|
77
77
|
- inflections.gemspec
|
78
78
|
- lib/inflections/en.rb
|
79
|
+
- lib/inflections/es.rb
|
79
80
|
- lib/inflections/version.rb
|
80
81
|
- test/en_test.rb
|
82
|
+
- test/es_test.rb
|
81
83
|
- test/test_helper.rb
|
82
84
|
homepage: https://github.com/davidcelis/inflections
|
83
85
|
licenses: []
|
@@ -105,3 +107,4 @@ specification_version: 3
|
|
105
107
|
summary: Sane inflection rules for ActiveSupport.
|
106
108
|
test_files:
|
107
109
|
- test/en_test.rb
|
110
|
+
- test/es_test.rb
|