Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

root/trunk/activesupport/test/inflector_test_cases.rb

Revision 8533, 5.3 kB (checked in by david, 9 months ago)

Fixed String#titleize to work for strings with 's too (closes #10571) [trek]

Line 
1 module InflectorTestCases
2   SingularToPlural = {
3     "search"      => "searches",
4     "switch"      => "switches",
5     "fix"         => "fixes",
6     "box"         => "boxes",
7     "process"     => "processes",
8     "address"     => "addresses",
9     "case"        => "cases",
10     "stack"       => "stacks",
11     "wish"        => "wishes",
12     "fish"        => "fish",
13
14     "category"    => "categories",
15     "query"       => "queries",
16     "ability"     => "abilities",
17     "agency"      => "agencies",
18     "movie"       => "movies",
19
20     "archive"     => "archives",
21
22     "index"       => "indices",
23
24     "wife"        => "wives",
25     "safe"        => "saves",
26     "half"        => "halves",
27
28     "move"        => "moves",
29
30     "salesperson" => "salespeople",
31     "person"      => "people",
32
33     "spokesman"   => "spokesmen",
34     "man"         => "men",
35     "woman"       => "women",
36
37     "basis"       => "bases",
38     "diagnosis"   => "diagnoses",
39     "diagnosis_a" => "diagnosis_as",
40
41     "datum"       => "data",
42     "medium"      => "media",
43     "analysis"    => "analyses",
44
45     "node_child"  => "node_children",
46     "child"       => "children",
47
48     "experience"  => "experiences",
49     "day"         => "days",
50
51     "comment"     => "comments",
52     "foobar"      => "foobars",
53     "newsletter"  => "newsletters",
54
55     "old_news"    => "old_news",
56     "news"        => "news",
57
58     "series"      => "series",
59     "species"     => "species",
60
61     "quiz"        => "quizzes",
62
63     "perspective" => "perspectives",
64
65     "ox"          => "oxen",
66     "photo"       => "photos",
67     "buffalo"     => "buffaloes",
68     "tomato"      => "tomatoes",
69     "dwarf"       => "dwarves",
70     "elf"         => "elves",
71     "information" => "information",
72     "equipment"   => "equipment",
73     "bus"         => "buses",
74     "status"      => "statuses",
75     "status_code" => "status_codes",
76     "mouse"       => "mice",
77
78     "louse"       => "lice",
79     "house"       => "houses",
80     "octopus"     => "octopi",
81     "virus"       => "viri",
82     "alias"       => "aliases",
83     "portfolio"   => "portfolios",
84
85     "vertex"      => "vertices",
86     "matrix"      => "matrices",
87     "matrix_fu"   => "matrix_fus",
88
89     "axis"        => "axes",
90     "testis"      => "testes",
91     "crisis"      => "crises",
92
93     "rice"        => "rice",
94     "shoe"        => "shoes",
95
96     "horse"       => "horses",
97     "prize"       => "prizes",
98     "edge"        => "edges",
99
100     "cow"         => "kine"
101   }
102
103   CamelToUnderscore = {
104     "Product"               => "product",
105     "SpecialGuest"          => "special_guest",
106     "ApplicationController" => "application_controller",
107     "Area51Controller"      => "area51_controller"
108   }
109
110   UnderscoreToLowerCamel = {
111     "product"                => "product",
112     "special_guest"          => "specialGuest",
113     "application_controller" => "applicationController",
114     "area51_controller"      => "area51Controller"
115   }
116
117   CamelToUnderscoreWithoutReverse = {
118     "HTMLTidy"              => "html_tidy",
119     "HTMLTidyGenerator"     => "html_tidy_generator",
120     "FreeBSD"               => "free_bsd",
121     "HTML"                  => "html",
122   }
123
124   CamelWithModuleToUnderscoreWithSlash = {
125     "Admin::Product" => "admin/product",
126     "Users::Commission::Department" => "users/commission/department",
127     "UsersSection::CommissionDepartment" => "users_section/commission_department",
128   }
129
130   ClassNameToForeignKeyWithUnderscore = {
131     "Person" => "person_id",
132     "MyApplication::Billing::Account" => "account_id"
133   }
134
135   ClassNameToForeignKeyWithoutUnderscore = {
136     "Person" => "personid",
137     "MyApplication::Billing::Account" => "accountid"
138   }
139
140   ClassNameToTableName = {
141     "PrimarySpokesman" => "primary_spokesmen",
142     "NodeChild"        => "node_children"
143   }
144
145   UnderscoreToHuman = {
146     "employee_salary" => "Employee salary",
147     "employee_id"     => "Employee",
148     "underground"     => "Underground"
149   }
150
151   MixtureToTitleCase = {
152     'active_record'       => 'Active Record',
153     'ActiveRecord'        => 'Active Record',
154     'action web service'  => 'Action Web Service',
155     'Action Web Service'  => 'Action Web Service',
156     'Action web service'  => 'Action Web Service',
157     'actionwebservice'    => 'Actionwebservice',
158     'Actionwebservice'    => 'Actionwebservice',
159     "david's code"        => "David's Code",
160     "David's code"        => "David's Code",
161     "david's Code"        => "David's Code"
162   }
163
164   OrdinalNumbers = {
165     "0" => "0th",
166     "1" => "1st",
167     "2" => "2nd",
168     "3" => "3rd",
169     "4" => "4th",
170     "5" => "5th",
171     "6" => "6th",
172     "7" => "7th",
173     "8" => "8th",
174     "9" => "9th",
175     "10" => "10th",
176     "11" => "11th",
177     "12" => "12th",
178     "13" => "13th",
179     "14" => "14th",
180     "20" => "20th",
181     "21" => "21st",
182     "22" => "22nd",
183     "23" => "23rd",
184     "24" => "24th",
185     "100" => "100th",
186     "101" => "101st",
187     "102" => "102nd",
188     "103" => "103rd",
189     "104" => "104th",
190     "110" => "110th",
191     "111" => "111th",
192     "112" => "112th",
193     "113" => "113th",
194     "1000" => "1000th",
195     "1001" => "1001st"
196   }
197
198   UnderscoresToDashes = {
199     "street"                => "street",
200     "street_address"        => "street-address",
201     "person_street_address" => "person-street-address"
202   }
203
204   Irregularities = {
205     'person' => 'people',
206     'man'    => 'men',
207     'child'  => 'children',
208     'sex'    => 'sexes',
209     'move'   => 'moves',
210   }
211 end
Note: See TracBrowser for help on using the browser.