waves 0.7.7 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/waves +17 -72
- data/doc/HISTORY +1 -44
- data/doc/README +1 -0
- data/doc/VERSION +1 -0
- data/lib/caches/file.rb +48 -0
- data/lib/caches/memcached.rb +40 -0
- data/lib/caches/simple.rb +25 -0
- data/lib/caches/synchronized.rb +25 -0
- data/lib/commands/console.rb +35 -0
- data/lib/commands/generate.rb +52 -0
- data/lib/commands/help.rb +5 -0
- data/lib/commands/{waves-server.rb → server.rb} +16 -3
- data/lib/dispatchers/base.rb +21 -20
- data/lib/dispatchers/default.rb +11 -63
- data/lib/ext/float.rb +13 -0
- data/lib/{utilities → ext}/hash.rb +2 -2
- data/lib/{utilities → ext}/integer.rb +5 -2
- data/lib/ext/kernel.rb +20 -0
- data/lib/ext/module.rb +20 -0
- data/lib/{utilities → ext}/object.rb +3 -5
- data/lib/ext/string.rb +20 -0
- data/lib/ext/symbol.rb +11 -0
- data/lib/ext/tempfile.rb +5 -0
- data/lib/foundations/classic.rb +64 -0
- data/lib/foundations/compact.rb +50 -0
- data/lib/helpers/basic.rb +11 -0
- data/lib/helpers/doc_type.rb +34 -0
- data/lib/helpers/extended.rb +21 -0
- data/lib/helpers/form.rb +3 -1
- data/lib/helpers/formatting.rb +3 -3
- data/lib/helpers/layouts.rb +37 -0
- data/lib/helpers/model.rb +8 -4
- data/lib/helpers/view.rb +2 -4
- data/lib/layers/inflect/english.rb +48 -5
- data/lib/layers/mvc.rb +18 -18
- data/lib/layers/mvc/controllers.rb +41 -0
- data/lib/layers/mvc/extensions.rb +52 -0
- data/lib/layers/orm/{active_record.rb → providers/active_record.rb} +9 -14
- data/lib/layers/orm/{active_record → providers/active_record}/migrations/empty.rb.erb +0 -0
- data/lib/layers/orm/{active_record → providers/active_record}/tasks/generate.rb +1 -1
- data/lib/layers/orm/{active_record → providers/active_record}/tasks/schema.rb +1 -1
- data/lib/layers/orm/{data_mapper.rb → providers/data_mapper.rb} +3 -4
- data/lib/layers/orm/providers/filebase.rb +25 -0
- data/lib/layers/orm/{sequel.rb → providers/sequel.rb} +11 -7
- data/lib/layers/orm/{sequel → providers/sequel}/migrations/empty.rb.erb +0 -0
- data/lib/layers/orm/{sequel → providers/sequel}/tasks/generate.rb +5 -3
- data/lib/layers/orm/{sequel → providers/sequel}/tasks/schema.rb +2 -2
- data/lib/{renderers → layers/renderers}/erubis.rb +10 -13
- data/lib/{renderers → layers/renderers}/haml.rb +27 -25
- data/lib/layers/renderers/markaby.rb +29 -0
- data/lib/matchers/accept.rb +21 -0
- data/lib/matchers/base.rb +30 -0
- data/lib/matchers/content_type.rb +17 -0
- data/lib/matchers/path.rb +67 -0
- data/lib/matchers/query.rb +21 -0
- data/lib/matchers/request.rb +27 -0
- data/lib/matchers/resource.rb +19 -0
- data/lib/matchers/traits.rb +19 -0
- data/lib/matchers/uri.rb +20 -0
- data/lib/renderers/mixin.rb +15 -29
- data/lib/resources/mixin.rb +132 -0
- data/lib/resources/paths.rb +34 -0
- data/lib/runtime/configuration.rb +55 -135
- data/lib/runtime/console.rb +4 -1
- data/lib/runtime/logger.rb +24 -48
- data/lib/runtime/mime_types.rb +516 -2
- data/lib/runtime/mocks.rb +14 -0
- data/lib/runtime/monitor.rb +32 -0
- data/lib/runtime/request.rb +107 -39
- data/lib/runtime/response.rb +5 -2
- data/lib/runtime/response_mixin.rb +43 -22
- data/lib/runtime/runtime.rb +67 -0
- data/lib/runtime/server.rb +14 -101
- data/lib/runtime/session.rb +4 -43
- data/lib/runtime/worker.rb +86 -0
- data/lib/servers/base.rb +42 -0
- data/lib/servers/mongrel.rb +13 -0
- data/lib/servers/webrick.rb +13 -0
- data/lib/tasks/gem.rb +1 -0
- data/lib/tasks/generate.rb +67 -62
- data/lib/views/errors.rb +49 -0
- data/lib/views/mixin.rb +34 -82
- data/lib/waves.rb +36 -57
- data/samples/blog/Rakefile +16 -5
- data/samples/blog/blog.db +0 -0
- data/samples/blog/configurations/default.rb +11 -0
- data/samples/blog/configurations/development.rb +9 -11
- data/samples/blog/configurations/production.rb +11 -15
- data/samples/blog/log/waves.production +3 -0
- data/samples/blog/models/comment.rb +9 -0
- data/samples/blog/models/entry.rb +17 -0
- data/samples/blog/public/css/site.css +13 -2
- data/samples/blog/public/javascript/jquery-1.2.6.min.js +32 -0
- data/samples/blog/resources/entry.rb +39 -0
- data/samples/blog/resources/map.rb +9 -0
- data/samples/blog/schema/migrations/001_initial_schema.rb +3 -3
- data/samples/blog/schema/migrations/002_add_comments.rb +2 -2
- data/samples/blog/startup.rb +8 -6
- data/samples/blog/templates/comment/add.mab +6 -4
- data/samples/blog/templates/comment/list.mab +4 -4
- data/samples/blog/templates/entry/{editor.mab → edit.mab} +7 -6
- data/samples/blog/templates/entry/list.mab +10 -5
- data/samples/blog/templates/entry/show.mab +16 -7
- data/samples/blog/templates/entry/summary.mab +8 -4
- data/samples/blog/templates/errors/not_found_404.mab +6 -1
- data/samples/blog/templates/layouts/default.mab +5 -3
- data/samples/blog/templates/waves/status.mab +85 -0
- data/{app → templates/classic}/Rakefile +58 -0
- data/templates/classic/configurations/default.rb.erb +9 -0
- data/{app → templates/classic}/configurations/development.rb.erb +3 -8
- data/{app → templates/classic}/configurations/production.rb.erb +3 -5
- data/templates/classic/resources/map.rb.erb +8 -0
- data/templates/classic/startup.rb.erb +11 -0
- data/{app → templates/classic}/templates/errors/not_found_404.mab +0 -0
- data/{app → templates/classic}/templates/errors/server_error_500.mab +0 -0
- data/{app → templates/classic}/templates/layouts/default.mab +0 -0
- data/templates/compact/startup.rb.erb +11 -0
- metadata +257 -610
- data/app/bin/waves-console +0 -4
- data/app/bin/waves-server +0 -4
- data/app/configurations/mapping.rb.erb +0 -14
- data/app/controllers/.gitignore +0 -0
- data/app/doc/.gitignore +0 -0
- data/app/helpers/.gitignore +0 -0
- data/app/lib/application.rb.erb +0 -5
- data/app/lib/tasks/.gitignore +0 -0
- data/app/log/.gitignore +0 -0
- data/app/models/.gitignore +0 -0
- data/app/public/css/.gitignore +0 -0
- data/app/public/flash/.gitignore +0 -0
- data/app/public/images/.gitignore +0 -0
- data/app/public/javascript/.gitignore +0 -0
- data/app/schema/migrations/.gitignore +0 -0
- data/app/startup.rb +0 -5
- data/app/tmp/sessions/.gitignore +0 -0
- data/app/views/.gitignore +0 -0
- data/bin/waves-console +0 -4
- data/bin/waves-server +0 -4
- data/doc/rdoc/classes/Erubis/Context.html +0 -218
- data/doc/rdoc/classes/Kernel.html +0 -145
- data/doc/rdoc/classes/Symbol.html +0 -154
- data/doc/rdoc/classes/Tempfile.html +0 -161
- data/doc/rdoc/classes/Waves.html +0 -455
- data/doc/rdoc/classes/Waves/Application.html +0 -371
- data/doc/rdoc/classes/Waves/Blackboard.html +0 -296
- data/doc/rdoc/classes/Waves/Configurations.html +0 -283
- data/doc/rdoc/classes/Waves/Configurations/Base.html +0 -209
- data/doc/rdoc/classes/Waves/Configurations/Default.html +0 -237
- data/doc/rdoc/classes/Waves/Console.html +0 -187
- data/doc/rdoc/classes/Waves/Controllers.html +0 -203
- data/doc/rdoc/classes/Waves/Controllers/Base.html +0 -151
- data/doc/rdoc/classes/Waves/Controllers/Mixin.html +0 -312
- data/doc/rdoc/classes/Waves/Dispatchers.html +0 -118
- data/doc/rdoc/classes/Waves/Dispatchers/Base.html +0 -198
- data/doc/rdoc/classes/Waves/Dispatchers/Default.html +0 -224
- data/doc/rdoc/classes/Waves/Dispatchers/NotFoundError.html +0 -122
- data/doc/rdoc/classes/Waves/Dispatchers/Redirect.html +0 -173
- data/doc/rdoc/classes/Waves/Foundations.html +0 -131
- data/doc/rdoc/classes/Waves/Foundations/Default.html +0 -179
- data/doc/rdoc/classes/Waves/Foundations/Simple.html +0 -167
- data/doc/rdoc/classes/Waves/Helpers.html +0 -176
- data/doc/rdoc/classes/Waves/Helpers/AssetHelper.html +0 -212
- data/doc/rdoc/classes/Waves/Helpers/Common.html +0 -213
- data/doc/rdoc/classes/Waves/Helpers/Default.html +0 -135
- data/doc/rdoc/classes/Waves/Helpers/Form.html +0 -201
- data/doc/rdoc/classes/Waves/Helpers/Formatting.html +0 -232
- data/doc/rdoc/classes/Waves/Helpers/Model.html +0 -194
- data/doc/rdoc/classes/Waves/Helpers/NumberHelper.html +0 -165
- data/doc/rdoc/classes/Waves/Helpers/TagHelper.html +0 -226
- data/doc/rdoc/classes/Waves/Helpers/UrlHelper.html +0 -242
- data/doc/rdoc/classes/Waves/Helpers/View.html +0 -163
- data/doc/rdoc/classes/Waves/Inflect/InflectorMethods.html +0 -475
- data/doc/rdoc/classes/Waves/Layers.html +0 -175
- data/doc/rdoc/classes/Waves/Layers/DefaultErrors.html +0 -161
- data/doc/rdoc/classes/Waves/Layers/Inflect.html +0 -119
- data/doc/rdoc/classes/Waves/Layers/Inflect/English.html +0 -168
- data/doc/rdoc/classes/Waves/Layers/Inflect/English/Rules.html +0 -112
- data/doc/rdoc/classes/Waves/Layers/Inflect/English/StringMethods.html +0 -194
- data/doc/rdoc/classes/Waves/Layers/MVC.html +0 -204
- data/doc/rdoc/classes/Waves/Layers/ORM/ActiveRecord.html +0 -239
- data/doc/rdoc/classes/Waves/Layers/ORM/ActiveRecord/ControllerMethods.html +0 -246
- data/doc/rdoc/classes/Waves/Layers/ORM/ActiveRecord/Symbol.html +0 -132
- data/doc/rdoc/classes/Waves/Layers/ORM/DataMapper.html +0 -166
- data/doc/rdoc/classes/Waves/Layers/ORM/Filebase.html +0 -157
- data/doc/rdoc/classes/Waves/Layers/ORM/Sequel.html +0 -232
- data/doc/rdoc/classes/Waves/Layers/ORM/Sequel/ControllerMethods.html +0 -246
- data/doc/rdoc/classes/Waves/Layers/Simple.html +0 -169
- data/doc/rdoc/classes/Waves/Layers/SimpleErrors.html +0 -159
- data/doc/rdoc/classes/Waves/Logger.html +0 -288
- data/doc/rdoc/classes/Waves/Mapping.html +0 -760
- data/doc/rdoc/classes/Waves/Mapping/PrettyUrls.html +0 -129
- data/doc/rdoc/classes/Waves/Mapping/PrettyUrls/GetRules.html +0 -174
- data/doc/rdoc/classes/Waves/Mapping/PrettyUrls/RestRules.html +0 -180
- data/doc/rdoc/classes/Waves/MimeTypes.html +0 -200
- data/doc/rdoc/classes/Waves/Renderers/Erubis.html +0 -162
- data/doc/rdoc/classes/Waves/Renderers/Haml.html +0 -160
- data/doc/rdoc/classes/Waves/Renderers/Markaby.html +0 -167
- data/doc/rdoc/classes/Waves/Renderers/Mixin.html +0 -191
- data/doc/rdoc/classes/Waves/Renderers/Scope.html +0 -181
- data/doc/rdoc/classes/Waves/Request.html +0 -441
- data/doc/rdoc/classes/Waves/Request/ParseError.html +0 -111
- data/doc/rdoc/classes/Waves/Response.html +0 -283
- data/doc/rdoc/classes/Waves/ResponseMixin.html +0 -460
- data/doc/rdoc/classes/Waves/ResponseProxy.html +0 -269
- data/doc/rdoc/classes/Waves/Server.html +0 -488
- data/doc/rdoc/classes/Waves/Session.html +0 -330
- data/doc/rdoc/classes/Waves/Utilities/Hash.html +0 -185
- data/doc/rdoc/classes/Waves/Utilities/Integer.html +0 -424
- data/doc/rdoc/classes/Waves/Utilities/Module.html +0 -174
- data/doc/rdoc/classes/Waves/Utilities/Object.html +0 -155
- data/doc/rdoc/classes/Waves/Utilities/Proc.html +0 -145
- data/doc/rdoc/classes/Waves/Utilities/String.html +0 -290
- data/doc/rdoc/classes/Waves/Views.html +0 -278
- data/doc/rdoc/classes/Waves/Views/Base.html +0 -118
- data/doc/rdoc/classes/Waves/Views/Mixin.html +0 -279
- data/doc/rdoc/classes/Waves/Views/NoTemplateError.html +0 -111
- data/doc/rdoc/created.rid +0 -1
- data/doc/rdoc/files/README_rdoc.html +0 -415
- data/doc/rdoc/files/bin/waves.html +0 -135
- data/doc/rdoc/files/doc/HISTORY.html +0 -265
- data/doc/rdoc/files/lib/commands/waves-console_rb.html +0 -110
- data/doc/rdoc/files/lib/commands/waves-server_rb.html +0 -108
- data/doc/rdoc/files/lib/controllers/base_rb.html +0 -101
- data/doc/rdoc/files/lib/controllers/mixin_rb.html +0 -101
- data/doc/rdoc/files/lib/dispatchers/base_rb.html +0 -101
- data/doc/rdoc/files/lib/dispatchers/default_rb.html +0 -101
- data/doc/rdoc/files/lib/foundations/default_rb.html +0 -101
- data/doc/rdoc/files/lib/foundations/simple_rb.html +0 -101
- data/doc/rdoc/files/lib/helpers/asset_helper_rb.html +0 -101
- data/doc/rdoc/files/lib/helpers/common_rb.html +0 -101
- data/doc/rdoc/files/lib/helpers/default_rb.html +0 -101
- data/doc/rdoc/files/lib/helpers/form_rb.html +0 -101
- data/doc/rdoc/files/lib/helpers/formatting_rb.html +0 -108
- data/doc/rdoc/files/lib/helpers/model_rb.html +0 -101
- data/doc/rdoc/files/lib/helpers/number_helper_rb.html +0 -101
- data/doc/rdoc/files/lib/helpers/tag_helper_rb.html +0 -101
- data/doc/rdoc/files/lib/helpers/url_helper_rb.html +0 -101
- data/doc/rdoc/files/lib/helpers/view_rb.html +0 -101
- data/doc/rdoc/files/lib/layers/default_errors_rb.html +0 -101
- data/doc/rdoc/files/lib/layers/inflect/english/rules_rb.html +0 -101
- data/doc/rdoc/files/lib/layers/inflect/english/string_rb.html +0 -101
- data/doc/rdoc/files/lib/layers/inflect/english_rb.html +0 -109
- data/doc/rdoc/files/lib/layers/mvc_rb.html +0 -101
- data/doc/rdoc/files/lib/layers/orm/active_record/tasks/generate_rb.html +0 -101
- data/doc/rdoc/files/lib/layers/orm/active_record/tasks/schema_rb.html +0 -101
- data/doc/rdoc/files/lib/layers/orm/active_record_rb.html +0 -108
- data/doc/rdoc/files/lib/layers/orm/data_mapper_rb.html +0 -108
- data/doc/rdoc/files/lib/layers/orm/filebase_rb.html +0 -101
- data/doc/rdoc/files/lib/layers/orm/migration_rb.html +0 -101
- data/doc/rdoc/files/lib/layers/orm/sequel/tasks/generate_rb.html +0 -101
- data/doc/rdoc/files/lib/layers/orm/sequel/tasks/schema_rb.html +0 -101
- data/doc/rdoc/files/lib/layers/orm/sequel_rb.html +0 -108
- data/doc/rdoc/files/lib/layers/simple_errors_rb.html +0 -101
- data/doc/rdoc/files/lib/layers/simple_rb.html +0 -101
- data/doc/rdoc/files/lib/mapping/mapping_rb.html +0 -101
- data/doc/rdoc/files/lib/mapping/pretty_urls_rb.html +0 -101
- data/doc/rdoc/files/lib/renderers/erubis_rb.html +0 -108
- data/doc/rdoc/files/lib/renderers/haml_rb.html +0 -108
- data/doc/rdoc/files/lib/renderers/markaby_rb.html +0 -108
- data/doc/rdoc/files/lib/renderers/mixin_rb.html +0 -101
- data/doc/rdoc/files/lib/runtime/application_rb.html +0 -107
- data/doc/rdoc/files/lib/runtime/blackboard_rb.html +0 -101
- data/doc/rdoc/files/lib/runtime/configuration_rb.html +0 -101
- data/doc/rdoc/files/lib/runtime/console_rb.html +0 -101
- data/doc/rdoc/files/lib/runtime/debugger_rb.html +0 -101
- data/doc/rdoc/files/lib/runtime/logger_rb.html +0 -108
- data/doc/rdoc/files/lib/runtime/mime_types_rb.html +0 -101
- data/doc/rdoc/files/lib/runtime/request_rb.html +0 -101
- data/doc/rdoc/files/lib/runtime/response_mixin_rb.html +0 -101
- data/doc/rdoc/files/lib/runtime/response_proxy_rb.html +0 -101
- data/doc/rdoc/files/lib/runtime/response_rb.html +0 -101
- data/doc/rdoc/files/lib/runtime/server_rb.html +0 -108
- data/doc/rdoc/files/lib/runtime/session_rb.html +0 -101
- data/doc/rdoc/files/lib/tasks/cluster_rb.html +0 -101
- data/doc/rdoc/files/lib/tasks/gem_rb.html +0 -108
- data/doc/rdoc/files/lib/tasks/generate_rb.html +0 -101
- data/doc/rdoc/files/lib/utilities/hash_rb.html +0 -101
- data/doc/rdoc/files/lib/utilities/inflect_rb.html +0 -111
- data/doc/rdoc/files/lib/utilities/integer_rb.html +0 -101
- data/doc/rdoc/files/lib/utilities/module_rb.html +0 -101
- data/doc/rdoc/files/lib/utilities/object_rb.html +0 -101
- data/doc/rdoc/files/lib/utilities/proc_rb.html +0 -101
- data/doc/rdoc/files/lib/utilities/string_rb.html +0 -101
- data/doc/rdoc/files/lib/utilities/symbol_rb.html +0 -101
- data/doc/rdoc/files/lib/utilities/tempfile_rb.html +0 -115
- data/doc/rdoc/files/lib/views/base_rb.html +0 -101
- data/doc/rdoc/files/lib/views/mixin_rb.html +0 -101
- data/doc/rdoc/files/lib/waves_rb.html +0 -195
- data/doc/rdoc/fr_class_index.html +0 -104
- data/doc/rdoc/fr_file_index.html +0 -97
- data/doc/rdoc/fr_method_index.html +0 -233
- data/doc/rdoc/index.html +0 -24
- data/doc/rdoc/rdoc-style.css +0 -208
- data/lib/commands/waves-console.rb +0 -21
- data/lib/controllers/base.rb +0 -11
- data/lib/controllers/mixin.rb +0 -165
- data/lib/foundations/default.rb +0 -27
- data/lib/foundations/simple.rb +0 -30
- data/lib/helpers/asset_helper.rb +0 -67
- data/lib/helpers/common.rb +0 -66
- data/lib/helpers/default.rb +0 -13
- data/lib/helpers/number_helper.rb +0 -25
- data/lib/helpers/tag_helper.rb +0 -58
- data/lib/helpers/url_helper.rb +0 -77
- data/lib/layers/default_errors.rb +0 -26
- data/lib/layers/inflect/english/rules.rb +0 -88
- data/lib/layers/inflect/english/string.rb +0 -24
- data/lib/layers/orm/filebase.rb +0 -22
- data/lib/layers/simple.rb +0 -32
- data/lib/layers/simple_errors.rb +0 -23
- data/lib/mapping/mapping.rb +0 -289
- data/lib/mapping/pretty_urls.rb +0 -96
- data/lib/renderers/markaby.rb +0 -33
- data/lib/runtime/application.rb +0 -69
- data/lib/runtime/blackboard.rb +0 -57
- data/lib/runtime/debugger.rb +0 -9
- data/lib/runtime/response_proxy.rb +0 -30
- data/lib/tasks/cluster.rb +0 -26
- data/lib/utilities/inflect.rb +0 -110
- data/lib/utilities/module.rb +0 -21
- data/lib/utilities/proc.rb +0 -16
- data/lib/utilities/string.rb +0 -49
- data/lib/utilities/symbol.rb +0 -10
- data/lib/utilities/tempfile.rb +0 -9
- data/lib/views/base.rb +0 -9
- data/samples/blog/bin/waves-console +0 -3
- data/samples/blog/bin/waves-server +0 -3
- data/samples/blog/configurations/mapping.rb +0 -23
- data/samples/blog/doc/EMTPY +0 -0
- data/samples/blog/lib/application.rb +0 -5
- data/samples/jub/Rakefile +0 -72
- data/samples/jub/bin/waves-console +0 -4
- data/samples/jub/bin/waves-server +0 -4
- data/samples/jub/configurations/development.rb +0 -31
- data/samples/jub/configurations/mapping.rb +0 -18
- data/samples/jub/configurations/production.rb +0 -31
- data/samples/jub/lib/application.rb +0 -5
- data/samples/jub/startup.rb +0 -6
- data/samples/jub/templates/errors/not_found_404.mab +0 -2
- data/samples/jub/templates/errors/server_error_500.mab +0 -2
- data/samples/jub/templates/layouts/default.mab +0 -14
- data/verify/app_generation/helpers.rb +0 -24
- data/verify/app_generation/startup.rb +0 -39
- data/verify/blackboard/blackboard_verify.rb +0 -92
- data/verify/blackboard/helpers.rb +0 -5
- data/verify/configurations/attributes.rb +0 -37
- data/verify/configurations/helpers.rb +0 -1
- data/verify/configurations/rack_integration.rb +0 -29
- data/verify/controllers/base.rb +0 -37
- data/verify/controllers/helpers.rb +0 -13
- data/verify/controllers/interface.rb +0 -51
- data/verify/core/helpers.rb +0 -3
- data/verify/core/utilities.rb +0 -177
- data/verify/foundations/default.rb +0 -86
- data/verify/foundations/default_application/Rakefile +0 -14
- data/verify/foundations/default_application/bin/waves-console +0 -3
- data/verify/foundations/default_application/bin/waves-server +0 -3
- data/verify/foundations/default_application/configurations/development.rb +0 -26
- data/verify/foundations/default_application/configurations/mapping.rb +0 -14
- data/verify/foundations/default_application/configurations/production.rb +0 -30
- data/verify/foundations/default_application/controllers/default.rb +0 -15
- data/verify/foundations/default_application/controllers/loaded.rb +0 -15
- data/verify/foundations/default_application/defaultapplication.db +0 -0
- data/verify/foundations/default_application/helpers/loaded.rb +0 -10
- data/verify/foundations/default_application/lib/application.rb +0 -5
- data/verify/foundations/default_application/models/default.rb +0 -13
- data/verify/foundations/default_application/models/loaded.rb +0 -13
- data/verify/foundations/default_application/schema/migrations/templates/empty.rb.erb +0 -9
- data/verify/foundations/default_application/startup.rb +0 -7
- data/verify/foundations/default_application/templates/errors/not_found_404.mab +0 -2
- data/verify/foundations/default_application/templates/errors/server_error_500.mab +0 -2
- data/verify/foundations/default_application/templates/layouts/default.mab +0 -14
- data/verify/foundations/default_application/views/default.rb +0 -7
- data/verify/foundations/default_application/views/loaded.rb +0 -15
- data/verify/foundations/helpers.rb +0 -1
- data/verify/foundations/simple.rb +0 -25
- data/verify/helpers.rb +0 -76
- data/verify/layers/data_mapper/association_verify.rb +0 -87
- data/verify/layers/default_errors.rb +0 -29
- data/verify/layers/helpers.rb +0 -1
- data/verify/layers/migration.rb +0 -33
- data/verify/layers/sequel/model.rb +0 -41
- data/verify/layers/sequeltest.db +0 -0
- data/verify/mapping/always.rb +0 -19
- data/verify/mapping/filters.rb +0 -65
- data/verify/mapping/handle.rb +0 -24
- data/verify/mapping/helpers.rb +0 -7
- data/verify/mapping/matches.rb +0 -27
- data/verify/mapping/named.rb +0 -29
- data/verify/mapping/options.rb +0 -17
- data/verify/mapping/path.rb +0 -40
- data/verify/mapping/response_proxy.rb +0 -50
- data/verify/mapping/threaded.rb +0 -25
- data/verify/requests/helpers.rb +0 -16
- data/verify/requests/request.rb +0 -73
- data/verify/requests/response.rb +0 -59
- data/verify/requests/session.rb +0 -54
- data/verify/views/helpers.rb +0 -1
- data/verify/views/rendering.rb +0 -34
- data/verify/views/templates/foo.erb +0 -0
- data/verify/views/templates/moo.erb +0 -0
- data/verify/views/templates/moo.mab +0 -0
data/lib/helpers/url_helper.rb
DELETED
@@ -1,77 +0,0 @@
|
|
1
|
-
module Waves
|
2
|
-
module Helpers
|
3
|
-
module UrlHelper
|
4
|
-
|
5
|
-
# Returns the URL for the set of +options+ provided. This takes the
|
6
|
-
# same options as url_for in action controller. For a list, see the
|
7
|
-
# documentation for ActionController::Base#url_for. Note that it'll
|
8
|
-
# set :only_path => true so you'll get the relative /controller/action
|
9
|
-
# instead of the fully qualified http://example.com/controller/action.
|
10
|
-
#
|
11
|
-
# When called from a view, url_for returns an HTML escaped url. If you
|
12
|
-
# need an unescaped url, pass :escape => false in the +options+.
|
13
|
-
def url_for(options = {}, *parameters_for_method_reference)
|
14
|
-
if options.kind_of? Hash
|
15
|
-
options = { :only_path => true }.update(options.symbolize_keys)
|
16
|
-
escape = options.key?(:escape) ? options.delete(:escape) : true
|
17
|
-
else
|
18
|
-
escape = true
|
19
|
-
end
|
20
|
-
|
21
|
-
url = options[:url] #@controller.send(:url_for, options, *parameters_for_method_reference)
|
22
|
-
escape ? html_escape(url) : url
|
23
|
-
end
|
24
|
-
|
25
|
-
|
26
|
-
# Creates a link tag of the given +name+ using a URL created by the set
|
27
|
-
# of +options+. See the valid options in the documentation for
|
28
|
-
# ActionController::Base#url_for. It's also possible to pass a string instead
|
29
|
-
# of an options hash to get a link tag that uses the value of the string as the
|
30
|
-
# href for the link. If nil is passed as a name, the link itself will become
|
31
|
-
# the name.
|
32
|
-
#
|
33
|
-
# The +html_options+ will accept a hash of html attributes for the link tag.
|
34
|
-
# It also accepts 3 modifiers that specialize the link behavior.
|
35
|
-
#
|
36
|
-
# * <tt>:confirm => 'question?'</tt>: This will add a JavaScript confirm
|
37
|
-
# prompt with the question specified. If the user accepts, the link is
|
38
|
-
# processed normally, otherwise no action is taken.
|
39
|
-
# * <tt>:popup => true || array of window options</tt>: This will force the
|
40
|
-
# link to open in a popup window. By passing true, a default browser window
|
41
|
-
# will be opened with the URL. You can also specify an array of options
|
42
|
-
# that are passed-thru to JavaScripts window.open method.
|
43
|
-
# * <tt>:method => symbol of HTTP verb</tt>: This modifier will dynamically
|
44
|
-
# create an HTML form and immediately submit the form for processing using
|
45
|
-
# the HTTP verb specified. Useful for having links perform a POST operation
|
46
|
-
# in dangerous actions like deleting a record (which search bots can follow
|
47
|
-
# while spidering your site). Supported verbs are :post, :delete and :put.
|
48
|
-
# Note that if the user has JavaScript disabled, the request will fall back
|
49
|
-
# to using GET. If you are relying on the POST behavior, your should check
|
50
|
-
# for it in your controllers action by using the request objects methods
|
51
|
-
# for post?, delete? or put?.
|
52
|
-
#
|
53
|
-
# You can mix and match the +html_options+ with the exception of
|
54
|
-
# :popup and :method which will raise an ActionView::ActionViewError
|
55
|
-
# exception.
|
56
|
-
#
|
57
|
-
# link_to "Visit Other Site", "http://www.rubyonrails.org/", :confirm => "Are you sure?"
|
58
|
-
# link_to "Help", { :action => "help" }, :popup => true
|
59
|
-
# link_to "View Image", { :action => "view" }, :popup => ['new_window_name', 'height=300,width=600']
|
60
|
-
# link_to "Delete Image", { :action => "delete", :id => @image.id }, :confirm => "Are you sure?", :method => :delete
|
61
|
-
def link_to(name, options = {}, html_options = nil, *parameters_for_method_reference)
|
62
|
-
if html_options
|
63
|
-
html_options = html_options.stringify_keys
|
64
|
-
# convert_options_to_javascript!(html_options)
|
65
|
-
tag_options = tag_options(html_options)
|
66
|
-
else
|
67
|
-
tag_options = nil
|
68
|
-
end
|
69
|
-
|
70
|
-
url = options.is_a?(String) ? options : self.url_for(options, *parameters_for_method_reference)
|
71
|
-
"<a href=\"#{url}\"#{tag_options}>#{name || url}</a>"
|
72
|
-
end
|
73
|
-
|
74
|
-
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Waves
|
2
|
-
module Layers
|
3
|
-
|
4
|
-
# Configures Waves to use the templates in app/templates/errors for exception handling
|
5
|
-
module DefaultErrors
|
6
|
-
|
7
|
-
def self.included( app )
|
8
|
-
|
9
|
-
app.auto_eval :Configurations do
|
10
|
-
auto_eval :Mapping do
|
11
|
-
extend Waves::Mapping
|
12
|
-
handle(Waves::Dispatchers::NotFoundError) do
|
13
|
-
html = Waves.application.views[:errors].process( request ) do
|
14
|
-
not_found_404( :error => Waves::Dispatchers::NotFoundError )
|
15
|
-
end
|
16
|
-
response.status = '404'
|
17
|
-
response.content_type = 'text/html'
|
18
|
-
response.body = html
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,88 +0,0 @@
|
|
1
|
-
module Waves
|
2
|
-
module Layers
|
3
|
-
module Inflect
|
4
|
-
module English
|
5
|
-
# Extends Waves::Inflect::InflectorMethods
|
6
|
-
module Rules
|
7
|
-
|
8
|
-
extend Waves::Inflect::InflectorMethods
|
9
|
-
|
10
|
-
# One argument means singular and plural are the same.
|
11
|
-
word 'equipment'
|
12
|
-
word 'information'
|
13
|
-
word 'money'
|
14
|
-
word 'species'
|
15
|
-
word 'series'
|
16
|
-
word 'fish'
|
17
|
-
word 'sheep'
|
18
|
-
word 'moose'
|
19
|
-
word 'hovercraft'
|
20
|
-
|
21
|
-
# Two arguments defines a singular and plural exception.
|
22
|
-
word 'Swiss' , 'Swiss'
|
23
|
-
word 'life' , 'lives'
|
24
|
-
word 'wife' , 'wives'
|
25
|
-
word 'cactus' , 'cacti'
|
26
|
-
word 'goose' , 'geese'
|
27
|
-
word 'criterion' , 'criteria'
|
28
|
-
word 'alias' , 'aliases'
|
29
|
-
word 'status' , 'statuses'
|
30
|
-
word 'axis' , 'axes'
|
31
|
-
word 'crisis' , 'crises'
|
32
|
-
word 'testis' , 'testes'
|
33
|
-
word 'child' , 'children'
|
34
|
-
word 'person' , 'people'
|
35
|
-
word 'potato' , 'potatoes'
|
36
|
-
word 'tomato' , 'tomatoes'
|
37
|
-
word 'buffalo' , 'buffaloes'
|
38
|
-
word 'torpedo' , 'torpedoes'
|
39
|
-
word 'quiz' , 'quizes'
|
40
|
-
word 'matrix' , 'matrices'
|
41
|
-
word 'vertex' , 'vetices'
|
42
|
-
word 'index' , 'indices'
|
43
|
-
word 'ox' , 'oxen'
|
44
|
-
word 'mouse' , 'mice'
|
45
|
-
word 'louse' , 'lice'
|
46
|
-
word 'thesis' , 'theses'
|
47
|
-
word 'thief' , 'thieves'
|
48
|
-
word 'analysis' , 'analyses'
|
49
|
-
|
50
|
-
# One-way singularization exception (convert plural to singular).
|
51
|
-
singular_word 'cactus', 'cacti'
|
52
|
-
|
53
|
-
# General rules.
|
54
|
-
rule 'hive' , 'hives'
|
55
|
-
rule 'rf' , 'rves'
|
56
|
-
rule 'af' , 'aves'
|
57
|
-
rule 'ero' , 'eroes'
|
58
|
-
rule 'man' , 'men'
|
59
|
-
rule 'ch' , 'ches'
|
60
|
-
rule 'sh' , 'shes'
|
61
|
-
rule 'ss' , 'sses'
|
62
|
-
rule 'ta' , 'tum'
|
63
|
-
rule 'ia' , 'ium'
|
64
|
-
rule 'ra' , 'rum'
|
65
|
-
rule 'ay' , 'ays'
|
66
|
-
rule 'ey' , 'eys'
|
67
|
-
rule 'oy' , 'oys'
|
68
|
-
rule 'uy' , 'uys'
|
69
|
-
rule 'y' , 'ies'
|
70
|
-
rule 'x' , 'xes'
|
71
|
-
rule 'lf' , 'lves'
|
72
|
-
rule 'us' , 'uses'
|
73
|
-
rule '' , 's'
|
74
|
-
|
75
|
-
# One-way singular rules.
|
76
|
-
singular_rule 'of' , 'ofs' # proof
|
77
|
-
singular_rule 'o' , 'oes' # hero, heroes
|
78
|
-
singular_rule 'f' , 'ves'
|
79
|
-
|
80
|
-
# One-way plural rules.
|
81
|
-
plural_rule 'fe' , 'ves' # safe, wife
|
82
|
-
plural_rule 's' , 'ses'
|
83
|
-
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module Waves
|
2
|
-
module Layers
|
3
|
-
module Inflect
|
4
|
-
module English
|
5
|
-
module StringMethods
|
6
|
-
|
7
|
-
def singular
|
8
|
-
English::Rules.singular(self)
|
9
|
-
end
|
10
|
-
|
11
|
-
alias_method(:singularize, :singular)
|
12
|
-
|
13
|
-
def plural
|
14
|
-
English::Rules.plural(self)
|
15
|
-
end
|
16
|
-
|
17
|
-
alias_method(:pluralize, :plural)
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
data/lib/layers/orm/filebase.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
module Waves
|
2
|
-
module Layers
|
3
|
-
module ORM
|
4
|
-
|
5
|
-
# Work in Progress
|
6
|
-
module Filebase
|
7
|
-
|
8
|
-
def self.included(app)
|
9
|
-
app.module_eval do
|
10
|
-
auto_eval( :Models ) do
|
11
|
-
auto_eval( true ) { include Filebase::Model[ :db / self.name.snake_case ] }
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
data/lib/layers/simple.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
module Waves
|
2
|
-
|
3
|
-
# Waves uses Layers to provide discrete, stackable, interchangeable bundles of functionality.
|
4
|
-
#
|
5
|
-
# Developers can make use of Layers by including them directly in a Waves application:
|
6
|
-
#
|
7
|
-
# module MyApp
|
8
|
-
# include SomeLayer
|
9
|
-
# end
|
10
|
-
module Layers
|
11
|
-
|
12
|
-
# Creates the Configurations namespace and establishes the standard autoload-or-autocreate
|
13
|
-
# rules.
|
14
|
-
module Simple
|
15
|
-
def self.included( app )
|
16
|
-
|
17
|
-
def app.config ; Waves.config ; end
|
18
|
-
def app.configurations ; self::Configurations ; end
|
19
|
-
|
20
|
-
app.instance_eval { include AutoCode }
|
21
|
-
|
22
|
-
app.auto_create_module( :Configurations ) do
|
23
|
-
include AutoCode
|
24
|
-
auto_create_class true, Waves::Configurations::Default
|
25
|
-
auto_load :Mapping, :directories => [:configurations]
|
26
|
-
auto_load true, :directories => [:configurations]
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
data/lib/layers/simple_errors.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
module Waves
|
2
|
-
module Layers
|
3
|
-
# Configures Waves for minimal exception handling.
|
4
|
-
#
|
5
|
-
# For example,
|
6
|
-
# a NotFoundError results in response status of 404, with body text
|
7
|
-
# of "404 Not Found".
|
8
|
-
module SimpleErrors
|
9
|
-
|
10
|
-
def self.included( app )
|
11
|
-
|
12
|
-
app.auto_eval :Configurations do
|
13
|
-
auto_eval :Mapping do
|
14
|
-
handle(Waves::Dispatchers::NotFoundError) do
|
15
|
-
response.status = 404; response.body = "404 Not Found"
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/lib/mapping/mapping.rb
DELETED
@@ -1,289 +0,0 @@
|
|
1
|
-
module Waves
|
2
|
-
|
3
|
-
# Mappings in Waves are the interface between the request dispatcher and your
|
4
|
-
# application code. The dispatcher matches each request against the mappings
|
5
|
-
# to determine a primary action and to collect sets of before, after, wrap,
|
6
|
-
# and always actions. The dispatcher also looks for an exception handler
|
7
|
-
# registered in the mappings when attempting a rescue.
|
8
|
-
#
|
9
|
-
# Each mapping associates a block with a set of constraints. Mappings can be
|
10
|
-
# one of several types:
|
11
|
-
#
|
12
|
-
# - action (the actual request processing and response)
|
13
|
-
# - handle (exception handling)
|
14
|
-
# - before
|
15
|
-
# - after
|
16
|
-
# - wrap (registers its block as both a before and after action)
|
17
|
-
# - always (like an "ensure" clause in a rescue)
|
18
|
-
#
|
19
|
-
# Actions are registered using path, url, or map. The other types may be
|
20
|
-
# registered using methods named after the type.
|
21
|
-
#
|
22
|
-
#
|
23
|
-
# The available constraints are:
|
24
|
-
#
|
25
|
-
# - a string or regexp that the path or url must match
|
26
|
-
# - parameters to match against the HTTP request headers and the Rack-specific variables (e.g. 'rack.url_scheme')
|
27
|
-
# - an additional hash reserved for settings not related to the Rack request (e.g. giving Rack handers special instructions for certain requests. See threaded? )
|
28
|
-
#
|
29
|
-
# The dispatcher evaluates mapping blocks in an instance of ResponseProxy,
|
30
|
-
# which provides access to foundational classes of a Waves application (i.e. controllers and views)
|
31
|
-
#
|
32
|
-
# == Examples
|
33
|
-
#
|
34
|
-
# resource = '([\w\-]+)'
|
35
|
-
# name = '([\w\-\_\.\+\@]+)'
|
36
|
-
#
|
37
|
-
# path %r{^/#{resource}/#{name}/?$} do |resource, name|
|
38
|
-
# "Hello from a #{resource} named #{name.capitalize}."
|
39
|
-
# end
|
40
|
-
#
|
41
|
-
# In this example, we are using binding regular expressions defined by +resource+
|
42
|
-
# and +name+. The matches are passed into the block as parameters. Thus, this
|
43
|
-
# rule, given the URL '/person/john' will return:
|
44
|
-
#
|
45
|
-
# Hello from a person named John.
|
46
|
-
#
|
47
|
-
# The given block may simple return a string. The content type is inferred from the request
|
48
|
-
# if possible, otherwise it defaults to +text+/+html+.
|
49
|
-
#
|
50
|
-
# path '/critters', :method => :post do
|
51
|
-
# request.content_type
|
52
|
-
# end
|
53
|
-
#
|
54
|
-
# /critters # => 'text/html'
|
55
|
-
#
|
56
|
-
# In this example, we match against a string and check to make sure that the request is a
|
57
|
-
# POST. If so, we return the request content_type. The request (and response) objects are
|
58
|
-
# available from within the block implicitly.
|
59
|
-
#
|
60
|
-
# = Invoking Controllers and Views
|
61
|
-
#
|
62
|
-
# You may invoke a controller or view method for the primary application by using the
|
63
|
-
# corresponding methods, preceded by the +use+ directive.
|
64
|
-
#
|
65
|
-
# == Examples
|
66
|
-
#
|
67
|
-
# path %r{^/#{resource}/#{name}/?$} do |resource, name|
|
68
|
-
# resource( resource ) do
|
69
|
-
# controller { find( name ) } | view { | instance | show( resource => instance ) }
|
70
|
-
# end
|
71
|
-
# end
|
72
|
-
#
|
73
|
-
# In this example, we take the same rule from above but invoke a controller and view method.
|
74
|
-
# We use the +resource+ directive and the resource parameter to set the MVC instances we're going
|
75
|
-
# to use. This is necessary to use the +controller+ or +view+ methods. Each of these take
|
76
|
-
# a block as arguments which are evaluated in the context of the instance. The +view+ method
|
77
|
-
# can further take an argument which is "piped" from the result of the controller block. This
|
78
|
-
# isn't required, but helps to clarify the request processing. Within a view block, a hash
|
79
|
-
# may also be passed in to the view method, which is converted into instance variables for the
|
80
|
-
# view instance. In this example, the +show+ method is assigned to an instance variable with the
|
81
|
-
# same name as the resource type.
|
82
|
-
#
|
83
|
-
# So given the same URL as above - /person/john - what will happen is the +find+ method for
|
84
|
-
# the +Person+ controller will be invoked and the result passed to the +Person+ view's +show+
|
85
|
-
# method, with +@person+ holding the value returned.
|
86
|
-
#
|
87
|
-
# Crucially, the controller does not need to know what variables the view depends on. This is
|
88
|
-
# the job of the mapping block, to act as the "glue" between the controller and view. The
|
89
|
-
# controller and view can thus be completely decoupled and become easier to reuse separately.
|
90
|
-
#
|
91
|
-
# url 'http://admin.foobar.com:/' do
|
92
|
-
# resource( :admin ) { view { console } }
|
93
|
-
# end
|
94
|
-
#
|
95
|
-
# In this example, we are using the +url+ method to map a subdomain of +foobar.com+ to the
|
96
|
-
# console method of the Admin view. In this case, we did not need a controller method, so
|
97
|
-
# we simply didn't call one.
|
98
|
-
#
|
99
|
-
# = Mapping Modules
|
100
|
-
#
|
101
|
-
# You may encapsulate sets of related rules into modules and simply include them into your
|
102
|
-
# mapping module. Some rule sets come packaged with Waves, such as PrettyUrls (rules for
|
103
|
-
# matching resources using names instead of ids). The simplest way to define such modules for
|
104
|
-
# reuse is by defining the +included+ class method for the rules module, and then define
|
105
|
-
# the rules using +module_eval+. See the PrettyUrls module for an example of how to do this.
|
106
|
-
#
|
107
|
-
# *Important:* Using pre-packaged mapping rules does not prevent you from adding to or
|
108
|
-
# overriding these rules. However, order does matter, so you should put your own rules
|
109
|
-
# ahead of those your may be importing. Also, place rules with constraints (for example,
|
110
|
-
# rules that require a POST) ahead of those with no constraints, otherwise the constrainted
|
111
|
-
# rules may never be called.
|
112
|
-
|
113
|
-
module Mapping
|
114
|
-
|
115
|
-
# If the pattern matches and constraints given by the options hash are satisfied, run the
|
116
|
-
# block before running any +path+ or +url+ actions. You can have as many +before+ matches
|
117
|
-
# as you want - they will all run, unless one of them calls redirect, generates an
|
118
|
-
# unhandled exception, etc.
|
119
|
-
def before( path, options = {}, &block )
|
120
|
-
if path.is_a? Hash
|
121
|
-
options = path
|
122
|
-
else
|
123
|
-
options[:path] = path
|
124
|
-
end
|
125
|
-
filters[:before] << [ options, block ]
|
126
|
-
end
|
127
|
-
|
128
|
-
# Similar to before, except it runs its actions after any matching +url+ or +path+ actions.
|
129
|
-
# Note that after methods will run even if an exception is thrown during processing.
|
130
|
-
def after( path, options = {}, &block )
|
131
|
-
if path.is_a? Hash
|
132
|
-
options = path
|
133
|
-
else
|
134
|
-
options[:path] = path
|
135
|
-
end
|
136
|
-
filters[:after] << [ options, block ]
|
137
|
-
end
|
138
|
-
|
139
|
-
# Run the action before and after the matching +url+ or +path+ action.
|
140
|
-
def wrap( path, options = {}, &block )
|
141
|
-
if path.is_a? Hash
|
142
|
-
options = path
|
143
|
-
else
|
144
|
-
options[:path] = path
|
145
|
-
end
|
146
|
-
filters[:before] << [ options, block ]
|
147
|
-
filters[:after] << [ options, block ]
|
148
|
-
end
|
149
|
-
|
150
|
-
# Like after, but will run even when an exception is thrown. Exceptions in
|
151
|
-
# always mappings are simply logged and ignored.
|
152
|
-
def always( path, options = {}, &block )
|
153
|
-
if path.is_a? Hash
|
154
|
-
options = path
|
155
|
-
else
|
156
|
-
options[:path] = path
|
157
|
-
end
|
158
|
-
filters[:always] << [ options, block ]
|
159
|
-
end
|
160
|
-
|
161
|
-
# Maps a request to a block. Don't use this method directly unless you know what
|
162
|
-
# you're doing. Use +path+ or +url+ instead.
|
163
|
-
def map( path, options = {}, params = {}, &block )
|
164
|
-
case path
|
165
|
-
when Hash
|
166
|
-
params = options; options = path
|
167
|
-
when String
|
168
|
-
options[:path] = path
|
169
|
-
end
|
170
|
-
mapping << [ options, params, block ]
|
171
|
-
end
|
172
|
-
|
173
|
-
# Match pattern against the +request.path+, along with satisfying any constraints
|
174
|
-
# specified by the options hash. If the pattern matches and the constraints are satisfied,
|
175
|
-
# run the block. Only one +path+ or +url+ match will be run (the first one).
|
176
|
-
def path( pat, options = {}, params = {}, &block )
|
177
|
-
options[:path] = pat; map( options, params, &block )
|
178
|
-
end
|
179
|
-
|
180
|
-
# Match pattern against the +request.url+, along with satisfying any constraints
|
181
|
-
# specified by the options hash. If the pattern matches and the constraints are satisfied,
|
182
|
-
# run the block. Only one +path+ or +url+ match will be run (the first one).
|
183
|
-
def url( pat, options = {}, params = {}, &block )
|
184
|
-
options[:url] = pat; map( options, params, &block )
|
185
|
-
end
|
186
|
-
|
187
|
-
# Maps the root of the application to a block. If an options hash is specified it must
|
188
|
-
# satisfy those constraints in order to run the block.
|
189
|
-
def root( options = {}, params = {}, &block )
|
190
|
-
path( %r{^/?$}, options, params, &block )
|
191
|
-
end
|
192
|
-
|
193
|
-
# Maps an exception handler to a block.
|
194
|
-
def handle(exception, options = {}, &block )
|
195
|
-
handlers << [exception,options, block]
|
196
|
-
end
|
197
|
-
|
198
|
-
# Maps a request to a block that will be executed within it's
|
199
|
-
# own thread. This is especially useful when you're running
|
200
|
-
# with an event driven server like thin or ebb, and this block
|
201
|
-
# is going to take a relatively long time.
|
202
|
-
def threaded( pat, options = {}, params = {}, &block)
|
203
|
-
params[:threaded] = true
|
204
|
-
map( pat, options, params, &block)
|
205
|
-
end
|
206
|
-
|
207
|
-
# Determines whether the request should be handled in a separate thread. This is used
|
208
|
-
# by event driven servers like thin and ebb, and is most useful for those methods that
|
209
|
-
# take a long time to complete, like for example upload processes. E.g.:
|
210
|
-
#
|
211
|
-
# threaded("/upload", :method => :post) do
|
212
|
-
# handle_upload
|
213
|
-
# end
|
214
|
-
#
|
215
|
-
# You typically wouldn't use this method directly.
|
216
|
-
def threaded?( request )
|
217
|
-
mapping.find do | options, params, function |
|
218
|
-
match = match( request, options, function )
|
219
|
-
return params[:threaded] == true if match
|
220
|
-
end
|
221
|
-
return false
|
222
|
-
end
|
223
|
-
|
224
|
-
# Match the given request against the defined rules. This is typically only called
|
225
|
-
# by a dispatcher object, so you shouldn't typically use it directly.
|
226
|
-
def []( request )
|
227
|
-
|
228
|
-
rx = { :before => [], :after => [], :always => [], :action => nil, :handlers => [] }
|
229
|
-
|
230
|
-
( filters[:before] + filters[:wrap] ).each do | options, function |
|
231
|
-
matches = match( request, options, function )
|
232
|
-
rx[:before] << matches if matches
|
233
|
-
end
|
234
|
-
|
235
|
-
mapping.find do | options, params, function |
|
236
|
-
rx[:action] = match( request, options, function )
|
237
|
-
break if rx[:action]
|
238
|
-
end
|
239
|
-
|
240
|
-
( filters[:after] + filters[:wrap] ).each do | options, function |
|
241
|
-
matches = match( request, options, function )
|
242
|
-
rx[:after] << matches if matches
|
243
|
-
end
|
244
|
-
|
245
|
-
filters[:always].each do | options, function |
|
246
|
-
matches = match( request, options, function )
|
247
|
-
rx[:always] << matches if matches
|
248
|
-
end
|
249
|
-
|
250
|
-
handlers.each do | exception, options, function |
|
251
|
-
matches = match( request, options, function )
|
252
|
-
rx[:handlers] << matches.unshift(exception) if matches
|
253
|
-
end
|
254
|
-
|
255
|
-
return rx
|
256
|
-
end
|
257
|
-
|
258
|
-
# Clear all mapping rules
|
259
|
-
def clear
|
260
|
-
@mapping = @filters = @handlers = nil;
|
261
|
-
end
|
262
|
-
|
263
|
-
private
|
264
|
-
|
265
|
-
def mapping; @mapping ||= []; end
|
266
|
-
|
267
|
-
def filters; @filters ||= { :before => [], :after => [], :wrap => [], :always => [] }; end
|
268
|
-
|
269
|
-
def handlers; @handlers ||= []; end
|
270
|
-
|
271
|
-
def match ( request, options, function )
|
272
|
-
return nil unless satisfy( request, options )
|
273
|
-
return [ function, nil ] if ( options[:path] == true or options[:url] == true )
|
274
|
-
matches = options[:path].match( request.path ) if options[:path]
|
275
|
-
matches = options[:url].match( request.url ) if options[:url]
|
276
|
-
return [ function, matches ? matches[1..-1] : nil ]
|
277
|
-
end
|
278
|
-
|
279
|
-
def satisfy( request, options )
|
280
|
-
options.nil? or options.all? do |name,wanted|
|
281
|
-
return true if wanted == true
|
282
|
-
got = request.send( name ) rescue request.env[ ( name =~ /^rack\./ ) ? name.to_s.downcase : name.to_s.upcase ]
|
283
|
-
( ( wanted.is_a?(Regexp) and wanted.match( got.to_s ) ) or got.to_s == wanted.to_s ) unless ( wanted.nil? or got.nil? )
|
284
|
-
end
|
285
|
-
end
|
286
|
-
end
|
287
|
-
|
288
|
-
|
289
|
-
end
|