inflections 3.2.7.20120803 → 3.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.markdown +6 -1
- data/README.markdown +2 -1
- data/lib/inflections/en-GB.rb +22 -0
- data/lib/inflections/railtie.rb +7 -3
- data/lib/inflections/version.rb +2 -2
- data/test/en-GB_test.rb +70 -0
- data/test/en_test.rb +0 -4
- metadata +5 -2
data/CHANGELOG.markdown
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
3.2.8 (current version)
|
|
2
2
|
=======================
|
|
3
|
+
* Support for British English (thanks to [creativetags](https://github.com/creativetags))
|
|
4
|
+
* Now versioning alongside ActiveSupport
|
|
5
|
+
|
|
6
|
+
0.0.5
|
|
7
|
+
=====
|
|
3
8
|
* Rails users no longer need to specify a locale to load; inflections are automagically loaded depending on `I18n.default_locale`
|
|
4
9
|
|
|
5
10
|
0.0.4
|
data/README.markdown
CHANGED
|
@@ -38,7 +38,7 @@ Define your own defaults as such:
|
|
|
38
38
|
|
|
39
39
|
```ruby
|
|
40
40
|
ActiveSupport::Inflector.inflections do |inflect|
|
|
41
|
-
inflect.singular /(phase)s$/i, '\1'
|
|
41
|
+
inflect.singular /(phase)s$/i, '\1'
|
|
42
42
|
inflect.plural /(shel|kni)fe/, '\1ves'
|
|
43
43
|
inflect.irregular 'foot', 'feet'
|
|
44
44
|
inflect.uncountable %w( money )
|
|
@@ -48,6 +48,7 @@ end
|
|
|
48
48
|
## Languages Currently Supported
|
|
49
49
|
|
|
50
50
|
* English (en)
|
|
51
|
+
* British English (en-GB)
|
|
51
52
|
* Spanish (es)
|
|
52
53
|
|
|
53
54
|
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.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Inflections
|
|
2
|
+
ActiveSupport::Inflector.inflections 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/railtie.rb
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
module Inflections
|
|
2
2
|
class Railtie < Rails::Railtie
|
|
3
3
|
begin
|
|
4
|
-
|
|
4
|
+
config.to_prepare do
|
|
5
|
+
require "inflections/#{Rails.configuration.i18n.default_locale}"
|
|
6
|
+
end
|
|
5
7
|
rescue LoadError => e
|
|
6
|
-
|
|
7
|
-
|
|
8
|
+
config.to_prepare do
|
|
9
|
+
warn "Inflections currently does not support #{Rails.configuration.i18n.default_locale}. Defaulting to English (en)."
|
|
10
|
+
require 'inflections/en'
|
|
11
|
+
end
|
|
8
12
|
end
|
|
9
13
|
end
|
|
10
14
|
end
|
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'
|
|
3
|
+
|
|
4
|
+
class TestEnglishInflections < MiniTest::Unit::TestCase
|
|
5
|
+
def test_regular_plurals
|
|
6
|
+
assert_equal 'dogs', 'dog'.pluralize
|
|
7
|
+
assert_equal 'dog', 'dogs'.singularize
|
|
8
|
+
|
|
9
|
+
assert_equal 'days', 'day'.pluralize
|
|
10
|
+
assert_equal 'day', 'days'.singularize
|
|
11
|
+
|
|
12
|
+
assert_equal 'tests', 'test'.pluralize
|
|
13
|
+
assert_equal 'test', 'tests'.singularize
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def test_sibilant_sounds
|
|
17
|
+
assert_equal 'addresses', 'address'.pluralize
|
|
18
|
+
assert_equal 'address', 'addresses'.singularize
|
|
19
|
+
|
|
20
|
+
assert_equal 'phases', 'phase'.pluralize
|
|
21
|
+
|
|
22
|
+
assert_equal 'buzzes', 'buzz'.pluralize
|
|
23
|
+
assert_equal 'buzz', 'buzzes'.singularize
|
|
24
|
+
|
|
25
|
+
assert_equal 'boxes', 'box'.pluralize
|
|
26
|
+
assert_equal 'box', 'boxes'.singularize
|
|
27
|
+
|
|
28
|
+
assert_equal 'benches', 'bench'.pluralize
|
|
29
|
+
assert_equal 'bench', 'benches'.singularize
|
|
30
|
+
|
|
31
|
+
assert_equal 'dishes', 'dish'.pluralize
|
|
32
|
+
assert_equal 'dish', 'dishes'.singularize
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def test_oes_rule
|
|
36
|
+
assert_equal 'heroes', 'hero'.pluralize
|
|
37
|
+
assert_equal 'hero', 'heroes'.singularize
|
|
38
|
+
|
|
39
|
+
assert_equal 'igloos', 'igloo'.pluralize
|
|
40
|
+
assert_equal 'igloo', 'igloos'.singularize
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def test_ies_rule
|
|
44
|
+
assert_equal 'berries', 'berry'.pluralize
|
|
45
|
+
assert_equal 'berry', 'berries'.singularize
|
|
46
|
+
|
|
47
|
+
assert_equal 'days', 'day'.pluralize
|
|
48
|
+
assert_equal 'day', 'days'.singularize
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def test_irregulars
|
|
52
|
+
assert_equal 'children', 'child'.pluralize
|
|
53
|
+
assert_equal 'child', 'children'.singularize
|
|
54
|
+
|
|
55
|
+
assert_equal 'people', 'person'.pluralize
|
|
56
|
+
assert_equal 'person', 'people'.singularize
|
|
57
|
+
|
|
58
|
+
assert_equal 'selves', 'self'.pluralize
|
|
59
|
+
assert_equal 'self', 'selves'.singularize
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def test_uncountables
|
|
63
|
+
assert_equal 'series', 'series'.pluralize
|
|
64
|
+
assert_equal 'series', 'series'.singularize
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def test_stupid_inflections_removed
|
|
68
|
+
assert_equal 'cows', 'cow'.pluralize
|
|
69
|
+
end
|
|
70
|
+
end
|
data/test/en_test.rb
CHANGED
|
@@ -18,10 +18,6 @@ class TestEnglishInflections < MiniTest::Unit::TestCase
|
|
|
18
18
|
assert_equal 'address', 'addresses'.singularize
|
|
19
19
|
|
|
20
20
|
assert_equal 'phases', 'phase'.pluralize
|
|
21
|
-
# Can't assume whether words that end with 'es' remove the 'es' or just 's'
|
|
22
|
-
# So I went with the case that seemed more reasonable given sibilant sounds
|
|
23
|
-
#
|
|
24
|
-
# assert_equal 'phase', 'phases'.singularize
|
|
25
21
|
|
|
26
22
|
assert_equal 'buzzes', 'buzz'.pluralize
|
|
27
23
|
assert_equal 'buzz', 'buzzes'.singularize
|
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: 3.2.
|
|
4
|
+
version: 3.2.8
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-
|
|
12
|
+
date: 2012-09-14 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rake
|
|
@@ -76,10 +76,12 @@ files:
|
|
|
76
76
|
- Rakefile
|
|
77
77
|
- inflections.gemspec
|
|
78
78
|
- lib/inflections.rb
|
|
79
|
+
- lib/inflections/en-GB.rb
|
|
79
80
|
- lib/inflections/en.rb
|
|
80
81
|
- lib/inflections/es.rb
|
|
81
82
|
- lib/inflections/railtie.rb
|
|
82
83
|
- lib/inflections/version.rb
|
|
84
|
+
- test/en-GB_test.rb
|
|
83
85
|
- test/en_test.rb
|
|
84
86
|
- test/es_test.rb
|
|
85
87
|
- test/test_helper.rb
|
|
@@ -108,5 +110,6 @@ signing_key:
|
|
|
108
110
|
specification_version: 3
|
|
109
111
|
summary: Sane inflection rules for ActiveSupport.
|
|
110
112
|
test_files:
|
|
113
|
+
- test/en-GB_test.rb
|
|
111
114
|
- test/en_test.rb
|
|
112
115
|
- test/es_test.rb
|