rails-inflections 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,324 @@
1
+ # encoding: utf-8
2
+
3
+ module InflectorTestCases
4
+ SingularToPlural = {
5
+ "search" => "searches",
6
+ "switch" => "switches",
7
+ "fix" => "fixes",
8
+ "box" => "boxes",
9
+ "process" => "processes",
10
+ "address" => "addresses",
11
+ "case" => "cases",
12
+ "stack" => "stacks",
13
+ "wish" => "wishes",
14
+ "fish" => "fish",
15
+ "jeans" => "jeans",
16
+ "funky jeans" => "funky jeans",
17
+ "my money" => "my money",
18
+
19
+ "category" => "categories",
20
+ "query" => "queries",
21
+ "ability" => "abilities",
22
+ "agency" => "agencies",
23
+ "movie" => "movies",
24
+
25
+ "archive" => "archives",
26
+
27
+ "index" => "indices",
28
+
29
+ "wife" => "wives",
30
+ "safe" => "saves",
31
+ "half" => "halves",
32
+
33
+ "move" => "moves",
34
+
35
+ "salesperson" => "salespeople",
36
+ "person" => "people",
37
+
38
+ "spokesman" => "spokesmen",
39
+ "man" => "men",
40
+ "woman" => "women",
41
+
42
+ "basis" => "bases",
43
+ "diagnosis" => "diagnoses",
44
+ "diagnosis_a" => "diagnosis_as",
45
+
46
+ "datum" => "data",
47
+ "medium" => "media",
48
+ "stadium" => "stadia",
49
+ "analysis" => "analyses",
50
+ "my_analysis" => "my_analyses",
51
+
52
+ "node_child" => "node_children",
53
+ "child" => "children",
54
+
55
+ "experience" => "experiences",
56
+ "day" => "days",
57
+
58
+ "comment" => "comments",
59
+ "foobar" => "foobars",
60
+ "newsletter" => "newsletters",
61
+
62
+ "old_news" => "old_news",
63
+ "news" => "news",
64
+
65
+ "series" => "series",
66
+ "miniseries" => "miniseries",
67
+ "species" => "species",
68
+
69
+ "quiz" => "quizzes",
70
+
71
+ "perspective" => "perspectives",
72
+
73
+ "ox" => "oxen",
74
+ "photo" => "photos",
75
+ "buffalo" => "buffaloes",
76
+ "tomato" => "tomatoes",
77
+ "dwarf" => "dwarves",
78
+ "elf" => "elves",
79
+ "information" => "information",
80
+ "equipment" => "equipment",
81
+ "bus" => "buses",
82
+ "status" => "statuses",
83
+ "status_code" => "status_codes",
84
+ "mouse" => "mice",
85
+
86
+ "louse" => "lice",
87
+ "house" => "houses",
88
+ "octopus" => "octopi",
89
+ "virus" => "viri",
90
+ "alias" => "aliases",
91
+ "portfolio" => "portfolios",
92
+
93
+ "vertex" => "vertices",
94
+ "matrix" => "matrices",
95
+ "matrix_fu" => "matrix_fus",
96
+
97
+ "axis" => "axes",
98
+ "taxi" => "taxis", # prevents regression
99
+ "testis" => "testes",
100
+ "crisis" => "crises",
101
+
102
+ "rice" => "rice",
103
+ "shoe" => "shoes",
104
+
105
+ "horse" => "horses",
106
+ "prize" => "prizes",
107
+ "edge" => "edges",
108
+
109
+ "database" => "databases",
110
+
111
+ # regression tests against improper inflection regexes
112
+ "|ice" => "|ices",
113
+ "|ouse" => "|ouses",
114
+ "slice" => "slices",
115
+ "police" => "police"
116
+ }
117
+
118
+ CamelToUnderscore = {
119
+ "Product" => "product",
120
+ "SpecialGuest" => "special_guest",
121
+ "ApplicationController" => "application_controller",
122
+ "Area51Controller" => "area51_controller"
123
+ }
124
+
125
+ UnderscoreToLowerCamel = {
126
+ "product" => "product",
127
+ "special_guest" => "specialGuest",
128
+ "application_controller" => "applicationController",
129
+ "area51_controller" => "area51Controller"
130
+ }
131
+
132
+ SymbolToLowerCamel = {
133
+ :product => 'product',
134
+ :special_guest => 'specialGuest',
135
+ :application_controller => 'applicationController',
136
+ :area51_controller => 'area51Controller'
137
+ }
138
+
139
+ CamelToUnderscoreWithoutReverse = {
140
+ "HTMLTidy" => "html_tidy",
141
+ "HTMLTidyGenerator" => "html_tidy_generator",
142
+ "FreeBSD" => "free_bsd",
143
+ "HTML" => "html",
144
+ "ForceXMLController" => "force_xml_controller",
145
+ }
146
+
147
+ CamelWithModuleToUnderscoreWithSlash = {
148
+ "Admin::Product" => "admin/product",
149
+ "Users::Commission::Department" => "users/commission/department",
150
+ "UsersSection::CommissionDepartment" => "users_section/commission_department",
151
+ }
152
+
153
+ ClassNameToForeignKeyWithUnderscore = {
154
+ "Person" => "person_id",
155
+ "MyApplication::Billing::Account" => "account_id"
156
+ }
157
+
158
+ ClassNameToForeignKeyWithoutUnderscore = {
159
+ "Person" => "personid",
160
+ "MyApplication::Billing::Account" => "accountid"
161
+ }
162
+
163
+ ClassNameToTableName = {
164
+ "PrimarySpokesman" => "primary_spokesmen",
165
+ "NodeChild" => "node_children"
166
+ }
167
+
168
+ StringToParameterized = {
169
+ "Donald E. Knuth" => "donald-e-knuth",
170
+ "Random text with *(bad)* characters" => "random-text-with-bad-characters",
171
+ "Allow_Under_Scores" => "allow_under_scores",
172
+ "Trailing bad characters!@#" => "trailing-bad-characters",
173
+ "!@#Leading bad characters" => "leading-bad-characters",
174
+ "Squeeze separators" => "squeeze-separators",
175
+ "Test with + sign" => "test-with-sign",
176
+ "Test with malformed utf8 \251" => "test-with-malformed-utf8"
177
+ }
178
+
179
+ StringToParameterizeWithNoSeparator = {
180
+ "Donald E. Knuth" => "donaldeknuth",
181
+ "With-some-dashes" => "with-some-dashes",
182
+ "Random text with *(bad)* characters" => "randomtextwithbadcharacters",
183
+ "Trailing bad characters!@#" => "trailingbadcharacters",
184
+ "!@#Leading bad characters" => "leadingbadcharacters",
185
+ "Squeeze separators" => "squeezeseparators",
186
+ "Test with + sign" => "testwithsign",
187
+ "Test with malformed utf8 \251" => "testwithmalformedutf8"
188
+ }
189
+
190
+ StringToParameterizeWithUnderscore = {
191
+ "Donald E. Knuth" => "donald_e_knuth",
192
+ "Random text with *(bad)* characters" => "random_text_with_bad_characters",
193
+ "With-some-dashes" => "with-some-dashes",
194
+ "Retain_underscore" => "retain_underscore",
195
+ "Trailing bad characters!@#" => "trailing_bad_characters",
196
+ "!@#Leading bad characters" => "leading_bad_characters",
197
+ "Squeeze separators" => "squeeze_separators",
198
+ "Test with + sign" => "test_with_sign",
199
+ "Test with malformed utf8 \251" => "test_with_malformed_utf8"
200
+ }
201
+
202
+ StringToParameterizedAndNormalized = {
203
+ "Malmö" => "malmo",
204
+ "Garçons" => "garcons",
205
+ "Ops\331" => "opsu",
206
+ "Ærøskøbing" => "aeroskobing",
207
+ "Aßlar" => "asslar",
208
+ "Japanese: 日本語" => "japanese"
209
+ }
210
+
211
+ UnderscoreToHuman = {
212
+ 'employee_salary' => 'Employee salary',
213
+ 'employee_id' => 'Employee',
214
+ 'underground' => 'Underground',
215
+ '_id' => 'Id',
216
+ '_external_id' => 'External'
217
+ }
218
+
219
+ UnderscoreToHumanWithoutCapitalize = {
220
+ "employee_salary" => "employee salary",
221
+ "employee_id" => "employee",
222
+ "underground" => "underground"
223
+ }
224
+
225
+ MixtureToTitleCase = {
226
+ 'active_record' => 'Active Record',
227
+ 'ActiveRecord' => 'Active Record',
228
+ 'action web service' => 'Action Web Service',
229
+ 'Action Web Service' => 'Action Web Service',
230
+ 'Action web service' => 'Action Web Service',
231
+ 'actionwebservice' => 'Actionwebservice',
232
+ 'Actionwebservice' => 'Actionwebservice',
233
+ "david's code" => "David's Code",
234
+ "David's code" => "David's Code",
235
+ "david's Code" => "David's Code",
236
+ "sgt. pepper's" => "Sgt. Pepper's",
237
+ "i've just seen a face" => "I've Just Seen A Face",
238
+ "maybe you'll be there" => "Maybe You'll Be There",
239
+ "¿por qué?" => '¿Por Qué?',
240
+ "Fred’s" => "Fred’s",
241
+ "Fred`s" => "Fred`s"
242
+ }
243
+
244
+ OrdinalNumbers = {
245
+ "-1" => "-1st",
246
+ "-2" => "-2nd",
247
+ "-3" => "-3rd",
248
+ "-4" => "-4th",
249
+ "-5" => "-5th",
250
+ "-6" => "-6th",
251
+ "-7" => "-7th",
252
+ "-8" => "-8th",
253
+ "-9" => "-9th",
254
+ "-10" => "-10th",
255
+ "-11" => "-11th",
256
+ "-12" => "-12th",
257
+ "-13" => "-13th",
258
+ "-14" => "-14th",
259
+ "-20" => "-20th",
260
+ "-21" => "-21st",
261
+ "-22" => "-22nd",
262
+ "-23" => "-23rd",
263
+ "-24" => "-24th",
264
+ "-100" => "-100th",
265
+ "-101" => "-101st",
266
+ "-102" => "-102nd",
267
+ "-103" => "-103rd",
268
+ "-104" => "-104th",
269
+ "-110" => "-110th",
270
+ "-111" => "-111th",
271
+ "-112" => "-112th",
272
+ "-113" => "-113th",
273
+ "-1000" => "-1000th",
274
+ "-1001" => "-1001st",
275
+ "0" => "0th",
276
+ "1" => "1st",
277
+ "2" => "2nd",
278
+ "3" => "3rd",
279
+ "4" => "4th",
280
+ "5" => "5th",
281
+ "6" => "6th",
282
+ "7" => "7th",
283
+ "8" => "8th",
284
+ "9" => "9th",
285
+ "10" => "10th",
286
+ "11" => "11th",
287
+ "12" => "12th",
288
+ "13" => "13th",
289
+ "14" => "14th",
290
+ "20" => "20th",
291
+ "21" => "21st",
292
+ "22" => "22nd",
293
+ "23" => "23rd",
294
+ "24" => "24th",
295
+ "100" => "100th",
296
+ "101" => "101st",
297
+ "102" => "102nd",
298
+ "103" => "103rd",
299
+ "104" => "104th",
300
+ "110" => "110th",
301
+ "111" => "111th",
302
+ "112" => "112th",
303
+ "113" => "113th",
304
+ "1000" => "1000th",
305
+ "1001" => "1001st"
306
+ }
307
+
308
+ UnderscoresToDashes = {
309
+ "street" => "street",
310
+ "street_address" => "street-address",
311
+ "person_street_address" => "person-street-address"
312
+ }
313
+
314
+ Irregularities = {
315
+ 'person' => 'people',
316
+ 'man' => 'men',
317
+ 'child' => 'children',
318
+ 'sex' => 'sexes',
319
+ 'move' => 'moves',
320
+ 'cow' => 'kine', # Test inflections with different starting letters
321
+ 'zombie' => 'zombies',
322
+ 'genus' => 'genera'
323
+ }
324
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails-inflections
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Vipul A M
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-10-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '4.1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '4.1'
55
+ description: |-
56
+ Inflections from Rails are frozen, and most edge cases are broken. rails-inflections adds
57
+ missing rules, or corrects broken ones.
58
+ email:
59
+ - vipulnsward@gmail.com
60
+ executables: []
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - ".gitignore"
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - lib/rails/inflections.rb
70
+ - lib/rails/inflections/version.rb
71
+ - rails-inflections.gemspec
72
+ - test/abstract_unit.rb
73
+ - test/constantize_test_cases.rb
74
+ - test/dependencies_test_helpers.rb
75
+ - test/inflector_test.rb
76
+ - test/inflector_test_cases.rb
77
+ homepage: ''
78
+ licenses:
79
+ - MIT
80
+ metadata: {}
81
+ post_install_message:
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubyforge_project:
97
+ rubygems_version: 2.2.2
98
+ signing_key:
99
+ specification_version: 4
100
+ summary: "\\Rails Inflections on steriods"
101
+ test_files:
102
+ - test/abstract_unit.rb
103
+ - test/constantize_test_cases.rb
104
+ - test/dependencies_test_helpers.rb
105
+ - test/inflector_test.rb
106
+ - test/inflector_test_cases.rb