thorero 0.9.4.4 → 0.9.4.5
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.
- data/LICENSE +1 -1
- data/README +21 -0
- data/Rakefile +275 -108
- data/TODO +0 -0
- data/bin/merb +12 -0
- data/bin/merb-specs +5 -0
- data/docs/bootloading.dox +58 -0
- data/docs/documentation_standards +40 -0
- 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 +51 -0
- data/lib/merb-core.rb +603 -0
- data/lib/merb-core/autoload.rb +32 -0
- data/lib/merb-core/bootloader.rb +708 -0
- data/lib/merb-core/config.rb +303 -0
- data/lib/merb-core/constants.rb +43 -0
- data/lib/merb-core/controller/abstract_controller.rb +578 -0
- data/lib/merb-core/controller/exceptions.rb +302 -0
- data/lib/merb-core/controller/merb_controller.rb +256 -0
- data/lib/merb-core/controller/mime.rb +106 -0
- data/lib/merb-core/controller/mixins/authentication.rb +87 -0
- data/lib/merb-core/controller/mixins/controller.rb +290 -0
- data/lib/merb-core/controller/mixins/render.rb +481 -0
- data/lib/merb-core/controller/mixins/responder.rb +472 -0
- data/lib/merb-core/controller/template.rb +254 -0
- data/lib/merb-core/core_ext.rb +8 -0
- data/lib/merb-core/core_ext/kernel.rb +319 -0
- data/lib/merb-core/dispatch/cookies.rb +91 -0
- data/lib/merb-core/dispatch/dispatcher.rb +278 -0
- data/lib/merb-core/dispatch/exceptions.html.erb +303 -0
- data/lib/merb-core/dispatch/request.rb +603 -0
- data/lib/merb-core/dispatch/router.rb +179 -0
- data/lib/merb-core/dispatch/router/behavior.rb +867 -0
- data/lib/merb-core/dispatch/router/cached_proc.rb +52 -0
- data/lib/merb-core/dispatch/router/route.rb +321 -0
- data/lib/merb-core/dispatch/session.rb +78 -0
- data/lib/merb-core/dispatch/session/cookie.rb +168 -0
- data/lib/merb-core/dispatch/session/memcached.rb +184 -0
- data/lib/merb-core/dispatch/session/memory.rb +241 -0
- data/lib/merb-core/dispatch/worker.rb +28 -0
- data/lib/merb-core/gem_ext/erubis.rb +77 -0
- data/lib/{extlib → merb-core}/logger.rb +2 -2
- data/lib/merb-core/plugins.rb +59 -0
- data/lib/merb-core/rack.rb +21 -0
- data/lib/merb-core/rack/adapter.rb +44 -0
- data/lib/merb-core/rack/adapter/ebb.rb +25 -0
- data/lib/merb-core/rack/adapter/evented_mongrel.rb +26 -0
- data/lib/merb-core/rack/adapter/fcgi.rb +17 -0
- data/lib/merb-core/rack/adapter/irb.rb +118 -0
- data/lib/merb-core/rack/adapter/mongrel.rb +26 -0
- data/lib/merb-core/rack/adapter/runner.rb +28 -0
- data/lib/merb-core/rack/adapter/swiftiplied_mongrel.rb +26 -0
- data/lib/merb-core/rack/adapter/thin.rb +39 -0
- data/lib/merb-core/rack/adapter/thin_turbo.rb +24 -0
- data/lib/merb-core/rack/adapter/webrick.rb +36 -0
- data/lib/merb-core/rack/application.rb +18 -0
- data/lib/merb-core/rack/handler/mongrel.rb +97 -0
- data/lib/merb-core/rack/middleware.rb +26 -0
- data/lib/merb-core/rack/middleware/path_prefix.rb +31 -0
- data/lib/merb-core/rack/middleware/profiler.rb +19 -0
- data/lib/merb-core/rack/middleware/static.rb +45 -0
- data/lib/merb-core/server.rb +252 -0
- data/lib/merb-core/tasks/audit.rake +68 -0
- data/lib/merb-core/tasks/merb.rb +1 -0
- data/lib/merb-core/tasks/merb_rake_helper.rb +12 -0
- data/lib/merb-core/test.rb +11 -0
- data/lib/merb-core/test/helpers.rb +9 -0
- data/lib/merb-core/test/helpers/controller_helper.rb +8 -0
- data/lib/merb-core/test/helpers/multipart_request_helper.rb +175 -0
- data/lib/merb-core/test/helpers/request_helper.rb +344 -0
- data/lib/merb-core/test/helpers/route_helper.rb +33 -0
- data/lib/merb-core/test/helpers/view_helper.rb +121 -0
- data/lib/merb-core/test/matchers.rb +9 -0
- data/lib/merb-core/test/matchers/controller_matchers.rb +319 -0
- data/lib/merb-core/test/matchers/route_matchers.rb +136 -0
- data/lib/merb-core/test/matchers/view_matchers.rb +335 -0
- data/lib/merb-core/test/run_specs.rb +47 -0
- data/lib/merb-core/test/tasks/spectasks.rb +68 -0
- data/lib/merb-core/test/test_ext/hpricot.rb +32 -0
- data/lib/merb-core/test/test_ext/object.rb +14 -0
- data/lib/merb-core/test/test_ext/string.rb +14 -0
- data/lib/merb-core/vendor/facets.rb +2 -0
- data/lib/merb-core/vendor/facets/dictionary.rb +433 -0
- data/lib/merb-core/vendor/facets/inflect.rb +345 -0
- data/lib/merb-core/version.rb +11 -0
- data/spec/private/config/adapter_spec.rb +32 -0
- data/spec/private/config/config_spec.rb +202 -0
- data/spec/private/config/environment_spec.rb +13 -0
- data/spec/private/config/spec_helper.rb +1 -0
- data/spec/private/core_ext/kernel_spec.rb +169 -0
- data/spec/private/dispatch/bootloader_spec.rb +24 -0
- data/spec/private/dispatch/cookies_spec.rb +107 -0
- data/spec/private/dispatch/dispatch_spec.rb +35 -0
- data/spec/private/dispatch/fixture/app/controllers/application.rb +4 -0
- data/spec/private/dispatch/fixture/app/controllers/exceptions.rb +27 -0
- data/spec/private/dispatch/fixture/app/controllers/foo.rb +21 -0
- data/spec/private/dispatch/fixture/app/helpers/global_helpers.rb +8 -0
- data/spec/private/dispatch/fixture/app/views/exeptions/client_error.html.erb +37 -0
- data/spec/private/dispatch/fixture/app/views/exeptions/internal_server_error.html.erb +216 -0
- data/spec/private/dispatch/fixture/app/views/exeptions/not_acceptable.html.erb +38 -0
- data/spec/private/dispatch/fixture/app/views/exeptions/not_found.html.erb +40 -0
- data/spec/private/dispatch/fixture/app/views/foo/bar.html.erb +0 -0
- data/spec/private/dispatch/fixture/app/views/layout/application.html.erb +11 -0
- data/spec/private/dispatch/fixture/config/black_hole.rb +12 -0
- data/spec/private/dispatch/fixture/config/environments/development.rb +6 -0
- data/spec/private/dispatch/fixture/config/environments/production.rb +5 -0
- data/spec/private/dispatch/fixture/config/environments/test.rb +6 -0
- data/spec/private/dispatch/fixture/config/init.rb +45 -0
- data/spec/private/dispatch/fixture/config/rack.rb +11 -0
- data/spec/private/dispatch/fixture/config/router.rb +35 -0
- data/spec/private/dispatch/fixture/log/merb_test.log +1874 -0
- data/spec/private/dispatch/fixture/public/images/merb.jpg +0 -0
- data/spec/private/dispatch/fixture/public/merb.fcgi +4 -0
- data/spec/private/dispatch/fixture/public/stylesheets/master.css +119 -0
- data/spec/private/dispatch/route_params_spec.rb +24 -0
- data/spec/private/dispatch/session_mixin_spec.rb +47 -0
- data/spec/private/dispatch/spec_helper.rb +1 -0
- data/spec/private/plugins/plugin_spec.rb +166 -0
- data/spec/private/rack/application_spec.rb +49 -0
- data/spec/private/router/behavior_spec.rb +60 -0
- data/spec/private/router/fixture/log/merb_test.log +139 -0
- data/spec/private/router/route_spec.rb +414 -0
- data/spec/private/router/router_spec.rb +175 -0
- data/spec/private/vendor/facets/plural_spec.rb +564 -0
- data/spec/private/vendor/facets/singular_spec.rb +489 -0
- data/spec/public/DEFINITIONS +11 -0
- data/spec/public/abstract_controller/controllers/alt_views/layout/application.erb +1 -0
- data/spec/public/abstract_controller/controllers/alt_views/layout/merb/test/fixtures/abstract/render_string_controller_layout.erb +1 -0
- data/spec/public/abstract_controller/controllers/alt_views/layout/merb/test/fixtures/abstract/render_template_controller_layout.erb +1 -0
- data/spec/public/abstract_controller/controllers/alt_views/merb/test/fixtures/abstract/display_object_with_multiple_roots/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/alt_views/merb/test/fixtures/abstract/display_object_with_multiple_roots/show.erb +1 -0
- data/spec/public/abstract_controller/controllers/alt_views/merb/test/fixtures/abstract/render_template_multiple_roots/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/alt_views/partial/basic_partial_with_multiple_roots/_partial.erb +1 -0
- data/spec/public/abstract_controller/controllers/alt_views/render_template_multiple_roots_and_custom_location/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/alt_views/render_template_multiple_roots_inherited/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/cousins.rb +41 -0
- data/spec/public/abstract_controller/controllers/display.rb +54 -0
- data/spec/public/abstract_controller/controllers/filters.rb +193 -0
- data/spec/public/abstract_controller/controllers/helpers.rb +41 -0
- data/spec/public/abstract_controller/controllers/partial.rb +121 -0
- data/spec/public/abstract_controller/controllers/render.rb +113 -0
- data/spec/public/abstract_controller/controllers/views/helpers/capture/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/helpers/capture_eq/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/helpers/capture_with_args/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/helpers/concat/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/layout/alt.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/layout/custom.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/display_object/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/display_object_with_action/new.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template/index.erb +1 -0
- 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 +1 -0
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template_multiple_roots/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template_multiple_roots/show.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_two_throw_contents/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/another_directory/_partial.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/basic_partial/_partial.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/basic_partial/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/basic_partial_with_multiple_roots/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/nested_partial/_first.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/nested_partial/_second.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/nested_partial/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_in_another_directory/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_both/_collection.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_both/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections/_collection.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_as/_collection.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_as/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_counter/_collection.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_counter/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_locals/_variables.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_locals/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_with_and_locals/_both.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_with_and_locals/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/with_absolute_partial/_partial.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/with_absolute_partial/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/with_as_partial/_with_partial.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/with_as_partial/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/with_nil_partial/_with_partial.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/with_nil_partial/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/with_partial/_with_partial.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/partial/with_partial/index.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/test_display/foo.html.erb +1 -0
- data/spec/public/abstract_controller/controllers/views/test_render/foo.html.erb +0 -0
- data/spec/public/abstract_controller/controllers/views/wonderful/index.erb +1 -0
- data/spec/public/abstract_controller/display_spec.rb +33 -0
- data/spec/public/abstract_controller/filter_spec.rb +106 -0
- data/spec/public/abstract_controller/helper_spec.rb +21 -0
- data/spec/public/abstract_controller/partial_spec.rb +61 -0
- data/spec/public/abstract_controller/render_spec.rb +90 -0
- data/spec/public/abstract_controller/spec_helper.rb +31 -0
- data/spec/public/boot_loader/boot_loader_spec.rb +33 -0
- data/spec/public/boot_loader/spec_helper.rb +1 -0
- data/spec/public/controller/authentication_spec.rb +103 -0
- data/spec/public/controller/base_spec.rb +36 -0
- data/spec/public/controller/controllers/authentication.rb +45 -0
- data/spec/public/controller/controllers/base.rb +36 -0
- data/spec/public/controller/controllers/display.rb +118 -0
- data/spec/public/controller/controllers/redirect.rb +30 -0
- data/spec/public/controller/controllers/responder.rb +93 -0
- data/spec/public/controller/controllers/url.rb +7 -0
- data/spec/public/controller/controllers/views/layout/custom.html.erb +1 -0
- data/spec/public/controller/controllers/views/layout/custom_arg.html.erb +1 -0
- data/spec/public/controller/controllers/views/layout/custom_arg.json.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_and_local_provides/index.html.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_and_local_provides/index.xml.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_provides/index.html.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_provides/index.xml.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/display_with_template/index.html.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/display_with_template/no_layout.html.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/display_with_template_argument/index.html.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/html_default/index.html.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/layout/custom.html.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/local_provides/index.html.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/local_provides/index.xml.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/multi_provides/index.html.erb +1 -0
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/multi_provides/index.js.erb +1 -0
- data/spec/public/controller/display_spec.rb +84 -0
- data/spec/public/controller/redirect_spec.rb +27 -0
- data/spec/public/controller/responder_spec.rb +163 -0
- data/spec/public/controller/spec_helper.rb +11 -0
- data/spec/public/controller/url_spec.rb +180 -0
- data/spec/public/core/merb_core_spec.rb +45 -0
- data/spec/public/core_ext/class_spec.rb +91 -0
- data/spec/public/core_ext/fixtures/core_ext_dependency.rb +2 -0
- data/spec/public/core_ext/kernel_spec.rb +9 -0
- data/spec/public/core_ext/spec_helper.rb +1 -0
- data/spec/public/directory_structure/directory/app/controllers/application.rb +3 -0
- data/spec/public/directory_structure/directory/app/controllers/base.rb +13 -0
- data/spec/public/directory_structure/directory/app/controllers/custom.rb +19 -0
- data/spec/public/directory_structure/directory/app/views/base/template.html.erb +1 -0
- data/spec/public/directory_structure/directory/app/views/wonderful/template.erb +1 -0
- data/spec/public/directory_structure/directory/config/router.rb +3 -0
- data/spec/public/directory_structure/directory/log/merb_test.log +562 -0
- data/spec/public/directory_structure/directory_spec.rb +44 -0
- data/spec/public/logger/logger_spec.rb +181 -0
- data/spec/public/logger/spec_helper.rb +1 -0
- data/spec/public/reloading/directory/app/controllers/application.rb +3 -0
- data/spec/public/reloading/directory/app/controllers/reload.rb +6 -0
- data/spec/public/reloading/directory/config/init.rb +2 -0
- data/spec/public/reloading/directory/log/merb_test.log +138 -0
- data/spec/public/reloading/reload_spec.rb +103 -0
- data/spec/public/request/multipart_spec.rb +41 -0
- data/spec/public/request/request_spec.rb +228 -0
- data/spec/public/router/default_spec.rb +21 -0
- data/spec/public/router/deferred_spec.rb +22 -0
- data/spec/public/router/fixation_spec.rb +27 -0
- data/spec/public/router/fixture/log/merb_test.log +1556 -0
- data/spec/public/router/namespace_spec.rb +113 -0
- data/spec/public/router/nested_matches_spec.rb +97 -0
- data/spec/public/router/nested_resources_spec.rb +41 -0
- data/spec/public/router/resource_spec.rb +37 -0
- data/spec/public/router/resources_spec.rb +82 -0
- data/spec/public/router/spec_helper.rb +90 -0
- data/spec/public/router/special_spec.rb +61 -0
- data/spec/public/router/string_spec.rb +61 -0
- data/spec/public/template/template_spec.rb +104 -0
- data/spec/public/template/templates/error.html.erb +2 -0
- data/spec/public/template/templates/template.html.erb +1 -0
- data/spec/public/template/templates/template.html.myt +1 -0
- data/spec/public/test/controller_matchers_spec.rb +402 -0
- data/spec/public/test/controllers/controller_assertion_mock.rb +7 -0
- data/spec/public/test/controllers/dispatch_controller.rb +11 -0
- data/spec/public/test/controllers/spec_helper_controller.rb +38 -0
- data/spec/public/test/multipart_request_helper_spec.rb +159 -0
- data/spec/public/test/multipart_upload_text_file.txt +1 -0
- data/spec/public/test/request_helper_spec.rb +221 -0
- data/spec/public/test/route_helper_spec.rb +71 -0
- data/spec/public/test/route_matchers_spec.rb +162 -0
- data/spec/public/test/view_helper_spec.rb +96 -0
- data/spec/public/test/view_matchers_spec.rb +183 -0
- data/spec/spec_helper.rb +68 -0
- metadata +493 -41
- data/README.txt +0 -3
- data/lib/extlib.rb +0 -32
- data/lib/extlib/assertions.rb +0 -8
- data/lib/extlib/blank.rb +0 -42
- data/lib/extlib/class.rb +0 -175
- data/lib/extlib/hash.rb +0 -410
- data/lib/extlib/hook.rb +0 -366
- data/lib/extlib/inflection.rb +0 -141
- data/lib/extlib/lazy_array.rb +0 -106
- data/lib/extlib/mash.rb +0 -143
- data/lib/extlib/module.rb +0 -37
- data/lib/extlib/object.rb +0 -165
- data/lib/extlib/object_space.rb +0 -13
- data/lib/extlib/pathname.rb +0 -5
- data/lib/extlib/pooling.rb +0 -233
- data/lib/extlib/rubygems.rb +0 -38
- data/lib/extlib/simple_set.rb +0 -39
- data/lib/extlib/string.rb +0 -132
- data/lib/extlib/struct.rb +0 -8
- data/lib/extlib/tasks/release.rb +0 -9
- data/lib/extlib/time.rb +0 -12
- data/lib/extlib/version.rb +0 -3
- data/lib/extlib/virtual_file.rb +0 -10
data/lib/extlib/object_space.rb
DELETED
data/lib/extlib/pathname.rb
DELETED
data/lib/extlib/pooling.rb
DELETED
@@ -1,233 +0,0 @@
|
|
1
|
-
require 'set'
|
2
|
-
require 'thread'
|
3
|
-
|
4
|
-
module Extlib
|
5
|
-
# ==== Notes
|
6
|
-
# Provides pooling support to class it got included in.
|
7
|
-
#
|
8
|
-
# Pooling of objects is a faster way of aquiring instances
|
9
|
-
# of objects compared to regular allocation and initialization
|
10
|
-
# because instances are keeped in memory reused.
|
11
|
-
#
|
12
|
-
# Classes that include Pooling module have re-defined new
|
13
|
-
# method that returns instances acquired from pool.
|
14
|
-
#
|
15
|
-
# Term resource is used for any type of poolable objects
|
16
|
-
# and should NOT be thought as DataMapper Resource or
|
17
|
-
# ActiveResource resource and such.
|
18
|
-
#
|
19
|
-
# In Data Objects connections are pooled so that it is
|
20
|
-
# unnecessary to allocate and initialize connection object
|
21
|
-
# each time connection is needed, like per request in a
|
22
|
-
# web application.
|
23
|
-
#
|
24
|
-
# Pool obviously has to be thread safe because state of
|
25
|
-
# object is reset when it is released.
|
26
|
-
module Pooling
|
27
|
-
|
28
|
-
def self.scavenger
|
29
|
-
@scavenger || begin
|
30
|
-
@scavenger = Thread.new do
|
31
|
-
loop do
|
32
|
-
lock.synchronize do
|
33
|
-
pools.each do |pool|
|
34
|
-
# This is a useful check, but non-essential, and right now it breaks lots of stuff.
|
35
|
-
# if pool.expired?
|
36
|
-
pool.lock.synchronize do
|
37
|
-
if pool.reserved_count == 0
|
38
|
-
pool.dispose
|
39
|
-
end
|
40
|
-
end
|
41
|
-
# end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
sleep(scavenger_interval)
|
45
|
-
end # loop
|
46
|
-
end
|
47
|
-
|
48
|
-
@scavenger.priority = -10
|
49
|
-
@scavenger
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def self.pools
|
54
|
-
@pools ||= Set.new
|
55
|
-
end
|
56
|
-
|
57
|
-
def self.append_pool(pool)
|
58
|
-
lock.synchronize do
|
59
|
-
pools << pool
|
60
|
-
end
|
61
|
-
Extlib::Pooling::scavenger
|
62
|
-
end
|
63
|
-
|
64
|
-
def self.lock
|
65
|
-
@lock ||= Mutex.new
|
66
|
-
end
|
67
|
-
|
68
|
-
class CrossPoolError < StandardError
|
69
|
-
end
|
70
|
-
|
71
|
-
class OrphanedObjectError < StandardError
|
72
|
-
end
|
73
|
-
|
74
|
-
class ThreadStopError < StandardError
|
75
|
-
end
|
76
|
-
|
77
|
-
def self.included(target)
|
78
|
-
target.class_eval do
|
79
|
-
class << self
|
80
|
-
alias __new new
|
81
|
-
end
|
82
|
-
|
83
|
-
@__pools = Hash.new { |h,k| __pool_lock.synchronize { h[k] = Pool.new(target.pool_size, target, k) } }
|
84
|
-
@__pool_lock = Mutex.new
|
85
|
-
|
86
|
-
def self.__pool_lock
|
87
|
-
@__pool_lock
|
88
|
-
end
|
89
|
-
|
90
|
-
def self.new(*args)
|
91
|
-
@__pools[args].new
|
92
|
-
end
|
93
|
-
|
94
|
-
def self.__pools
|
95
|
-
@__pools
|
96
|
-
end
|
97
|
-
|
98
|
-
def self.pool_size
|
99
|
-
8
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
def release
|
105
|
-
@__pool.release(self) unless @__pool.nil?
|
106
|
-
end
|
107
|
-
|
108
|
-
class Pool
|
109
|
-
def initialize(max_size, resource, args)
|
110
|
-
raise ArgumentError.new("+max_size+ should be a Fixnum but was #{max_size.inspect}") unless Fixnum === max_size
|
111
|
-
raise ArgumentError.new("+resource+ should be a Class but was #{resource.inspect}") unless Class === resource
|
112
|
-
|
113
|
-
@max_size = max_size
|
114
|
-
@resource = resource
|
115
|
-
@args = args
|
116
|
-
|
117
|
-
@available = []
|
118
|
-
@reserved_count = 0
|
119
|
-
end
|
120
|
-
|
121
|
-
def lock
|
122
|
-
@resource.__pool_lock
|
123
|
-
end
|
124
|
-
|
125
|
-
def scavenge_interval
|
126
|
-
@resource.scavenge_interval
|
127
|
-
end
|
128
|
-
|
129
|
-
def new
|
130
|
-
instance = nil
|
131
|
-
|
132
|
-
lock.synchronize do
|
133
|
-
instance = acquire
|
134
|
-
end
|
135
|
-
|
136
|
-
Extlib::Pooling::append_pool(self)
|
137
|
-
|
138
|
-
if instance.nil?
|
139
|
-
# Account for the current thread, and the pool scavenger.
|
140
|
-
if ThreadGroup::Default.list.size == 2 && @reserved_count >= @max_size
|
141
|
-
raise ThreadStopError.new(size)
|
142
|
-
else
|
143
|
-
sleep(0.05)
|
144
|
-
new
|
145
|
-
end
|
146
|
-
else
|
147
|
-
instance
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
def release(instance)
|
152
|
-
lock.synchronize do
|
153
|
-
instance.instance_variable_set(:@__pool, nil)
|
154
|
-
@reserved_count -= 1
|
155
|
-
@available.push(instance)
|
156
|
-
end
|
157
|
-
nil
|
158
|
-
end
|
159
|
-
|
160
|
-
def delete(instance)
|
161
|
-
lock.synchronize do
|
162
|
-
instance.instance_variable_set(:@__pool, nil)
|
163
|
-
@reserved_count -= 1
|
164
|
-
end
|
165
|
-
nil
|
166
|
-
end
|
167
|
-
|
168
|
-
def size
|
169
|
-
@available.size + @reserved_count
|
170
|
-
end
|
171
|
-
alias length size
|
172
|
-
|
173
|
-
def inspect
|
174
|
-
"#<Extlib::Pooling::Pool<#{@resource.name}> available=#{@available.size} reserved_count=#{@reserved_count}>"
|
175
|
-
end
|
176
|
-
|
177
|
-
def flush!
|
178
|
-
@available.pop.dispose until @available.empty?
|
179
|
-
end
|
180
|
-
|
181
|
-
def dispose
|
182
|
-
flush!
|
183
|
-
@resource.__pools.delete(@args)
|
184
|
-
!Extlib::Pooling::pools.delete?(self).nil?
|
185
|
-
end
|
186
|
-
|
187
|
-
# Disabled temporarily.
|
188
|
-
#
|
189
|
-
# def expired?
|
190
|
-
# lock.synchronize do
|
191
|
-
# @available.each do |instance|
|
192
|
-
# if instance.instance_variable_get(:@__allocated_in_pool) + scavenge_interval < Time.now
|
193
|
-
# instance.dispose
|
194
|
-
# @available.delete(instance)
|
195
|
-
# end
|
196
|
-
# end
|
197
|
-
#
|
198
|
-
# size == 0
|
199
|
-
# end
|
200
|
-
# end
|
201
|
-
|
202
|
-
def reserved_count
|
203
|
-
@reserved_count
|
204
|
-
end
|
205
|
-
|
206
|
-
private
|
207
|
-
|
208
|
-
def acquire
|
209
|
-
instance = if !@available.empty?
|
210
|
-
@available.pop
|
211
|
-
elsif size < @max_size
|
212
|
-
@resource.__new(*@args)
|
213
|
-
else
|
214
|
-
nil
|
215
|
-
end
|
216
|
-
|
217
|
-
if instance.nil?
|
218
|
-
instance
|
219
|
-
else
|
220
|
-
raise CrossPoolError.new(instance) if instance.instance_variable_get(:@__pool)
|
221
|
-
@reserved_count += 1
|
222
|
-
instance.instance_variable_set(:@__pool, self)
|
223
|
-
instance.instance_variable_set(:@__allocated_in_pool, Time.now)
|
224
|
-
instance
|
225
|
-
end
|
226
|
-
end
|
227
|
-
end
|
228
|
-
|
229
|
-
def self.scavenger_interval
|
230
|
-
60
|
231
|
-
end
|
232
|
-
end # module Pooling
|
233
|
-
end # module Extlib
|
data/lib/extlib/rubygems.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
# this is a temporary workaround until rubygems Does the Right thing here
|
2
|
-
require 'rubygems'
|
3
|
-
module Gem
|
4
|
-
class SourceIndex
|
5
|
-
|
6
|
-
# This is resolved in 1.1
|
7
|
-
if Version.new(RubyGemsVersion) < Version.new("1.1")
|
8
|
-
|
9
|
-
# Overwrite this so that a gem of the same name and version won't push one
|
10
|
-
# from the gems directory out entirely.
|
11
|
-
#
|
12
|
-
# @param gem_spec<Gem::Specification> The specification of the gem to add.
|
13
|
-
def add_spec(gem_spec)
|
14
|
-
unless gem_spec.instance_variable_get("@loaded_from") &&
|
15
|
-
@gems[gem_spec.full_name].is_a?(Gem::Specification) &&
|
16
|
-
@gems[gem_spec.full_name].installation_path ==
|
17
|
-
File.join(defined?(Merb) && Merb.respond_to?(:root) ? Merb.root : Dir.pwd,"gems")
|
18
|
-
|
19
|
-
@gems[gem_spec.full_name] = gem_spec
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
class Specification
|
28
|
-
|
29
|
-
# Overwrite this so that gems in the gems directory get preferred over gems
|
30
|
-
# from any other location. If there are two gems of different versions in
|
31
|
-
# the gems directory, the later one will load as usual.
|
32
|
-
#
|
33
|
-
# @return <Array[Array]> The object used for sorting gem specs.
|
34
|
-
def sort_obj
|
35
|
-
[@name, installation_path == File.join(defined?(Merb) && Merb.respond_to?(:root) ? Merb.root : Dir.pwd,"gems") ? 1 : -1, @version.to_ints, @new_platform == Gem::Platform::RUBY ? -1 : 1]
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
data/lib/extlib/simple_set.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
module Extlib
|
2
|
-
# Simple set implementation
|
3
|
-
# on top of Hash with merging support.
|
4
|
-
#
|
5
|
-
# In particular this is used to store
|
6
|
-
# a set of callable actions of controller.
|
7
|
-
class SimpleSet < Hash
|
8
|
-
|
9
|
-
# @param arr<Array> Initial set values.
|
10
|
-
#
|
11
|
-
# @return <Array> The array the Set was initialized with
|
12
|
-
def initialize(arr = [])
|
13
|
-
arr.each {|x| self[x] = true}
|
14
|
-
end
|
15
|
-
|
16
|
-
# @param value<Object> Value to add to set.
|
17
|
-
#
|
18
|
-
# @return <TrueClass>
|
19
|
-
def <<(value)
|
20
|
-
self[value] = true
|
21
|
-
end
|
22
|
-
|
23
|
-
# @param arr<Array> Values to merge with set.
|
24
|
-
#
|
25
|
-
# @return <SimpleSet> The set after the Array was merged in.
|
26
|
-
def merge(arr)
|
27
|
-
super(arr.inject({}) {|s,x| s[x] = true; s })
|
28
|
-
end
|
29
|
-
|
30
|
-
# @return <String> A human readable version of the set.
|
31
|
-
def inspect
|
32
|
-
"#<SimpleSet: {#{keys.map {|x| x.inspect}.join(", ")}}>"
|
33
|
-
end
|
34
|
-
|
35
|
-
# def to_a
|
36
|
-
alias_method :to_a, :keys
|
37
|
-
|
38
|
-
end # SimpleSet
|
39
|
-
end # Merb
|
data/lib/extlib/string.rb
DELETED
@@ -1,132 +0,0 @@
|
|
1
|
-
require "pathname"
|
2
|
-
|
3
|
-
class String
|
4
|
-
##
|
5
|
-
# @return <String> The string with all regexp special characters escaped.
|
6
|
-
#
|
7
|
-
# @example
|
8
|
-
# "*?{}.".escape_regexp #=> "\\*\\?\\{\\}\\."
|
9
|
-
def escape_regexp
|
10
|
-
Regexp.escape self
|
11
|
-
end
|
12
|
-
|
13
|
-
##
|
14
|
-
# @return String The string with all regexp special characters unescaped.
|
15
|
-
#
|
16
|
-
# @example
|
17
|
-
# "\\*\\?\\{\\}\\.".unescape_regexp #=> "*?{}."
|
18
|
-
def unescape_regexp
|
19
|
-
self.gsub(/\\([\.\?\|\(\)\[\]\{\}\^\$\*\+\-])/, '\1')
|
20
|
-
end
|
21
|
-
|
22
|
-
##
|
23
|
-
# @return <String> The string converted to snake case.
|
24
|
-
#
|
25
|
-
# @example
|
26
|
-
# "FooBar".snake_case #=> "foo_bar"
|
27
|
-
# @example
|
28
|
-
# "HeadlineCNNNews".snake_case #=> "headline_cnn_news"
|
29
|
-
# @example
|
30
|
-
# "CNN".snake_case #=> "cnn"
|
31
|
-
def snake_case
|
32
|
-
return self.downcase if self =~ /^[A-Z]+$/
|
33
|
-
self.gsub(/([A-Z]+)(?=[A-Z][a-z]?)|\B[A-Z]/, '_\&') =~ /_*(.*)/
|
34
|
-
return $+.downcase
|
35
|
-
end
|
36
|
-
|
37
|
-
##
|
38
|
-
# @return <String> The string converted to camel case.
|
39
|
-
#
|
40
|
-
# @example
|
41
|
-
# "foo_bar".camel_case #=> "FooBar"
|
42
|
-
def camel_case
|
43
|
-
return self if self !~ /_/ && self =~ /[A-Z]+.*/
|
44
|
-
split('_').map{|e| e.capitalize}.join
|
45
|
-
end
|
46
|
-
|
47
|
-
##
|
48
|
-
# @return <String> The path string converted to a constant name.
|
49
|
-
#
|
50
|
-
# @example
|
51
|
-
# "merb/core_ext/string".to_const_string #=> "Merb::CoreExt::String"
|
52
|
-
def to_const_string
|
53
|
-
gsub(/\/(.?)/) { "::#{$1.upcase}" }.gsub(/(?:^|_)(.)/) { $1.upcase }
|
54
|
-
end
|
55
|
-
|
56
|
-
##
|
57
|
-
# @return <String>
|
58
|
-
# The path that is associated with the constantized string, assuming a
|
59
|
-
# conventional structure.
|
60
|
-
#
|
61
|
-
# @example
|
62
|
-
# "FooBar::Baz".to_const_path # => "foo_bar/baz"
|
63
|
-
def to_const_path
|
64
|
-
snake_case.gsub(/::/, "/")
|
65
|
-
end
|
66
|
-
|
67
|
-
##
|
68
|
-
# @param o<String> The path component to join with the string.
|
69
|
-
#
|
70
|
-
# @return <String> The original path concatenated with o.
|
71
|
-
#
|
72
|
-
# @example
|
73
|
-
# "merb"/"core_ext" #=> "merb/core_ext"
|
74
|
-
def /(o)
|
75
|
-
File.join(self, o.to_s)
|
76
|
-
end
|
77
|
-
|
78
|
-
##
|
79
|
-
# @param other<String> Base path to calculate against
|
80
|
-
#
|
81
|
-
# @return <String> Relative path from between the two
|
82
|
-
#
|
83
|
-
# @example
|
84
|
-
# "/opt/local/lib".relative_path_from("/opt/local/lib/ruby/site_ruby") # => "../.."
|
85
|
-
def relative_path_from(other)
|
86
|
-
Pathname.new(self).relative_path_from(Pathname.new(other)).to_s
|
87
|
-
end
|
88
|
-
|
89
|
-
# Overwrite this method to provide your own translations.
|
90
|
-
def self.translate(value)
|
91
|
-
translations[value] || value
|
92
|
-
end
|
93
|
-
|
94
|
-
def self.translations
|
95
|
-
@translations ||= {}
|
96
|
-
end
|
97
|
-
|
98
|
-
# Matches any whitespace (including newline) and replaces with a single space
|
99
|
-
#
|
100
|
-
# @example
|
101
|
-
# <<QUERY.compress_lines
|
102
|
-
# SELECT name
|
103
|
-
# FROM users
|
104
|
-
# QUERY
|
105
|
-
# => "SELECT name FROM users"
|
106
|
-
def compress_lines(spaced = true)
|
107
|
-
split($/).map { |line| line.strip }.join(spaced ? ' ' : '')
|
108
|
-
end
|
109
|
-
|
110
|
-
# Useful for heredocs - removes whitespace margin.
|
111
|
-
def margin(indicator = nil)
|
112
|
-
lines = self.dup.split($/)
|
113
|
-
|
114
|
-
min_margin = 0
|
115
|
-
lines.each do |line|
|
116
|
-
if line =~ /^(\s+)/ && (min_margin == 0 || $1.size < min_margin)
|
117
|
-
min_margin = $1.size
|
118
|
-
end
|
119
|
-
end
|
120
|
-
lines.map { |line| line.sub(/^\s{#{min_margin}}/, '') }.join($/)
|
121
|
-
end
|
122
|
-
|
123
|
-
# Formats String for easy translation. Replaces an arbitrary number of
|
124
|
-
# values using numeric identifier replacement.
|
125
|
-
#
|
126
|
-
# @example
|
127
|
-
# "%s %s %s" % %w(one two three) #=> "one two three"
|
128
|
-
# "%3$s %2$s %1$s" % %w(one two three) #=> "three two one"
|
129
|
-
def t(*values)
|
130
|
-
self.class::translate(self) % values
|
131
|
-
end
|
132
|
-
end # class String
|