merb-core 0.9.7 → 0.9.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +136 -2
- data/CONTRIBUTORS +6 -0
- data/PUBLIC_CHANGELOG +38 -0
- data/Rakefile +38 -30
- data/lib/merb-core.rb +88 -23
- data/lib/merb-core/bootloader.rb +235 -51
- data/lib/merb-core/config.rb +121 -36
- data/lib/merb-core/controller/abstract_controller.rb +59 -36
- data/lib/merb-core/controller/exceptions.rb +2 -15
- data/lib/merb-core/controller/merb_controller.rb +44 -1
- data/lib/merb-core/controller/mime.rb +4 -0
- data/lib/merb-core/controller/mixins/controller.rb +38 -21
- data/lib/merb-core/controller/mixins/render.rb +44 -29
- data/lib/merb-core/controller/mixins/responder.rb +3 -31
- data/lib/merb-core/controller/template.rb +45 -21
- data/lib/merb-core/core_ext/kernel.rb +60 -32
- data/lib/merb-core/dispatch/default_exception/default_exception.rb +2 -2
- data/lib/merb-core/dispatch/default_exception/views/_css.html.erb +3 -1
- data/lib/merb-core/dispatch/default_exception/views/_javascript.html.erb +71 -67
- data/lib/merb-core/dispatch/default_exception/views/index.html.erb +7 -3
- data/lib/merb-core/dispatch/dispatcher.rb +3 -3
- data/lib/merb-core/dispatch/request.rb +56 -9
- data/lib/merb-core/dispatch/router.rb +159 -133
- data/lib/merb-core/dispatch/router/behavior.rb +462 -703
- data/lib/merb-core/dispatch/router/cached_proc.rb +3 -3
- data/lib/merb-core/dispatch/router/resources.rb +289 -0
- data/lib/merb-core/dispatch/router/route.rb +514 -294
- data/lib/merb-core/dispatch/session.rb +4 -2
- data/lib/merb-core/logger.rb +213 -202
- data/lib/merb-core/plugins.rb +9 -1
- data/lib/merb-core/rack.rb +3 -1
- data/lib/merb-core/rack/adapter.rb +7 -4
- data/lib/merb-core/rack/adapter/abstract.rb +188 -0
- data/lib/merb-core/rack/adapter/ebb.rb +12 -13
- data/lib/merb-core/rack/adapter/evented_mongrel.rb +2 -15
- data/lib/merb-core/rack/adapter/irb.rb +3 -2
- data/lib/merb-core/rack/adapter/mongrel.rb +22 -15
- data/lib/merb-core/rack/adapter/swiftiplied_mongrel.rb +4 -16
- data/lib/merb-core/rack/adapter/thin.rb +21 -22
- data/lib/merb-core/rack/adapter/thin_turbo.rb +4 -11
- data/lib/merb-core/rack/adapter/webrick.rb +54 -18
- data/lib/merb-core/rack/application.rb +4 -4
- data/lib/merb-core/rack/handler/mongrel.rb +12 -13
- data/lib/merb-core/rack/middleware/csrf.rb +1 -1
- data/lib/merb-core/rack/stream_wrapper.rb +41 -0
- data/lib/merb-core/server.rb +157 -90
- data/lib/merb-core/tasks/gem_management.rb +267 -0
- data/lib/merb-core/tasks/merb.rb +1 -0
- data/lib/merb-core/tasks/merb_rake_helper.rb +48 -34
- data/lib/merb-core/tasks/stats.rake +1 -1
- data/lib/merb-core/test.rb +9 -3
- data/lib/merb-core/test/helpers.rb +1 -0
- data/lib/merb-core/test/helpers/mock_request_helper.rb +393 -0
- data/lib/merb-core/test/helpers/multipart_request_helper.rb +3 -2
- data/lib/merb-core/test/helpers/request_helper.rb +40 -372
- data/lib/merb-core/test/helpers/route_helper.rb +16 -2
- data/lib/merb-core/test/matchers.rb +1 -0
- data/lib/merb-core/test/matchers/controller_matchers.rb +4 -247
- data/lib/merb-core/test/matchers/request_matchers.rb +140 -0
- data/lib/merb-core/test/matchers/view_matchers.rb +22 -4
- data/lib/merb-core/test/run_specs.rb +118 -26
- data/lib/merb-core/test/test_ext/rspec.rb +181 -0
- data/lib/merb-core/version.rb +1 -9
- metadata +10 -342
- data/docs/bootloading.dox +0 -58
- data/docs/documentation_standards +0 -40
- data/docs/merb-core-call-stack-diagram.mmap +0 -0
- data/docs/merb-core-call-stack-diagram.pdf +0 -0
- data/docs/merb-core-call-stack-diagram.png +0 -0
- data/docs/new_render_api +0 -51
- data/lib/merb-core/vendor/facets.rb +0 -2
- data/lib/merb-core/vendor/facets/dictionary.rb +0 -433
- data/lib/merb-core/vendor/facets/inflect.rb +0 -342
- data/spec/private/config/adapter_spec.rb +0 -32
- data/spec/private/config/config_spec.rb +0 -202
- data/spec/private/config/environment_spec.rb +0 -13
- data/spec/private/config/merb_spec.rb +0 -34
- data/spec/private/config/spec_helper.rb +0 -1
- data/spec/private/core_ext/kernel_spec.rb +0 -159
- data/spec/private/dispatch/bootloader_spec.rb +0 -24
- data/spec/private/dispatch/fixture/app/controllers/application.rb +0 -4
- data/spec/private/dispatch/fixture/app/controllers/exceptions.rb +0 -25
- data/spec/private/dispatch/fixture/app/controllers/foo.rb +0 -19
- data/spec/private/dispatch/fixture/app/helpers/global_helpers.rb +0 -8
- data/spec/private/dispatch/fixture/app/views/exeptions/client_error.html.erb +0 -37
- data/spec/private/dispatch/fixture/app/views/exeptions/internal_server_error.html.erb +0 -216
- data/spec/private/dispatch/fixture/app/views/exeptions/not_acceptable.html.erb +0 -38
- data/spec/private/dispatch/fixture/app/views/exeptions/not_found.html.erb +0 -40
- data/spec/private/dispatch/fixture/app/views/foo/bar.html.erb +0 -0
- data/spec/private/dispatch/fixture/app/views/layout/application.html.erb +0 -11
- data/spec/private/dispatch/fixture/config/black_hole.rb +0 -12
- data/spec/private/dispatch/fixture/config/environments/development.rb +0 -6
- data/spec/private/dispatch/fixture/config/environments/production.rb +0 -5
- data/spec/private/dispatch/fixture/config/environments/test.rb +0 -6
- data/spec/private/dispatch/fixture/config/init.rb +0 -45
- data/spec/private/dispatch/fixture/config/rack.rb +0 -11
- data/spec/private/dispatch/fixture/config/router.rb +0 -35
- data/spec/private/dispatch/fixture/log/merb_test.log +0 -8839
- data/spec/private/dispatch/fixture/public/images/merb.jpg +0 -0
- data/spec/private/dispatch/fixture/public/merb.fcgi +0 -4
- data/spec/private/dispatch/fixture/public/stylesheets/master.css +0 -119
- data/spec/private/dispatch/route_params_spec.rb +0 -23
- data/spec/private/dispatch/spec_helper.rb +0 -1
- data/spec/private/router/behavior_spec.rb +0 -60
- data/spec/private/router/fixture/log/merb_test.log +0 -35
- data/spec/private/router/route_spec.rb +0 -418
- data/spec/private/router/router_spec.rb +0 -183
- data/spec/private/vendor/facets/plural_spec.rb +0 -564
- data/spec/private/vendor/facets/singular_spec.rb +0 -489
- data/spec/public/DEFINITIONS +0 -11
- data/spec/public/abstract_controller/controllers/alt_views/layout/application.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/layout/merb/test/fixtures/abstract/render_string_controller_layout.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/layout/merb/test/fixtures/abstract/render_template_controller_layout.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/merb/test/fixtures/abstract/display_object_with_multiple_roots/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/merb/test/fixtures/abstract/display_object_with_multiple_roots/show.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/merb/test/fixtures/abstract/render_template_multiple_roots/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/partial/basic_partial_with_multiple_roots/_partial.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/render_template_multiple_roots_and_custom_location/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/render_template_multiple_roots_inherited/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/cousins.rb +0 -41
- data/spec/public/abstract_controller/controllers/display.rb +0 -60
- data/spec/public/abstract_controller/controllers/filters.rb +0 -260
- data/spec/public/abstract_controller/controllers/helpers.rb +0 -41
- data/spec/public/abstract_controller/controllers/partial.rb +0 -121
- data/spec/public/abstract_controller/controllers/render.rb +0 -113
- data/spec/public/abstract_controller/controllers/views/helpers/capture/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/helpers/capture_eq/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/helpers/capture_with_args/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/helpers/concat/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/layout/alt.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/layout/custom.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/display_object/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/display_object_with_action/new.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template_app_layout/index.erb +0 -0
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template_custom_layout/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template_multiple_roots/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template_multiple_roots/show.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_two_throw_contents/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/another_directory/_partial.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/basic_partial/_partial.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/basic_partial/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/basic_partial_with_multiple_roots/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/nested_partial/_first.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/nested_partial/_second.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/nested_partial/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_in_another_directory/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_both/_collection.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_both/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections/_collection.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_as/_collection.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_as/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_counter/_collection.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_counter/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_locals/_variables.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_locals/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_with_and_locals/_both.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_with_and_locals/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_absolute_partial/_partial.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_absolute_partial/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_as_partial/_with_partial.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_as_partial/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_nil_partial/_with_partial.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_nil_partial/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_partial/_with_partial.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_partial/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/test_display/foo.html.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/test_render/foo.html.erb +0 -0
- data/spec/public/abstract_controller/controllers/views/wonderful/index.erb +0 -1
- data/spec/public/abstract_controller/display_spec.rb +0 -37
- data/spec/public/abstract_controller/filter_spec.rb +0 -136
- data/spec/public/abstract_controller/helper_spec.rb +0 -21
- data/spec/public/abstract_controller/partial_spec.rb +0 -61
- data/spec/public/abstract_controller/render_spec.rb +0 -90
- data/spec/public/abstract_controller/spec_helper.rb +0 -31
- data/spec/public/boot_loader/boot_loader_spec.rb +0 -33
- data/spec/public/boot_loader/spec_helper.rb +0 -1
- data/spec/public/controller/authentication_spec.rb +0 -174
- data/spec/public/controller/base_spec.rb +0 -88
- data/spec/public/controller/conditional_get_spec.rb +0 -100
- data/spec/public/controller/config/init.rb +0 -6
- data/spec/public/controller/controllers/authentication.rb +0 -74
- data/spec/public/controller/controllers/base.rb +0 -65
- data/spec/public/controller/controllers/conditional_get.rb +0 -35
- data/spec/public/controller/controllers/cookies.rb +0 -36
- data/spec/public/controller/controllers/dispatcher.rb +0 -35
- data/spec/public/controller/controllers/display.rb +0 -118
- data/spec/public/controller/controllers/redirect.rb +0 -36
- data/spec/public/controller/controllers/responder.rb +0 -93
- data/spec/public/controller/controllers/url.rb +0 -7
- data/spec/public/controller/controllers/views/layout/custom.html.erb +0 -1
- data/spec/public/controller/controllers/views/layout/custom_arg.html.erb +0 -1
- data/spec/public/controller/controllers/views/layout/custom_arg.json.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_and_local_provides/index.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_and_local_provides/index.xml.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_provides/index.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_provides/index.xml.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/display_with_template/index.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/display_with_template/no_layout.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/display_with_template_argument/index.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/html_default/index.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/layout/custom.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/local_provides/index.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/local_provides/index.xml.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/multi_provides/index.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/multi_provides/index.js.erb +0 -1
- data/spec/public/controller/cookies_spec.rb +0 -95
- data/spec/public/controller/dispatcher_spec.rb +0 -410
- data/spec/public/controller/display_spec.rb +0 -84
- data/spec/public/controller/redirect_spec.rb +0 -33
- data/spec/public/controller/responder_spec.rb +0 -169
- data/spec/public/controller/spec_helper.rb +0 -13
- data/spec/public/controller/url_spec.rb +0 -255
- data/spec/public/core/merb_core_spec.rb +0 -45
- data/spec/public/core_ext/fixtures/core_ext_dependency.rb +0 -2
- data/spec/public/core_ext/kernel_spec.rb +0 -88
- data/spec/public/core_ext/spec_helper.rb +0 -1
- data/spec/public/directory_structure/directory/app/controllers/application.rb +0 -3
- data/spec/public/directory_structure/directory/app/controllers/base.rb +0 -13
- data/spec/public/directory_structure/directory/app/controllers/custom.rb +0 -19
- data/spec/public/directory_structure/directory/app/views/base/template.html.erb +0 -1
- data/spec/public/directory_structure/directory/app/views/wonderful/template.erb +0 -1
- data/spec/public/directory_structure/directory/config/router.rb +0 -3
- data/spec/public/directory_structure/directory/log/merb_test.log +0 -4588
- data/spec/public/directory_structure/directory_spec.rb +0 -43
- data/spec/public/logger/logger_spec.rb +0 -181
- data/spec/public/logger/spec_helper.rb +0 -1
- data/spec/public/rack/conditinal_get_middleware_spec.rb +0 -127
- data/spec/public/rack/csrf_middleware_spec.rb +0 -70
- data/spec/public/rack/rack_middleware_spec.rb +0 -99
- data/spec/public/rack/shared_example_groups.rb +0 -35
- data/spec/public/reloading/directory/app/controllers/application.rb +0 -3
- data/spec/public/reloading/directory/app/controllers/reload.rb +0 -6
- data/spec/public/reloading/directory/config/init.rb +0 -2
- data/spec/public/reloading/directory/log/merb_test.log +0 -288231
- data/spec/public/reloading/reload_spec.rb +0 -103
- data/spec/public/request/multipart_spec.rb +0 -41
- data/spec/public/request/request_spec.rb +0 -250
- data/spec/public/router/default_spec.rb +0 -21
- data/spec/public/router/deferred_spec.rb +0 -22
- data/spec/public/router/fixation_spec.rb +0 -49
- data/spec/public/router/fixture/log/merb_test.log +0 -524
- data/spec/public/router/namespace_spec.rb +0 -113
- data/spec/public/router/nested_matches_spec.rb +0 -97
- data/spec/public/router/nested_resources_spec.rb +0 -41
- data/spec/public/router/resource_spec.rb +0 -37
- data/spec/public/router/resources_spec.rb +0 -82
- data/spec/public/router/spec_helper.rb +0 -90
- data/spec/public/router/special_spec.rb +0 -61
- data/spec/public/router/string_spec.rb +0 -61
- data/spec/public/session/controllers/sessions.rb +0 -56
- data/spec/public/session/cookie_session_spec.rb +0 -73
- data/spec/public/session/memcached_session_spec.rb +0 -31
- data/spec/public/session/memory_session_spec.rb +0 -28
- data/spec/public/session/multiple_sessions_spec.rb +0 -74
- data/spec/public/session/no_session_spec.rb +0 -12
- data/spec/public/session/session_spec.rb +0 -106
- data/spec/public/template/template_spec.rb +0 -104
- data/spec/public/template/templates/error.html.erb +0 -2
- data/spec/public/template/templates/template.html.erb +0 -1
- data/spec/public/template/templates/template.html.myt +0 -1
- data/spec/public/test/controller_matchers_spec.rb +0 -412
- data/spec/public/test/controllers/controller_assertion_mock.rb +0 -7
- data/spec/public/test/controllers/dispatch_controller.rb +0 -11
- data/spec/public/test/controllers/spec_helper_controller.rb +0 -39
- data/spec/public/test/multipart_request_helper_spec.rb +0 -159
- data/spec/public/test/multipart_upload_text_file.txt +0 -1
- data/spec/public/test/request_helper_spec.rb +0 -269
- data/spec/public/test/route_helper_spec.rb +0 -78
- data/spec/public/test/route_matchers_spec.rb +0 -166
- data/spec/public/test/view_helper_spec.rb +0 -96
- data/spec/public/test/view_matchers_spec.rb +0 -183
- data/spec/spec_helper.rb +0 -121
@@ -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
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
|
3
|
-
MERB_BIN = File.dirname(__FILE__) + "/../../../bin/merb"
|
4
|
-
|
5
|
-
describe Merb::Config do
|
6
|
-
before do
|
7
|
-
ARGV.replace([])
|
8
|
-
Merb::Server.should_receive(:start).and_return(nil)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should load the runner adapter by default" do
|
12
|
-
Merb.start
|
13
|
-
Merb::Config[:adapter].should == "runner"
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should load mongrel adapter when running `merb`" do
|
17
|
-
load(MERB_BIN)
|
18
|
-
Merb::Config[:adapter].should == "mongrel"
|
19
|
-
end
|
20
|
-
|
21
|
-
it "should override adapter when running `merb -a other`" do
|
22
|
-
ARGV.push *%w[-a other]
|
23
|
-
load(MERB_BIN)
|
24
|
-
Merb::Config[:adapter].should == "other"
|
25
|
-
end
|
26
|
-
|
27
|
-
it "should load irb adapter when running `merb -i`" do
|
28
|
-
ARGV << '-i'
|
29
|
-
load(MERB_BIN)
|
30
|
-
Merb::Config[:adapter].should == "irb"
|
31
|
-
end
|
32
|
-
end
|
@@ -1,202 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
-
|
3
|
-
describe Merb::Config do
|
4
|
-
before do
|
5
|
-
Merb::Config.setup
|
6
|
-
end
|
7
|
-
|
8
|
-
it "should be able to yield the configuration via #use" do
|
9
|
-
res = nil
|
10
|
-
Merb::Config.use {|c| res = c}
|
11
|
-
res.should == Merb::Config.defaults
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should be able to get a configuration key" do
|
15
|
-
Merb::Config[:host].should == "0.0.0.0"
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should be able to set a configuration key" do
|
19
|
-
Merb::Config[:bar] = "Hello"
|
20
|
-
Merb::Config[:bar].should == "Hello"
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should be able to #delete a configuration key" do
|
24
|
-
Merb::Config[:bar] = "Hello"
|
25
|
-
Merb::Config[:bar].should == "Hello"
|
26
|
-
Merb::Config.delete(:bar)
|
27
|
-
Merb::Config[:bar].should == nil
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should be able to #fetch a key that does exist" do
|
31
|
-
Merb::Config.fetch(:host, "192.168.2.1").should == "0.0.0.0"
|
32
|
-
end
|
33
|
-
|
34
|
-
it "should be able to #fetch a key that does exist" do
|
35
|
-
Merb::Config.fetch(:bar, "heylo").should == "heylo"
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should be able to dump to YAML" do
|
39
|
-
Merb::Config.to_yaml.should == Merb::Config.instance_variable_get("@configuration").to_yaml
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should support -u to set the user to run Merb as" do
|
43
|
-
Merb::Config.parse_args(["-u", "tester"])
|
44
|
-
Merb::Config[:user].should == "tester"
|
45
|
-
end
|
46
|
-
|
47
|
-
it "should support -G to set the group to run Merb as" do
|
48
|
-
Merb::Config.parse_args(["-G", "tester"])
|
49
|
-
Merb::Config[:group].should == "tester"
|
50
|
-
end
|
51
|
-
|
52
|
-
it "should support -d to daemonize Merb" do
|
53
|
-
Merb::Config.parse_args(["-d"])
|
54
|
-
Merb::Config[:daemonize].should == true
|
55
|
-
end
|
56
|
-
|
57
|
-
it "should support -c to set the number of cluster nodes" do
|
58
|
-
Merb::Config.parse_args(["-c", "4"])
|
59
|
-
Merb::Config[:cluster].should == "4"
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should support -p to set the port number" do
|
63
|
-
Merb::Config.parse_args(["-p", "6000"])
|
64
|
-
Merb::Config[:port].should == "6000"
|
65
|
-
end
|
66
|
-
|
67
|
-
it "should support -o to set the socket filename" do
|
68
|
-
Merb::Config.parse_args(["-o", "merb.2.sock"])
|
69
|
-
Merb::Config[:socket_file].should == "merb.2.sock"
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should support --socket-file to set the socket filename" do
|
73
|
-
Merb::Config.parse_args(["--socket-file", "app.thin.0.sock"])
|
74
|
-
Merb::Config[:socket_file].should == "app.thin.0.sock" # 0 is default socket #
|
75
|
-
end
|
76
|
-
|
77
|
-
it "should support -s to set the socket number" do
|
78
|
-
Merb::Config.parse_args(["-s", "0"])
|
79
|
-
Merb::Config[:socket].should == "0"
|
80
|
-
end
|
81
|
-
|
82
|
-
it "should support --socket to set the socket number" do
|
83
|
-
Merb::Config.parse_args(["--socket", "3"])
|
84
|
-
Merb::Config[:socket].should == "3"
|
85
|
-
end
|
86
|
-
|
87
|
-
it "should support -P to set the PIDfile" do
|
88
|
-
Merb::Config.parse_args(["-P", "pidfile"])
|
89
|
-
Merb::Config[:pid_file].should == "pidfile"
|
90
|
-
end
|
91
|
-
|
92
|
-
it "should have server return PIDfile setting as is with no cluster nodes" do
|
93
|
-
Merb::Config.parse_args(["-P", "pidfile", "-p", "6000"])
|
94
|
-
Merb::Server.pid_file(6000).should == "pidfile"
|
95
|
-
Merb::Server.pid_files.should == ["pidfile"]
|
96
|
-
end
|
97
|
-
|
98
|
-
it "should support setting of PIDfile with cluster nodes" do
|
99
|
-
Merb::Config.parse_args(["-P", "/tmp/merb.pidfile", "-c", "2", "-p", "6000"])
|
100
|
-
Merb::Server.pid_file(6000).should == "/tmp/merb.6000.pidfile"
|
101
|
-
Merb::Server.pid_file(6001).should == "/tmp/merb.6001.pidfile"
|
102
|
-
|
103
|
-
Dir.should_receive(:[]).with("/tmp/merb.*.pidfile")
|
104
|
-
Merb::Server.pid_files
|
105
|
-
end
|
106
|
-
|
107
|
-
it "should support default PIDfile setting" do
|
108
|
-
Merb::Config.parse_args(["-p", "6000"])
|
109
|
-
Merb::Server.pid_file(6000).should == Merb.log_path / "merb.6000.pid"
|
110
|
-
|
111
|
-
Dir.should_receive(:[]).with(Merb.log_path / "merb.*.pid")
|
112
|
-
Merb::Server.pid_files
|
113
|
-
end
|
114
|
-
|
115
|
-
it "should support -h to set the hostname" do
|
116
|
-
Merb::Config.parse_args(["-h", "hostname"])
|
117
|
-
Merb::Config[:host].should == "hostname"
|
118
|
-
end
|
119
|
-
|
120
|
-
it "should support -i to specify loading IRB" do
|
121
|
-
Merb::Config.parse_args(["-i"])
|
122
|
-
Merb::Config[:adapter].should == "irb"
|
123
|
-
end
|
124
|
-
|
125
|
-
it "should support -l to specify the log level" do
|
126
|
-
Merb::Config.parse_args(["-l", "debug"])
|
127
|
-
Merb::Config[:log_level].should == :debug
|
128
|
-
end
|
129
|
-
|
130
|
-
it "should support -L to specify the location of the log file" do
|
131
|
-
Merb::Config.parse_args(["-L", "log_file"])
|
132
|
-
Merb::Config[:log_file].should == "log_file"
|
133
|
-
end
|
134
|
-
|
135
|
-
it "should support -r to specify a runner" do
|
136
|
-
Merb::Config.parse_args(["-r", "foo_runner"])
|
137
|
-
Merb::Config[:runner_code].should == "foo_runner"
|
138
|
-
Merb::Config[:adapter].should == "runner"
|
139
|
-
end
|
140
|
-
|
141
|
-
it "should support -R to specify a rackup file" do
|
142
|
-
Merb::Config.parse_args(["-R", "config.ru"])
|
143
|
-
Merb::Config[:rackup].should == "config.ru"
|
144
|
-
end
|
145
|
-
|
146
|
-
it "should support -K for a graceful kill" do
|
147
|
-
Merb::Server.should_receive(:kill).with("all", 1)
|
148
|
-
Merb.start(["-K", "all"])
|
149
|
-
end
|
150
|
-
|
151
|
-
it "should support -k for a hard kill" do
|
152
|
-
Merb::Server.should_receive(:kill).with("all", 9)
|
153
|
-
Merb.start(["-k", "all"])
|
154
|
-
end
|
155
|
-
|
156
|
-
it "should support -X off to turn off the mutex" do
|
157
|
-
Merb::Config.parse_args(["-X", "off"])
|
158
|
-
Merb::Config[:use_mutex].should == false
|
159
|
-
end
|
160
|
-
|
161
|
-
it "should support -X on to turn off the mutex" do
|
162
|
-
Merb::Config.parse_args(["-X", "on"])
|
163
|
-
Merb::Config[:use_mutex].should == true
|
164
|
-
end
|
165
|
-
|
166
|
-
it "should take Merb.disable into account" do
|
167
|
-
Merb::Config[:disabled_components].should == []
|
168
|
-
Merb::Config[:disabled_components] << :foo
|
169
|
-
Merb.disable(:bar)
|
170
|
-
Merb.disable(:buz, :fux)
|
171
|
-
Merb::Config[:disabled_components].should == [:foo, :bar, :buz, :fux]
|
172
|
-
Merb.disabled?(:foo).should == true
|
173
|
-
Merb.disabled?(:foo, :buz).should == true
|
174
|
-
end
|
175
|
-
|
176
|
-
it "should take Merb.testing? into account" do
|
177
|
-
$TESTING.should == true
|
178
|
-
Merb::Config[:testing].should be_nil
|
179
|
-
Merb.should be_testing
|
180
|
-
$TESTING = false
|
181
|
-
Merb.should_not be_testing
|
182
|
-
Merb::Config[:testing] = true
|
183
|
-
Merb.should be_testing
|
184
|
-
$TESTING = true; Merb::Config[:testing] = false # reset
|
185
|
-
end
|
186
|
-
|
187
|
-
it "supports -V to turn on verbose mode" do
|
188
|
-
Merb::Config[:verbose] = false
|
189
|
-
Merb::Config.parse_args(["-V"])
|
190
|
-
Merb::Config[:verbose].should be(true)
|
191
|
-
end
|
192
|
-
|
193
|
-
it "supports --verbose to turn on verbose mode" do
|
194
|
-
Merb::Config[:verbose] = false
|
195
|
-
Merb::Config.parse_args(["--verbose"])
|
196
|
-
Merb::Config[:verbose].should be(true)
|
197
|
-
end
|
198
|
-
|
199
|
-
it "has verbose mode turned off by default" do
|
200
|
-
Merb::Config[:verbose].should be(false)
|
201
|
-
end
|
202
|
-
end
|