merb-core 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README +21 -0
- data/Rakefile +285 -0
- data/TODO +0 -0
- data/bin/merb +8 -0
- data/bin/merb-specs +5 -0
- data/docs/bootloading.dox +57 -0
- data/docs/documentation_standards +40 -0
- data/docs/new_render_api +51 -0
- data/lib/merb-core.rb +304 -0
- data/lib/merb-core/autoload.rb +29 -0
- data/lib/merb-core/bootloader.rb +601 -0
- data/lib/merb-core/config.rb +284 -0
- data/lib/merb-core/constants.rb +43 -0
- data/lib/merb-core/controller/abstract_controller.rb +531 -0
- data/lib/merb-core/controller/exceptions.rb +257 -0
- data/lib/merb-core/controller/merb_controller.rb +214 -0
- data/lib/merb-core/controller/mime.rb +88 -0
- data/lib/merb-core/controller/mixins/controller.rb +262 -0
- data/lib/merb-core/controller/mixins/render.rb +324 -0
- data/lib/merb-core/controller/mixins/responder.rb +464 -0
- data/lib/merb-core/controller/template.rb +205 -0
- data/lib/merb-core/core_ext.rb +12 -0
- data/lib/merb-core/core_ext/class.rb +192 -0
- data/lib/merb-core/core_ext/hash.rb +422 -0
- data/lib/merb-core/core_ext/kernel.rb +304 -0
- data/lib/merb-core/core_ext/mash.rb +154 -0
- data/lib/merb-core/core_ext/object.rb +136 -0
- data/lib/merb-core/core_ext/object_space.rb +14 -0
- data/lib/merb-core/core_ext/rubygems.rb +28 -0
- data/lib/merb-core/core_ext/set.rb +41 -0
- data/lib/merb-core/core_ext/string.rb +69 -0
- data/lib/merb-core/dispatch/cookies.rb +92 -0
- data/lib/merb-core/dispatch/dispatcher.rb +233 -0
- data/lib/merb-core/dispatch/exceptions.html.erb +297 -0
- data/lib/merb-core/dispatch/request.rb +560 -0
- data/lib/merb-core/dispatch/router.rb +141 -0
- data/lib/merb-core/dispatch/router/behavior.rb +777 -0
- data/lib/merb-core/dispatch/router/cached_proc.rb +52 -0
- data/lib/merb-core/dispatch/router/route.rb +212 -0
- data/lib/merb-core/dispatch/session.rb +28 -0
- data/lib/merb-core/dispatch/session/cookie.rb +166 -0
- data/lib/merb-core/dispatch/session/memcached.rb +161 -0
- data/lib/merb-core/dispatch/session/memory.rb +234 -0
- data/lib/merb-core/gem_ext/erubis.rb +19 -0
- data/lib/merb-core/logger.rb +230 -0
- data/lib/merb-core/plugins.rb +25 -0
- data/lib/merb-core/rack.rb +15 -0
- data/lib/merb-core/rack/adapter.rb +42 -0
- data/lib/merb-core/rack/adapter/ebb.rb +22 -0
- data/lib/merb-core/rack/adapter/evented_mongrel.rb +24 -0
- data/lib/merb-core/rack/adapter/fcgi.rb +16 -0
- data/lib/merb-core/rack/adapter/irb.rb +108 -0
- data/lib/merb-core/rack/adapter/mongrel.rb +25 -0
- data/lib/merb-core/rack/adapter/runner.rb +27 -0
- data/lib/merb-core/rack/adapter/thin.rb +27 -0
- data/lib/merb-core/rack/adapter/webrick.rb +35 -0
- data/lib/merb-core/rack/application.rb +77 -0
- data/lib/merb-core/rack/handler/mongrel.rb +97 -0
- data/lib/merb-core/server.rb +184 -0
- data/lib/merb-core/test.rb +10 -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 +257 -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 +269 -0
- data/lib/merb-core/test/matchers/route_matchers.rb +136 -0
- data/lib/merb-core/test/matchers/view_matchers.rb +293 -0
- data/lib/merb-core/test/run_specs.rb +38 -0
- data/lib/merb-core/test/tasks/spectasks.rb +39 -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/vendor/facets.rb +2 -0
- data/lib/merb-core/vendor/facets/dictionary.rb +433 -0
- data/lib/merb-core/vendor/facets/inflect.rb +211 -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 +139 -0
- data/spec/private/config/environment_spec.rb +13 -0
- data/spec/private/config/spec_helper.rb +1 -0
- data/spec/private/core_ext/hash_spec.rb +506 -0
- data/spec/private/core_ext/kernel_spec.rb +46 -0
- data/spec/private/core_ext/object_spec.rb +39 -0
- data/spec/private/core_ext/set_spec.rb +26 -0
- data/spec/private/core_ext/string_spec.rb +9 -0
- data/spec/private/dispatch/cookies_spec.rb +107 -0
- data/spec/private/dispatch/dispatch_spec.rb +26 -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/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 +1 -0
- data/spec/private/dispatch/fixture/config/router.rb +35 -0
- data/spec/private/dispatch/fixture/log/development.log +1 -0
- data/spec/private/dispatch/fixture/log/merb.4000.pid +1 -0
- data/spec/private/dispatch/fixture/log/merb_test.log +2040 -0
- data/spec/private/dispatch/fixture/log/production.log +1 -0
- data/spec/private/dispatch/fixture/merb.4000.pid +1 -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/spec_helper.rb +1 -0
- data/spec/private/plugins/plugin_spec.rb +81 -0
- data/spec/private/rack/application_spec.rb +43 -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/display.rb +54 -0
- data/spec/public/abstract_controller/controllers/filters.rb +167 -0
- data/spec/public/abstract_controller/controllers/helpers.rb +31 -0
- data/spec/public/abstract_controller/controllers/partial.rb +106 -0
- data/spec/public/abstract_controller/controllers/render.rb +86 -0
- data/spec/public/abstract_controller/controllers/views/helpers/capture/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/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_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_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 +80 -0
- data/spec/public/abstract_controller/helper_spec.rb +13 -0
- data/spec/public/abstract_controller/partial_spec.rb +53 -0
- data/spec/public/abstract_controller/render_spec.rb +70 -0
- data/spec/public/abstract_controller/spec_helper.rb +27 -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/base_spec.rb +31 -0
- data/spec/public/controller/controllers/base.rb +41 -0
- data/spec/public/controller/controllers/display.rb +40 -0
- data/spec/public/controller/controllers/responder.rb +67 -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/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/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 +34 -0
- data/spec/public/controller/log/merb.4000.pid +1 -0
- data/spec/public/controller/responder_spec.rb +95 -0
- data/spec/public/controller/spec_helper.rb +9 -0
- data/spec/public/controller/url_spec.rb +152 -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.4000.pid +1 -0
- data/spec/public/directory_structure/directory/log/merb_test.log +265 -0
- data/spec/public/directory_structure/directory/merb.4000.pid +1 -0
- data/spec/public/directory_structure/directory_spec.rb +44 -0
- data/spec/public/logger/logger_spec.rb +175 -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.4000.pid +1 -0
- data/spec/public/reloading/directory/log/merb_test.log +59 -0
- data/spec/public/reloading/directory/merb.4000.pid +1 -0
- data/spec/public/reloading/reload_spec.rb +80 -0
- data/spec/public/request/multipart_spec.rb +15 -0
- data/spec/public/request/request_spec.rb +207 -0
- data/spec/public/router/default_spec.rb +21 -0
- data/spec/public/router/deferred_spec.rb +22 -0
- data/spec/public/router/namespace_spec.rb +113 -0
- data/spec/public/router/nested_resources_spec.rb +34 -0
- data/spec/public/router/resource_spec.rb +45 -0
- data/spec/public/router/resources_spec.rb +57 -0
- data/spec/public/router/spec_helper.rb +72 -0
- data/spec/public/router/special_spec.rb +44 -0
- data/spec/public/router/string_spec.rb +61 -0
- data/spec/public/template/template_spec.rb +92 -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 +378 -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 +30 -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 +153 -0
- data/spec/public/test/route_helper_spec.rb +54 -0
- data/spec/public/test/route_matchers_spec.rb +133 -0
- data/spec/public/test/view_helper_spec.rb +96 -0
- data/spec/public/test/view_matchers_spec.rb +107 -0
- data/spec/spec_helper.rb +71 -0
- metadata +488 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2008 Ezra Zygmuntowicz
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
merb-core is a new branch of Merb (also referred to as merb-next or the 0.9 series) which aims to provide a stable, stripped down API for a future Merb 1.0 release.
|
2
|
+
|
3
|
+
This branch is based off the 0.5 release series but with significant rewrites.
|
4
|
+
|
5
|
+
Goals of this release:
|
6
|
+
|
7
|
+
* Stabilize the @public interface methods to provide for a more consistent application development experience.
|
8
|
+
* Remove features until nothing except a central application API is left
|
9
|
+
* Improve comments on methods using a standard documentation methodology as described in DOCUMENTATION_STANDARDS
|
10
|
+
* Separate the tests into two sections... "private" and "public"
|
11
|
+
* Public methods are methods tagged with @public that will be part of the standard, stable Merb API
|
12
|
+
* Private methods are implementation methods that might
|
13
|
+
* Implement a new render API
|
14
|
+
* Build more extensions to regain selected features when needed
|
15
|
+
|
16
|
+
To familiarize yourself with how a merb-core application might look,
|
17
|
+
use merb-gen (from merb-more) to generate a few apps:
|
18
|
+
$ merb-gen myapp # a "normal" merb app
|
19
|
+
$ merb-gen myapp --flat # a flattened app
|
20
|
+
$ merb-gen myapp --very-flat # a single-file app
|
21
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,285 @@
|
|
1
|
+
require "rake"
|
2
|
+
require "rake/clean"
|
3
|
+
require "rake/gempackagetask"
|
4
|
+
require "rake/rdoctask"
|
5
|
+
require "rake/testtask"
|
6
|
+
require "spec/rake/spectask"
|
7
|
+
require "fileutils"
|
8
|
+
|
9
|
+
def __DIR__
|
10
|
+
File.dirname(__FILE__)
|
11
|
+
end
|
12
|
+
|
13
|
+
require __DIR__ + "/tools/rakehelp"
|
14
|
+
require __DIR__ + "/tools/annotation_extract"
|
15
|
+
|
16
|
+
include FileUtils
|
17
|
+
|
18
|
+
NAME = "merb-core"
|
19
|
+
|
20
|
+
require "lib/merb-core/version"
|
21
|
+
require "lib/merb-core/test/run_specs"
|
22
|
+
|
23
|
+
##############################################################################
|
24
|
+
# Packaging & Installation
|
25
|
+
##############################################################################
|
26
|
+
CLEAN.include ["**/.*.sw?", "pkg", "lib/*.bundle", "*.gem", "doc/rdoc", ".config", "coverage", "cache"]
|
27
|
+
|
28
|
+
windows = (PLATFORM =~ /win32|cygwin/) rescue nil
|
29
|
+
|
30
|
+
SUDO = windows ? "" : "sudo"
|
31
|
+
|
32
|
+
desc "Packages up Merb."
|
33
|
+
task :default => :package
|
34
|
+
|
35
|
+
task :merb => [:clean, :rdoc, :package]
|
36
|
+
|
37
|
+
spec = Gem::Specification.new do |s|
|
38
|
+
s.name = NAME
|
39
|
+
s.version = Merb::VERSION
|
40
|
+
s.platform = Gem::Platform::RUBY
|
41
|
+
s.author = "Ezra Zygmuntowicz"
|
42
|
+
s.email = "ez@engineyard.com"
|
43
|
+
s.homepage = "http://merb.devjavu.com"
|
44
|
+
s.summary = "Merb. Pocket rocket web framework."
|
45
|
+
s.bindir = "bin"
|
46
|
+
s.description = s.summary
|
47
|
+
s.executables = %w( merb )
|
48
|
+
s.require_path = "lib"
|
49
|
+
s.files = %w( LICENSE README Rakefile TODO ) + Dir["{docs,bin,spec,lib,examples,app_generators,merb_generators,merb_default_generators,rspec_generators,test_unit_generators,script}/**/*"]
|
50
|
+
|
51
|
+
# rdoc
|
52
|
+
s.has_rdoc = true
|
53
|
+
s.extra_rdoc_files = %w( README LICENSE TODO )
|
54
|
+
#s.rdoc_options += RDOC_OPTS + ["--exclude", "^(app|uploads)"]
|
55
|
+
|
56
|
+
# Dependencies
|
57
|
+
s.add_dependency "erubis"
|
58
|
+
s.add_dependency "rake"
|
59
|
+
s.add_dependency "json_pure"
|
60
|
+
s.add_dependency "rspec"
|
61
|
+
s.add_dependency "rack"
|
62
|
+
s.add_dependency "hpricot"
|
63
|
+
s.add_dependency "mime-types"
|
64
|
+
# Requirements
|
65
|
+
s.requirements << "install the json gem to get faster json parsing"
|
66
|
+
s.required_ruby_version = ">= 1.8.4"
|
67
|
+
end
|
68
|
+
|
69
|
+
Rake::GemPackageTask.new(spec) do |package|
|
70
|
+
package.gem_spec = spec
|
71
|
+
end
|
72
|
+
|
73
|
+
desc "Run :package and install the resulting .gem"
|
74
|
+
task :install => :package do
|
75
|
+
sh %{#{SUDO} gem install --local pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri}
|
76
|
+
end
|
77
|
+
|
78
|
+
desc "Run :package and install the resulting .gem with jruby"
|
79
|
+
task :jinstall => :package do
|
80
|
+
sh %{#{SUDO} jruby -S gem install pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri}
|
81
|
+
end
|
82
|
+
|
83
|
+
desc "Run :clean and uninstall the .gem"
|
84
|
+
task :uninstall => :clean do
|
85
|
+
sh %{#{SUDO} gem uninstall #{NAME}}
|
86
|
+
end
|
87
|
+
|
88
|
+
##############################################################################
|
89
|
+
# Documentation
|
90
|
+
##############################################################################
|
91
|
+
task :doc => [:rdoc]
|
92
|
+
namespace :doc do
|
93
|
+
|
94
|
+
Rake::RDocTask.new do |rdoc|
|
95
|
+
files = ["README", "LICENSE", "CHANGELOG", "lib/**/*.rb"]
|
96
|
+
rdoc.rdoc_files.add(files)
|
97
|
+
rdoc.main = "README"
|
98
|
+
rdoc.title = "Merb Docs"
|
99
|
+
rdoc.template = __DIR__ + "/tools/allison-2.0.2/lib/allison.rb"
|
100
|
+
rdoc.rdoc_dir = "doc/rdoc"
|
101
|
+
rdoc.options << "--line-numbers" << "--inline-source"
|
102
|
+
end
|
103
|
+
|
104
|
+
desc "run webgen"
|
105
|
+
task :webgen do
|
106
|
+
sh %{cd doc/site; webgen}
|
107
|
+
end
|
108
|
+
|
109
|
+
desc "rdoc to rubyforge"
|
110
|
+
task :rubyforge do
|
111
|
+
# sh %{rake doc}
|
112
|
+
sh %{#{SUDO} chmod -R 755 doc} unless windows
|
113
|
+
sh %{/usr/bin/scp -r -p doc/rdoc/* ezmobius@rubyforge.org:/var/www/gforge-projects/merb}
|
114
|
+
end
|
115
|
+
|
116
|
+
end
|
117
|
+
|
118
|
+
##############################################################################
|
119
|
+
# rSpec & rcov
|
120
|
+
##############################################################################
|
121
|
+
desc "Run :specs, :rcov"
|
122
|
+
task :aok => [:specs, :rcov]
|
123
|
+
|
124
|
+
# desc "Run all specs"
|
125
|
+
# Spec::Rake::SpecTask.new("specs") do |t|
|
126
|
+
# t.spec_opts = ["--format", "specdoc", "--colour"]
|
127
|
+
# t.spec_files = Dir["spec/**/*_spec.rb"].sort
|
128
|
+
# end
|
129
|
+
|
130
|
+
def setup_specs(name, spec_cmd='spec')
|
131
|
+
desc "Run all specs (#{name})"
|
132
|
+
task "specs:#{name}" do
|
133
|
+
run_specs("spec/**/*_spec.rb", spec_cmd)
|
134
|
+
end
|
135
|
+
|
136
|
+
desc "Run private specs (#{name})"
|
137
|
+
task "specs:#{name}:private" do
|
138
|
+
run_specs("spec/private/**/*_spec.rb", spec_cmd)
|
139
|
+
end
|
140
|
+
|
141
|
+
desc "Run public specs (#{name})"
|
142
|
+
task "specs:#{name}:public" do
|
143
|
+
run_specs("spec/public/**/*_spec.rb", spec_cmd)
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
setup_specs("mri", "spec")
|
148
|
+
setup_specs("jruby", "jruby -S spec")
|
149
|
+
|
150
|
+
task "specs" => ["specs:mri"]
|
151
|
+
task "specs:private" => ["specs:mri:private"]
|
152
|
+
task "specs:public" => ["specs:mri:public"]
|
153
|
+
|
154
|
+
desc "Run coverage suite"
|
155
|
+
task :rcov do
|
156
|
+
require 'fileutils'
|
157
|
+
FileUtils.rm_rf("coverage") if File.directory?("coverage")
|
158
|
+
FileUtils.mkdir("coverage")
|
159
|
+
path = File.expand_path(Dir.pwd)
|
160
|
+
files = Dir["spec/**/*_spec.rb"]
|
161
|
+
files.each do |spec|
|
162
|
+
puts "Getting coverage for #{File.expand_path(spec)}"
|
163
|
+
command = %{rcov #{File.expand_path(spec)} --aggregate #{path}/coverage/data.data --exclude ".*" --include-file "lib/merb-core(?!\/vendor)"}
|
164
|
+
command += " --no-html" unless spec == files.last
|
165
|
+
`#{command} 2>&1`
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
desc "Run a specific spec with TASK=xxxx"
|
170
|
+
Spec::Rake::SpecTask.new("spec") do |t|
|
171
|
+
t.spec_opts = ["--format", "specdoc", "--colour"]
|
172
|
+
t.libs = ["lib", "server/lib" ]
|
173
|
+
t.spec_files = (ENV["TASK"] || '').split(',').map do |task|
|
174
|
+
"spec/**/#{task}_spec.rb"
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
desc "Run all specs output html"
|
179
|
+
Spec::Rake::SpecTask.new("specs_html") do |t|
|
180
|
+
t.spec_opts = ["--format", "html"]
|
181
|
+
t.libs = ["lib", "server/lib" ]
|
182
|
+
t.spec_files = Dir["spec/**/*_spec.rb"].sort
|
183
|
+
end
|
184
|
+
|
185
|
+
# desc "RCov"
|
186
|
+
# Spec::Rake::SpecTask.new("rcov") do |t|
|
187
|
+
# t.rcov_opts = ["--exclude", "gems", "--exclude", "spec"]
|
188
|
+
# t.spec_opts = ["--format", "specdoc", "--colour"]
|
189
|
+
# t.spec_files = Dir["spec/**/*_spec.rb"].sort
|
190
|
+
# t.libs = ["lib", "server/lib"]
|
191
|
+
# t.rcov = true
|
192
|
+
# end
|
193
|
+
|
194
|
+
STATS_DIRECTORIES = [
|
195
|
+
['Code', 'lib/'],
|
196
|
+
['Unit tests', 'spec']
|
197
|
+
].collect { |name, dir| [ name, "./#{dir}" ] }.
|
198
|
+
select { |name, dir| File.directory?(dir) }
|
199
|
+
|
200
|
+
desc "Report code statistics (KLOCs, etc) from the application"
|
201
|
+
task :stats do
|
202
|
+
require __DIR__ + "/tools/code_statistics"
|
203
|
+
# require "extra/stats"
|
204
|
+
verbose = true
|
205
|
+
CodeStatistics.new(*STATS_DIRECTORIES).to_s
|
206
|
+
end
|
207
|
+
|
208
|
+
task :release => :package do
|
209
|
+
if ENV["RELEASE"]
|
210
|
+
sh %{rubyforge add_release merb merb "#{ENV["RELEASE"]}" pkg/#{NAME}-#{Merb::VERSION}.gem}
|
211
|
+
else
|
212
|
+
puts "Usage: rake release RELEASE='Clever tag line goes here'"
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
##############################################################################
|
217
|
+
# SYNTAX CHECKING
|
218
|
+
##############################################################################
|
219
|
+
|
220
|
+
task :check_syntax do
|
221
|
+
`find . -name "*.rb" |xargs -n1 ruby -c |grep -v "Syntax OK"`
|
222
|
+
puts "* Done"
|
223
|
+
end
|
224
|
+
|
225
|
+
##############################################################################
|
226
|
+
# SVN
|
227
|
+
##############################################################################
|
228
|
+
namespace :repo do
|
229
|
+
|
230
|
+
desc "Add new files to repository"
|
231
|
+
task :add do
|
232
|
+
if File.directory?(".git")
|
233
|
+
system "git add *"
|
234
|
+
elsif File.directory?(".svn")
|
235
|
+
system "svn status | grep '^\?' | sed -e 's/? *//' | sed -e 's/ /\ /g' | xargs svn add"
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
239
|
+
desc "Fetch changes from master repository"
|
240
|
+
task :rebase do
|
241
|
+
if File.directory?(".git")
|
242
|
+
system "git stash ; git svn rebase ; git stash apply"
|
243
|
+
elsif File.directory?(".svn")
|
244
|
+
system "svn update"
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
desc "commit modified changes to the repository"
|
249
|
+
task :commit do
|
250
|
+
if File.directory?(".git")
|
251
|
+
system "git commit"
|
252
|
+
elsif File.directory?(".svn")
|
253
|
+
system "svn commit"
|
254
|
+
end
|
255
|
+
end
|
256
|
+
|
257
|
+
end
|
258
|
+
|
259
|
+
# Run specific tests or test files. Searches nested spec directories as well.
|
260
|
+
#
|
261
|
+
# Based on a technique popularized by Geoffrey Grosenbach
|
262
|
+
rule "" do |t|
|
263
|
+
spec_cmd = (RUBY_PLATFORM =~ /java/) ? "jruby -S spec" : "spec"
|
264
|
+
# spec:spec_file:spec_name
|
265
|
+
if /spec:(.*)$/.match(t.name)
|
266
|
+
arguments = t.name.split(':')
|
267
|
+
|
268
|
+
file_name = arguments[1]
|
269
|
+
spec_name = arguments[2..-1]
|
270
|
+
|
271
|
+
spec_filename = "#{file_name}_spec.rb"
|
272
|
+
specs = Dir["spec/**/#{spec_filename}"]
|
273
|
+
|
274
|
+
if path = specs.detect { |f| spec_filename == File.basename(f) }
|
275
|
+
run_file_name = path
|
276
|
+
else
|
277
|
+
puts "No specs found for #{t.name.inspect}"
|
278
|
+
exit
|
279
|
+
end
|
280
|
+
|
281
|
+
example = " -e '#{spec_name}'" unless spec_name.empty?
|
282
|
+
|
283
|
+
sh "#{spec_cmd} #{run_file_name} --format specdoc --colour #{example}"
|
284
|
+
end
|
285
|
+
end
|
data/TODO
ADDED
File without changes
|
data/bin/merb
ADDED
data/bin/merb-specs
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
The Merb boot process starts when you run the Merb binary, which calls `Merb.start`. Merb.start performs the
|
2
|
+
following tasks:
|
3
|
+
|
4
|
+
list.
|
5
|
+
* Loads merb.yml from the root directory or config directory and puts them in the Merb::Config hash
|
6
|
+
* Parses config arguments from the command-line and adds them to the Merb::Config hash
|
7
|
+
* Runs the BootLoaders (see below)
|
8
|
+
* Starts the Merb Rack adapter
|
9
|
+
|
10
|
+
The BootLoader is a configurable process, which, by default, runs the following processes:
|
11
|
+
|
12
|
+
deflist.
|
13
|
+
Environment: Sets the Merb environment based on any -e flag passed the merb binary
|
14
|
+
BuildFramework: Set the framework paths, which can either be set in the Merb::Config[:framework]
|
15
|
+
variable or defaults to the paths described below.
|
16
|
+
Dependencies: Load dependencies.rb, which should include any plugins that will be loaded, as well
|
17
|
+
as an after_app_loaded hook.
|
18
|
+
Logger: Set up the logger in the `Merb.dir_for(:log)` directory. In test mode, it will be called
|
19
|
+
`test_logger`. In other modes, it will be set to `merb.#{pid}.log`. The log level will default
|
20
|
+
to `info` but can be specified via the Merb::Config[:log_level] option.
|
21
|
+
LoadRouter: The router is loaded from `Merb.dir_for(:config)/router.rb`.
|
22
|
+
LoadClasses: Files in all of the load paths are `require`d, and classes added during the load of
|
23
|
+
each files are tracked so they can be removed later during the reloading process.
|
24
|
+
Templates: All templates under the `_template_root` of any loaded controllers, as well as all
|
25
|
+
templates under `Merb.dir_for(:view)` are registered as inlined templates.
|
26
|
+
MimeTypes: Register all MimeTypes (see below for defaults).
|
27
|
+
AfterAppLoads: Call any `after_app_loads` hooks that were registered in dependencies.rb
|
28
|
+
MixinSessionContainer: Register the session types and set the app to use one if
|
29
|
+
`Merb::Config[:session_type]` is set.
|
30
|
+
ChooseAdapter: Set `Merb.adapter` to be the adapter chosen via Merb::Config[:adapter] (which
|
31
|
+
can be specified via the `-a foo` command-line parameter).
|
32
|
+
RackUpApplication: Set up a default rack application. Alternatively, allow for additional configuration
|
33
|
+
in `Merb.dir_for(:config)/rack.rb`, which will be evaluated in the context of a Rack::Builder.new
|
34
|
+
block.
|
35
|
+
ReloadClasses: If Merb::Config[:reload_classes] is set, begin the process of reloading classes
|
36
|
+
every time a class is modified.
|
37
|
+
|
38
|
+
deflist: Default Framework Paths.
|
39
|
+
application: Merb.root/app/controller/application.rb
|
40
|
+
config: Merb.root/config
|
41
|
+
lib: Merb.root/lib
|
42
|
+
log: Merb.root/log
|
43
|
+
view: Merb.root/app/views
|
44
|
+
model: Merb.root/app/models
|
45
|
+
controller: Merb.root/app/controllers
|
46
|
+
helper: Merb.root/app/helpers
|
47
|
+
mailer: Merb.root/app/mailers
|
48
|
+
part: Merb.root/app/parts
|
49
|
+
|
50
|
+
deflist: MimeTypes.
|
51
|
+
\:all: no transform, */*
|
52
|
+
\:yaml: to_yaml, application/x-yaml or text/yaml
|
53
|
+
\:text: to_text, text/plain
|
54
|
+
\:html: to_html, text/html or application/xhtml+xml or application/html
|
55
|
+
\:xml: to_xml, application/xml or text/xml or application/x-xml, adds "Encoding: UTF-8" response header
|
56
|
+
\:js: to_json, text/javascript ot application/javascript or application/x-javascript
|
57
|
+
\:json: to_json, application/json or text/x-json
|
@@ -0,0 +1,40 @@
|
|
1
|
+
Every method should have documentation above the method definition that fits this basic model...
|
2
|
+
|
3
|
+
# Render the specified item, with the specified options.
|
4
|
+
#
|
5
|
+
# ==== Parameters
|
6
|
+
# thing<String, Symbol, nil>::
|
7
|
+
# The thing to render. This will default to the current action
|
8
|
+
# opts<Hash>:: An options hash (see below)
|
9
|
+
#
|
10
|
+
# ==== Options (opts)
|
11
|
+
# :format<Symbol>:: A registered mime-type format
|
12
|
+
# :template<String>::
|
13
|
+
# The path to the template relative to the template root
|
14
|
+
# :status<~to_i>::
|
15
|
+
# The status to send to the client. Typically, this would
|
16
|
+
# be an integer (200), or a Merb status code (Accepted)
|
17
|
+
# :layout<~to_s>::
|
18
|
+
# A layout to use instead of the default. This should be
|
19
|
+
# relative to the layout root. By default, the layout will
|
20
|
+
# be either the controller_name or application. If you
|
21
|
+
# want to use an alternative content-type than the one
|
22
|
+
# that the base template was rendered as, you will need
|
23
|
+
# to do :layout => “foo.#{content_type}” (i.e. “foo.json”)
|
24
|
+
#
|
25
|
+
# ==== Returns
|
26
|
+
# String:: The rendered template, including layout, if appropriate.
|
27
|
+
#
|
28
|
+
# ==== Raises
|
29
|
+
# TemplateNotFound::
|
30
|
+
# There is no template for the specified location.
|
31
|
+
#
|
32
|
+
# ==== Alternatives
|
33
|
+
# If you pass a Hash as the first parameter, it will be moved to
|
34
|
+
# opts and “thing” will be the current action
|
35
|
+
#
|
36
|
+
#—
|
37
|
+
# @public
|
38
|
+
def render(thing = nil, opts = {})
|
39
|
+
<snip>
|
40
|
+
end
|
data/docs/new_render_api
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
## TEMPLATES
|
2
|
+
|
3
|
+
# Render an action
|
4
|
+
render :symbol
|
5
|
+
|
6
|
+
# Render a string
|
7
|
+
render "string"
|
8
|
+
|
9
|
+
# Render an object; will call to_#{content-type} on this if the default template is not found
|
10
|
+
display @obj
|
11
|
+
|
12
|
+
# Provide an alternative default thing to render; note that we can use strings here for template paths
|
13
|
+
# because strings would never fail and fallback to the @obj
|
14
|
+
display @obj, :symbol
|
15
|
+
display @obj, "full/path/to/template"
|
16
|
+
|
17
|
+
# Render a template
|
18
|
+
render_template "full/path/to/template"
|
19
|
+
|
20
|
+
# Render with a mime-type (same as render, but with added mime-type set)
|
21
|
+
render_json :symbol
|
22
|
+
render_json "string"
|
23
|
+
|
24
|
+
# Render nothing at all
|
25
|
+
render_nothing
|
26
|
+
|
27
|
+
# TEMPLATE OPTIONS (all functions above can use these options)
|
28
|
+
|
29
|
+
# :format can be used to override the mime-type arrived at via content-negotiation
|
30
|
+
render :symbol, :format => :xml
|
31
|
+
|
32
|
+
# :status can set the status that will be returned to the browser
|
33
|
+
render :symbol, :status => Successful::Accepted
|
34
|
+
# or
|
35
|
+
render :symbol, :status => 202
|
36
|
+
|
37
|
+
# :layout sets the layout to use; default: controller.to_path || :application; :none means no layout
|
38
|
+
render :symbol, :layout => :none
|
39
|
+
|
40
|
+
## PARTIALS
|
41
|
+
|
42
|
+
# Render a partial
|
43
|
+
partial :symbol
|
44
|
+
|
45
|
+
# Render a partial with an object (it will default to the local var "symbol" in the partial)
|
46
|
+
partial :symbol, :with => @object
|
47
|
+
partial :symbol, :with => @object, :as => "something"
|
48
|
+
|
49
|
+
# Render a partial with a collection of objects (same :as semantics)
|
50
|
+
partial :symbol, :with => [col, lec, tion]
|
51
|
+
partial :symbol, :with => [col, lec, tion], :as => "name"
|