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/lazy_array.rb
DELETED
@@ -1,106 +0,0 @@
|
|
1
|
-
class LazyArray # borrowed partially from StrokeDB
|
2
|
-
instance_methods.each { |m| undef_method m unless %w[ __id__ __send__ send dup class object_id kind_of? respond_to? assert_kind_of should should_not instance_variable_set instance_variable_get ].include?(m) }
|
3
|
-
|
4
|
-
include Enumerable
|
5
|
-
|
6
|
-
# these methods should return self or nil
|
7
|
-
RETURN_SELF = [ :<<, :clear, :concat, :collect!, :each, :each_index,
|
8
|
-
:each_with_index, :freeze, :insert, :map!, :push, :replace,
|
9
|
-
:reject!, :reverse!, :reverse_each, :sort!, :unshift ]
|
10
|
-
|
11
|
-
RETURN_SELF.each do |method|
|
12
|
-
class_eval <<-EOS, __FILE__, __LINE__
|
13
|
-
def #{method}(*args, &block)
|
14
|
-
lazy_load
|
15
|
-
results = @array.#{method}(*args, &block)
|
16
|
-
results.kind_of?(Array) ? self : results
|
17
|
-
end
|
18
|
-
EOS
|
19
|
-
end
|
20
|
-
|
21
|
-
(Array.public_instance_methods(false).map { |m| m.to_sym } - RETURN_SELF - [ :taguri= ]).each do |method|
|
22
|
-
class_eval <<-EOS, __FILE__, __LINE__
|
23
|
-
def #{method}(*args, &block)
|
24
|
-
lazy_load
|
25
|
-
@array.#{method}(*args, &block)
|
26
|
-
end
|
27
|
-
EOS
|
28
|
-
end
|
29
|
-
|
30
|
-
def replace(other)
|
31
|
-
mark_loaded
|
32
|
-
@array.replace(other.entries)
|
33
|
-
self
|
34
|
-
end
|
35
|
-
|
36
|
-
def clear
|
37
|
-
mark_loaded
|
38
|
-
@array.clear
|
39
|
-
self
|
40
|
-
end
|
41
|
-
|
42
|
-
def eql?(other)
|
43
|
-
lazy_load
|
44
|
-
@array.eql?(other.entries)
|
45
|
-
end
|
46
|
-
|
47
|
-
alias == eql?
|
48
|
-
|
49
|
-
def load_with(&block)
|
50
|
-
@load_with_proc = block
|
51
|
-
self
|
52
|
-
end
|
53
|
-
|
54
|
-
def loaded?
|
55
|
-
@loaded == true
|
56
|
-
end
|
57
|
-
|
58
|
-
def unload
|
59
|
-
clear
|
60
|
-
@loaded = false
|
61
|
-
self
|
62
|
-
end
|
63
|
-
|
64
|
-
def respond_to?(method, include_private = false)
|
65
|
-
super || @array.respond_to?(method, include_private)
|
66
|
-
end
|
67
|
-
|
68
|
-
def to_proc
|
69
|
-
@load_with_proc
|
70
|
-
end
|
71
|
-
|
72
|
-
private
|
73
|
-
|
74
|
-
def initialize(*args, &block)
|
75
|
-
@loaded = false
|
76
|
-
@load_with_proc = proc { |v| v }
|
77
|
-
@array = Array.new(*args, &block)
|
78
|
-
end
|
79
|
-
|
80
|
-
def initialize_copy(original)
|
81
|
-
@array = original.entries
|
82
|
-
load_with(&original)
|
83
|
-
mark_loaded if @array.any?
|
84
|
-
end
|
85
|
-
|
86
|
-
def lazy_load
|
87
|
-
return if loaded?
|
88
|
-
mark_loaded
|
89
|
-
@load_with_proc[self]
|
90
|
-
end
|
91
|
-
|
92
|
-
def mark_loaded
|
93
|
-
@loaded = true
|
94
|
-
end
|
95
|
-
|
96
|
-
# delegate any not-explicitly-handled methods to @array, if possible.
|
97
|
-
# this is handy for handling methods mixed-into Array like group_by
|
98
|
-
def method_missing(method, *args, &block)
|
99
|
-
if @array.respond_to?(method)
|
100
|
-
lazy_load
|
101
|
-
@array.send(method, *args, &block)
|
102
|
-
else
|
103
|
-
super
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
data/lib/extlib/mash.rb
DELETED
@@ -1,143 +0,0 @@
|
|
1
|
-
# This class has dubious semantics and we only have it so that people can write
|
2
|
-
# params[:key] instead of params['key'].
|
3
|
-
class Mash < Hash
|
4
|
-
|
5
|
-
# @param constructor<Object>
|
6
|
-
# The default value for the mash. Defaults to an empty hash.
|
7
|
-
#
|
8
|
-
# @details [Alternatives]
|
9
|
-
# If constructor is a Hash, a new mash will be created based on the keys of
|
10
|
-
# the hash and no default value will be set.
|
11
|
-
def initialize(constructor = {})
|
12
|
-
if constructor.is_a?(Hash)
|
13
|
-
super()
|
14
|
-
update(constructor)
|
15
|
-
else
|
16
|
-
super(constructor)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
# @param key<Object> The default value for the mash. Defaults to nil.
|
21
|
-
#
|
22
|
-
# @details [Alternatives]
|
23
|
-
# If key is a Symbol and it is a key in the mash, then the default value will
|
24
|
-
# be set to the value matching the key.
|
25
|
-
def default(key = nil)
|
26
|
-
if key.is_a?(Symbol) && include?(key = key.to_s)
|
27
|
-
self[key]
|
28
|
-
else
|
29
|
-
super
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
alias_method :regular_writer, :[]= unless method_defined?(:regular_writer)
|
34
|
-
alias_method :regular_update, :update unless method_defined?(:regular_update)
|
35
|
-
|
36
|
-
# @param key<Object> The key to set.
|
37
|
-
# @param value<Object>
|
38
|
-
# The value to set the key to.
|
39
|
-
#
|
40
|
-
# @see Mash#convert_key
|
41
|
-
# @see Mash#convert_value
|
42
|
-
def []=(key, value)
|
43
|
-
regular_writer(convert_key(key), convert_value(value))
|
44
|
-
end
|
45
|
-
|
46
|
-
# @param other_hash<Hash>
|
47
|
-
# A hash to update values in the mash with. The keys and the values will be
|
48
|
-
# converted to Mash format.
|
49
|
-
#
|
50
|
-
# @return <Mash> The updated mash.
|
51
|
-
def update(other_hash)
|
52
|
-
other_hash.each_pair { |key, value| regular_writer(convert_key(key), convert_value(value)) }
|
53
|
-
self
|
54
|
-
end
|
55
|
-
|
56
|
-
alias_method :merge!, :update
|
57
|
-
|
58
|
-
# @param key<Object> The key to check for. This will be run through convert_key.
|
59
|
-
#
|
60
|
-
# @return <TrueClass, FalseClass> True if the key exists in the mash.
|
61
|
-
def key?(key)
|
62
|
-
super(convert_key(key))
|
63
|
-
end
|
64
|
-
|
65
|
-
# def include? def has_key? def member?
|
66
|
-
alias_method :include?, :key?
|
67
|
-
alias_method :has_key?, :key?
|
68
|
-
alias_method :member?, :key?
|
69
|
-
|
70
|
-
# @param key<Object> The key to fetch. This will be run through convert_key.
|
71
|
-
# @param *extras<Array> Default value.
|
72
|
-
#
|
73
|
-
# @return <Object> The value at key or the default value.
|
74
|
-
def fetch(key, *extras)
|
75
|
-
super(convert_key(key), *extras)
|
76
|
-
end
|
77
|
-
|
78
|
-
# @param *indices<Array>
|
79
|
-
# The keys to retrieve values for. These will be run through +convert_key+.
|
80
|
-
#
|
81
|
-
# @return <Array> The values at each of the provided keys
|
82
|
-
def values_at(*indices)
|
83
|
-
indices.collect {|key| self[convert_key(key)]}
|
84
|
-
end
|
85
|
-
|
86
|
-
# @return <Mash> A duplicate of this mash.
|
87
|
-
def dup
|
88
|
-
Mash.new(self)
|
89
|
-
end
|
90
|
-
|
91
|
-
# @param hash<Hash> The hash to merge with the mash.
|
92
|
-
#
|
93
|
-
# @return <Mash> A new mash with the hash values merged in.
|
94
|
-
def merge(hash)
|
95
|
-
self.dup.update(hash)
|
96
|
-
end
|
97
|
-
|
98
|
-
# @param key<Object>
|
99
|
-
# The key to delete from the mash.\
|
100
|
-
def delete(key)
|
101
|
-
super(convert_key(key))
|
102
|
-
end
|
103
|
-
|
104
|
-
# Used to provide the same interface as Hash.
|
105
|
-
#
|
106
|
-
# @return <Mash> This mash unchanged.
|
107
|
-
def stringify_keys!; self end
|
108
|
-
|
109
|
-
# @return <Hash> The mash as a Hash with string keys.
|
110
|
-
def to_hash
|
111
|
-
Hash.new(default).merge(self)
|
112
|
-
end
|
113
|
-
|
114
|
-
protected
|
115
|
-
# @param key<Object> The key to convert.
|
116
|
-
#
|
117
|
-
# @param <Object>
|
118
|
-
# The converted key. If the key was a symbol, it will be converted to a
|
119
|
-
# string.
|
120
|
-
#
|
121
|
-
# @api private
|
122
|
-
def convert_key(key)
|
123
|
-
key.kind_of?(Symbol) ? key.to_s : key
|
124
|
-
end
|
125
|
-
|
126
|
-
# @param value<Object> The value to convert.
|
127
|
-
#
|
128
|
-
# @return <Object>
|
129
|
-
# The converted value. A Hash or an Array of hashes, will be converted to
|
130
|
-
# their Mash equivalents.
|
131
|
-
#
|
132
|
-
# @api private
|
133
|
-
def convert_value(value)
|
134
|
-
case value
|
135
|
-
when Hash
|
136
|
-
value.to_mash
|
137
|
-
when Array
|
138
|
-
value.collect { |e| convert_value(e) }
|
139
|
-
else
|
140
|
-
value
|
141
|
-
end
|
142
|
-
end
|
143
|
-
end
|
data/lib/extlib/module.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
class Module
|
2
|
-
def find_const(const_name)
|
3
|
-
if const_name[0..1] == '::'
|
4
|
-
Object.find_const(const_name[2..-1])
|
5
|
-
else
|
6
|
-
nested_const_lookup(const_name)
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
private
|
11
|
-
|
12
|
-
# Doesn't do any caching since constants can change with remove_const
|
13
|
-
def nested_const_lookup(const_name)
|
14
|
-
constants = [ Object ]
|
15
|
-
|
16
|
-
unless self == Object
|
17
|
-
self.name.split('::').each do |part|
|
18
|
-
constants.unshift(constants.first.const_get(part))
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
parts = const_name.split('::')
|
23
|
-
|
24
|
-
# from most to least specific constant, use each as a base and try
|
25
|
-
# to find a constant with the name const_name within them
|
26
|
-
constants.each do |const|
|
27
|
-
# return the nested constant if available
|
28
|
-
return const if parts.all? do |part|
|
29
|
-
const = const.const_defined?(part) ? const.const_get(part) : nil
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
# if we get this far then the nested constant was not found
|
34
|
-
raise NameError, "uninitialized constant #{const_name}"
|
35
|
-
end
|
36
|
-
|
37
|
-
end # class Module
|
data/lib/extlib/object.rb
DELETED
@@ -1,165 +0,0 @@
|
|
1
|
-
class Object
|
2
|
-
# Extracts the singleton class, so that metaprogramming can be done on it.
|
3
|
-
#
|
4
|
-
# @return <Class> The meta class.
|
5
|
-
#
|
6
|
-
# @example [Setup]
|
7
|
-
# class MyString < String; end
|
8
|
-
#
|
9
|
-
# MyString.instance_eval do
|
10
|
-
# define_method :foo do
|
11
|
-
# puts self
|
12
|
-
# end
|
13
|
-
# end
|
14
|
-
#
|
15
|
-
# MyString.meta_class.instance_eval do
|
16
|
-
# define_method :bar do
|
17
|
-
# puts self
|
18
|
-
# end
|
19
|
-
# end
|
20
|
-
#
|
21
|
-
# def String.add_meta_var(var)
|
22
|
-
# self.meta_class.instance_eval do
|
23
|
-
# define_method var do
|
24
|
-
# puts "HELLO"
|
25
|
-
# end
|
26
|
-
# end
|
27
|
-
# end
|
28
|
-
#
|
29
|
-
# @example
|
30
|
-
# MyString.new("Hello").foo #=> "Hello"
|
31
|
-
# @example
|
32
|
-
# MyString.new("Hello").bar
|
33
|
-
# #=> NoMethodError: undefined method `bar' for "Hello":MyString
|
34
|
-
# @example
|
35
|
-
# MyString.foo
|
36
|
-
# #=> NoMethodError: undefined method `foo' for MyString:Class
|
37
|
-
# @example
|
38
|
-
# MyString.bar
|
39
|
-
# #=> MyString
|
40
|
-
# @example
|
41
|
-
# String.bar
|
42
|
-
# #=> NoMethodError: undefined method `bar' for String:Class
|
43
|
-
# @example
|
44
|
-
# MyString.add_meta_var(:x)
|
45
|
-
# MyString.x #=> HELLO
|
46
|
-
#
|
47
|
-
# @details [Description of Examples]
|
48
|
-
# As you can see, using #meta_class allows you to execute code (and here,
|
49
|
-
# define a method) on the metaclass itself. It also allows you to define
|
50
|
-
# class methods that can be run on subclasses, and then be able to execute
|
51
|
-
# code on the metaclass of the subclass (here MyString).
|
52
|
-
#
|
53
|
-
# In this case, we were able to define a class method (add_meta_var) on
|
54
|
-
# String that was executable by the MyString subclass. It was then able to
|
55
|
-
# define a method on the subclass by adding it to the MyString metaclass.
|
56
|
-
#
|
57
|
-
# For more information, you can check out _why's excellent article at:
|
58
|
-
# http://whytheluckystiff.net/articles/seeingMetaclassesClearly.html
|
59
|
-
def meta_class() class << self; self end end
|
60
|
-
|
61
|
-
# @return <TrueClass, FalseClass>
|
62
|
-
# True if the empty? is true or if the object responds to strip (e.g. a
|
63
|
-
# String) and strip.empty? is true, or if !self is true.
|
64
|
-
#
|
65
|
-
# @example [].blank? #=> true
|
66
|
-
# @example [1].blank? #=> false
|
67
|
-
# @example [nil].blank? #=> false
|
68
|
-
# @example nil.blank? #=> true
|
69
|
-
# @example true.blank? #=> false
|
70
|
-
# @example false.blank? #=> true
|
71
|
-
# @example "".blank? #=> true
|
72
|
-
# @example " ".blank? #=> true
|
73
|
-
# @example " hey ho ".blank? #=> false
|
74
|
-
def blank?
|
75
|
-
if respond_to?(:empty?) && respond_to?(:strip)
|
76
|
-
empty? or strip.empty?
|
77
|
-
elsif respond_to?(:empty?)
|
78
|
-
empty?
|
79
|
-
else
|
80
|
-
!self
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
# @param name<String> The name of the constant to get, e.g. "Merb::Router".
|
85
|
-
#
|
86
|
-
# @return <Object> The constant corresponding to the name.
|
87
|
-
def full_const_get(name)
|
88
|
-
list = name.split("::")
|
89
|
-
list.shift if list.first.blank?
|
90
|
-
obj = self
|
91
|
-
list.each do |x|
|
92
|
-
# This is required because const_get tries to look for constants in the
|
93
|
-
# ancestor chain, but we only want constants that are HERE
|
94
|
-
obj = obj.const_defined?(x) ? obj.const_get(x) : obj.const_missing(x)
|
95
|
-
end
|
96
|
-
obj
|
97
|
-
end
|
98
|
-
|
99
|
-
# @param name<String> The name of the constant to get, e.g. "Merb::Router".
|
100
|
-
# @param value<Object> The value to assign to the constant.
|
101
|
-
#
|
102
|
-
# @return <Object> The constant corresponding to the name.
|
103
|
-
def full_const_set(name, value)
|
104
|
-
list = name.split("::")
|
105
|
-
toplevel = list.first.blank?
|
106
|
-
list.shift if toplevel
|
107
|
-
last = list.pop
|
108
|
-
obj = list.empty? ? Object : Object.full_const_get(list.join("::"))
|
109
|
-
obj.const_set(last, value) if obj && !obj.const_defined?(last)
|
110
|
-
end
|
111
|
-
|
112
|
-
# Defines module from a string name (e.g. Foo::Bar::Baz)
|
113
|
-
# If module already exists, no exception raised.
|
114
|
-
#
|
115
|
-
# @param name<String> The name of the full module name to make
|
116
|
-
#
|
117
|
-
# @return <NilClass>
|
118
|
-
def make_module(str)
|
119
|
-
mod = str.split("::")
|
120
|
-
start = mod.map {|x| "module #{x}"}.join("; ")
|
121
|
-
ender = (["end"] * mod.size).join("; ")
|
122
|
-
self.class_eval <<-HERE
|
123
|
-
#{start}
|
124
|
-
#{ender}
|
125
|
-
HERE
|
126
|
-
end
|
127
|
-
|
128
|
-
# @param duck<Symbol, Class, Array> The thing to compare the object to.
|
129
|
-
#
|
130
|
-
# @note
|
131
|
-
# The behavior of the method depends on the type of duck as follows:
|
132
|
-
# Symbol:: Check whether the object respond_to?(duck).
|
133
|
-
# Class:: Check whether the object is_a?(duck).
|
134
|
-
# Array::
|
135
|
-
# Check whether the object quacks_like? at least one of the options in the
|
136
|
-
# array.
|
137
|
-
#
|
138
|
-
# @return <TrueClass, FalseClass>
|
139
|
-
# True if the object quacks like duck.
|
140
|
-
def quacks_like?(duck)
|
141
|
-
case duck
|
142
|
-
when Symbol
|
143
|
-
self.respond_to?(duck)
|
144
|
-
when Class
|
145
|
-
self.is_a?(duck)
|
146
|
-
when Array
|
147
|
-
duck.any? {|d| self.quacks_like?(d) }
|
148
|
-
else
|
149
|
-
false
|
150
|
-
end
|
151
|
-
end
|
152
|
-
|
153
|
-
# @param arrayish<#include?> Container to check, to see if it includes the object.
|
154
|
-
# @param *more<Array>:: additional args, will be flattened into arrayish
|
155
|
-
#
|
156
|
-
# @return <TrueClass, FalseClass>
|
157
|
-
# True if the object is included in arrayish (+ more)
|
158
|
-
#
|
159
|
-
# @example 1.in?([1,2,3]) #=> true
|
160
|
-
# @example 1.in?(1,2,3) #=> true
|
161
|
-
def in?(arrayish,*more)
|
162
|
-
arrayish = more.unshift(arrayish) unless more.empty?
|
163
|
-
arrayish.include?(self)
|
164
|
-
end
|
165
|
-
end
|