wycats-merb-core 0.9.8 → 0.9.9

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.
Files changed (58) hide show
  1. data/CHANGELOG +136 -2
  2. data/CONTRIBUTORS +6 -0
  3. data/PUBLIC_CHANGELOG +15 -0
  4. data/Rakefile +12 -14
  5. data/lib/merb-core.rb +82 -43
  6. data/lib/merb-core/bootloader.rb +268 -60
  7. data/lib/merb-core/config.rb +119 -34
  8. data/lib/merb-core/controller/abstract_controller.rb +58 -18
  9. data/lib/merb-core/controller/exceptions.rb +2 -15
  10. data/lib/merb-core/controller/merb_controller.rb +28 -1
  11. data/lib/merb-core/controller/mime.rb +4 -0
  12. data/lib/merb-core/controller/mixins/controller.rb +14 -17
  13. data/lib/merb-core/controller/mixins/render.rb +23 -28
  14. data/lib/merb-core/controller/mixins/responder.rb +0 -1
  15. data/lib/merb-core/controller/template.rb +44 -20
  16. data/lib/merb-core/core_ext/kernel.rb +8 -3
  17. data/lib/merb-core/dispatch/default_exception/default_exception.rb +1 -1
  18. data/lib/merb-core/dispatch/default_exception/views/_css.html.erb +3 -1
  19. data/lib/merb-core/dispatch/default_exception/views/_javascript.html.erb +71 -67
  20. data/lib/merb-core/dispatch/default_exception/views/index.html.erb +6 -2
  21. data/lib/merb-core/dispatch/dispatcher.rb +5 -9
  22. data/lib/merb-core/dispatch/request.rb +46 -57
  23. data/lib/merb-core/dispatch/router.rb +83 -6
  24. data/lib/merb-core/dispatch/router/behavior.rb +87 -27
  25. data/lib/merb-core/dispatch/router/resources.rb +281 -167
  26. data/lib/merb-core/dispatch/router/route.rb +141 -27
  27. data/lib/merb-core/logger.rb +213 -202
  28. data/lib/merb-core/rack.rb +3 -1
  29. data/lib/merb-core/rack/adapter.rb +7 -4
  30. data/lib/merb-core/rack/adapter/ebb.rb +12 -13
  31. data/lib/merb-core/rack/adapter/evented_mongrel.rb +2 -15
  32. data/lib/merb-core/rack/adapter/irb.rb +3 -2
  33. data/lib/merb-core/rack/adapter/mongrel.rb +22 -15
  34. data/lib/merb-core/rack/adapter/swiftiplied_mongrel.rb +4 -16
  35. data/lib/merb-core/rack/adapter/thin.rb +21 -22
  36. data/lib/merb-core/rack/adapter/thin_turbo.rb +4 -11
  37. data/lib/merb-core/rack/adapter/webrick.rb +54 -18
  38. data/lib/merb-core/rack/handler/mongrel.rb +12 -13
  39. data/lib/merb-core/rack/middleware/csrf.rb +1 -1
  40. data/lib/merb-core/server.rb +135 -98
  41. data/lib/merb-core/tasks/gem_management.rb +50 -12
  42. data/lib/merb-core/tasks/merb.rb +1 -0
  43. data/lib/merb-core/tasks/merb_rake_helper.rb +9 -38
  44. data/lib/merb-core/tasks/stats.rake +2 -2
  45. data/lib/merb-core/test.rb +9 -3
  46. data/lib/merb-core/test/helpers.rb +1 -0
  47. data/lib/merb-core/test/helpers/multipart_request_helper.rb +3 -2
  48. data/lib/merb-core/test/helpers/request_helper.rb +40 -372
  49. data/lib/merb-core/test/helpers/route_helper.rb +15 -7
  50. data/lib/merb-core/test/matchers.rb +1 -0
  51. data/lib/merb-core/test/matchers/controller_matchers.rb +4 -247
  52. data/lib/merb-core/test/matchers/view_matchers.rb +22 -4
  53. data/lib/merb-core/test/run_specs.rb +117 -25
  54. data/lib/merb-core/version.rb +1 -1
  55. metadata +1 -1
  56. data/lib/merb-core/vendor/facets.rb +0 -2
  57. data/lib/merb-core/vendor/facets/dictionary.rb +0 -433
  58. data/lib/merb-core/vendor/facets/inflect.rb +0 -342
@@ -1,342 +0,0 @@
1
- module English
2
-
3
- # = English Nouns Number Inflection.
4
- #
5
- # This module provides english singular <-> plural noun inflections.
6
- module Inflect
7
-
8
- @singular_of = {}
9
- @plural_of = {}
10
-
11
- @singular_rules = []
12
- @plural_rules = []
13
-
14
- class << self
15
- # Defines a general inflection exception case.
16
- #
17
- # ==== Parameters
18
- # singular<String>::
19
- # singular form of the word
20
- # plural<String>::
21
- # plural form of the word
22
- #
23
- # ==== Examples
24
- #
25
- # Here we define erratum/errata exception case:
26
- #
27
- # English::Inflect.word "erratum", "errata"
28
- #
29
- # In case singular and plural forms are the same omit
30
- # second argument on call:
31
- #
32
- # English::Inflect.word 'information'
33
- def word(singular, plural=nil)
34
- plural = singular unless plural
35
- singular_word(singular, plural)
36
- plural_word(singular, plural)
37
- end
38
-
39
- def clear(type = :all)
40
- if type == :singular || type == :all
41
- @singular_of = {}
42
- @singular_rules = []
43
- @singularization_rules, @singularization_regex = nil, nil
44
- end
45
- if type == :plural || type == :all
46
- @singular_of = {}
47
- @singular_rules = []
48
- @singularization_rules, @singularization_regex = nil, nil
49
- end
50
- end
51
-
52
-
53
- # Define a singularization exception.
54
- #
55
- # ==== Parameters
56
- # singular<String>::
57
- # singular form of the word
58
- # plural<String>::
59
- # plural form of the word
60
- def singular_word(singular, plural)
61
- @singular_of[plural] = singular
62
- @singular_of[plural.capitalize] = singular.capitalize
63
- end
64
-
65
- # Define a pluralization exception.
66
- #
67
- # ==== Parameters
68
- # singular<String>::
69
- # singular form of the word
70
- # plural<String>::
71
- # plural form of the word
72
- def plural_word(singular, plural)
73
- @plural_of[singular] = plural
74
- @plural_of[singular.capitalize] = plural.capitalize
75
- end
76
-
77
- # Define a general rule.
78
- #
79
- # ==== Parameters
80
- # singular<String>::
81
- # ending of the word in singular form
82
- # plural<String>::
83
- # ending of the word in plural form
84
- # whole_word<Boolean>::
85
- # for capitalization, since words can be
86
- # capitalized (Man => Men) #
87
- # ==== Examples
88
- # Once the following rule is defined:
89
- # English::Inflect.rule 'y', 'ies'
90
- #
91
- # You can see the following results:
92
- # irb> "fly".plural
93
- # => flies
94
- # irb> "cry".plural
95
- # => cries
96
- # Define a general rule.
97
-
98
- def rule(singular, plural, whole_word = false)
99
- singular_rule(singular, plural)
100
- plural_rule(singular, plural)
101
- word(singular, plural) if whole_word
102
- end
103
-
104
- # Define a singularization rule.
105
- #
106
- # ==== Parameters
107
- # singular<String>::
108
- # ending of the word in singular form
109
- # plural<String>::
110
- # ending of the word in plural form
111
- #
112
- # ==== Examples
113
- # Once the following rule is defined:
114
- # English::Inflect.singular_rule 'o', 'oes'
115
- #
116
- # You can see the following results:
117
- # irb> "heroes".singular
118
- # => hero
119
- def singular_rule(singular, plural)
120
- @singular_rules << [singular, plural]
121
- end
122
-
123
- # Define a plurualization rule.
124
- #
125
- # ==== Parameters
126
- # singular<String>::
127
- # ending of the word in singular form
128
- # plural<String>::
129
- # ending of the word in plural form
130
- #
131
- # ==== Examples
132
- # Once the following rule is defined:
133
- # English::Inflect.singular_rule 'fe', 'ves'
134
- #
135
- # You can see the following results:
136
- # irb> "wife".plural
137
- # => wives
138
- def plural_rule(singular, plural)
139
- @plural_rules << [singular, plural]
140
- end
141
-
142
- # Read prepared singularization rules.
143
- def singularization_rules
144
- if defined?(@singularization_regex) && @singularization_regex
145
- return [@singularization_regex, @singularization_hash]
146
- end
147
- # No sorting needed: Regexen match on longest string
148
- @singularization_regex = Regexp.new("(" + @singular_rules.map {|s,p| p}.join("|") + ")$", "i")
149
- @singularization_hash = Hash[*@singular_rules.flatten].invert
150
- [@singularization_regex, @singularization_hash]
151
- end
152
-
153
- # Read prepared pluralization rules.
154
- def pluralization_rules
155
- if defined?(@pluralization_regex) && @pluralization_regex
156
- return [@pluralization_regex, @pluralization_hash]
157
- end
158
- @pluralization_regex = Regexp.new("(" + @plural_rules.map {|s,p| s}.join("|") + ")$", "i")
159
- @pluralization_hash = Hash[*@plural_rules.flatten]
160
- [@pluralization_regex, @pluralization_hash]
161
- end
162
-
163
- attr_reader :singular_of, :plural_of
164
-
165
- # Convert an English word from plurel to singular.
166
- #
167
- # "boys".singular #=> boy
168
- # "tomatoes".singular #=> tomato
169
- #
170
- # ==== Parameters
171
- # word<String>:: word to singularize
172
- #
173
- # ==== Returns
174
- # <String>:: singularized form of word
175
- #
176
- # ==== Notes
177
- # Aliased as singularize (a Railism)
178
- def singular(word)
179
- if result = singular_of[word]
180
- return result.dup
181
- end
182
- result = word.dup
183
- regex, hash = singularization_rules
184
- result.sub!(regex) {|m| hash[m]}
185
- singular_of[word] = result
186
- return result
187
- end
188
-
189
- # Alias for #singular (a Railism).
190
- #
191
- alias_method(:singularize, :singular)
192
-
193
- # Convert an English word from singular to plurel.
194
- #
195
- # "boy".plural #=> boys
196
- # "tomato".plural #=> tomatoes
197
- #
198
- # ==== Parameters
199
- # word<String>:: word to pluralize
200
- #
201
- # ==== Returns
202
- # <String>:: pluralized form of word
203
- #
204
- # ==== Notes
205
- # Aliased as pluralize (a Railism)
206
- def plural(word)
207
- # special exceptions
208
- return "" if word == ""
209
- if result = plural_of[word]
210
- return result.dup
211
- end
212
- result = word.dup
213
- regex, hash = pluralization_rules
214
- result.sub!(regex) {|m| hash[m]}
215
- plural_of[word] = result
216
- return result
217
- end
218
-
219
- # Alias for #plural (a Railism).
220
- alias_method(:pluralize, :plural)
221
- end
222
-
223
- # One argument means singular and plural are the same.
224
-
225
- word 'equipment'
226
- word 'information'
227
- word 'money'
228
- word 'species'
229
- word 'series'
230
- word 'fish'
231
- word 'sheep'
232
- word 'moose'
233
- word 'hovercraft'
234
- word 'grass'
235
- word 'rain'
236
- word 'milk'
237
- word 'rice'
238
- word 'plurals'
239
-
240
- # Two arguments defines a singular and plural exception.
241
-
242
- word 'Swiss' , 'Swiss'
243
- word 'life' , 'lives'
244
- word 'wife' , 'wives'
245
- word 'goose' , 'geese'
246
- word 'criterion' , 'criteria'
247
- word 'alias' , 'aliases'
248
- word 'status' , 'statuses'
249
- word 'axis' , 'axes'
250
- word 'crisis' , 'crises'
251
- word 'testis' , 'testes'
252
- word 'potato' , 'potatoes'
253
- word 'tomato' , 'tomatoes'
254
- word 'buffalo' , 'buffaloes'
255
- word 'torpedo' , 'torpedoes'
256
- word 'quiz' , 'quizzes'
257
- word 'matrix' , 'matrices'
258
- word 'vertex' , 'vertices'
259
- word 'index' , 'indices'
260
- word 'ox' , 'oxen'
261
- word 'mouse' , 'mice'
262
- word 'louse' , 'lice'
263
- word 'thesis' , 'theses'
264
- word 'thief' , 'thieves'
265
- word 'analysis' , 'analyses'
266
- word 'erratum' , 'errata'
267
- word 'phenomenon', 'phenomena'
268
- word 'octopus' , 'octopi'
269
- word 'thesaurus' , 'thesauri'
270
- word 'movie' , 'movies'
271
- word 'cactus' , 'cacti'
272
- word 'plus' , 'plusses'
273
- word 'cross' , 'crosses'
274
- word 'medium' , 'media'
275
- word 'cow' , 'kine'
276
- word 'datum' , 'data'
277
- word 'basis' , 'bases'
278
- word 'diagnosis' , 'diagnoses'
279
-
280
- # One-way singularization exception (convert plural to singular).
281
-
282
- # General rules.
283
- rule 'person' , 'people', true
284
- rule 'shoe' , 'shoes', true
285
- rule 'hive' , 'hives', true
286
- rule 'man' , 'men', true
287
- rule 'child' , 'children', true
288
- rule 'news' , 'news', true
289
- rule 'rf' , 'rves'
290
- rule 'af' , 'aves'
291
- rule 'ero' , 'eroes'
292
- rule 'man' , 'men'
293
- rule 'ch' , 'ches'
294
- rule 'sh' , 'shes'
295
- rule 'ss' , 'sses'
296
- rule 'ta' , 'tum'
297
- rule 'ia' , 'ium'
298
- rule 'ra' , 'rum'
299
- rule 'ay' , 'ays'
300
- rule 'ey' , 'eys'
301
- rule 'oy' , 'oys'
302
- rule 'uy' , 'uys'
303
- rule 'y' , 'ies'
304
- rule 'x' , 'xes'
305
- rule 'lf' , 'lves'
306
- rule 'ffe' , 'ffes'
307
- rule 'afe' , 'aves'
308
- rule 'ouse' , 'ouses'
309
- # more cases of words ending in -oses not being singularized properly
310
- # than cases of words ending in -osis
311
- # rule 'osis' , 'oses'
312
- rule 'ox' , 'oxes'
313
- rule 'us' , 'uses'
314
- rule '' , 's'
315
-
316
- # One-way singular rules.
317
-
318
- singular_rule 'of' , 'ofs' # proof
319
- singular_rule 'o' , 'oes' # hero, heroes
320
- singular_rule 'f' , 'ves'
321
-
322
- # One-way plural rules.
323
-
324
- #plural_rule 'fe' , 'ves' # safe, wife
325
- plural_rule 's' , 'ses'
326
- plural_rule 'ive' , 'ives' # don't want to snag wife
327
- plural_rule 'fe' , 'ves' # don't want to snag perspectives
328
-
329
-
330
- end
331
- end
332
-
333
- class String
334
- def singular
335
- English::Inflect.singular(self)
336
- end
337
- alias_method(:singularize, :singular)
338
- def plural
339
- English::Inflect.plural(self)
340
- end
341
- alias_method(:pluralize, :plural)
342
- end