wycats-merb-core 0.9.8 → 0.9.9
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/CHANGELOG +136 -2
- data/CONTRIBUTORS +6 -0
- data/PUBLIC_CHANGELOG +15 -0
- data/Rakefile +12 -14
- data/lib/merb-core.rb +82 -43
- data/lib/merb-core/bootloader.rb +268 -60
- data/lib/merb-core/config.rb +119 -34
- data/lib/merb-core/controller/abstract_controller.rb +58 -18
- data/lib/merb-core/controller/exceptions.rb +2 -15
- data/lib/merb-core/controller/merb_controller.rb +28 -1
- data/lib/merb-core/controller/mime.rb +4 -0
- data/lib/merb-core/controller/mixins/controller.rb +14 -17
- data/lib/merb-core/controller/mixins/render.rb +23 -28
- data/lib/merb-core/controller/mixins/responder.rb +0 -1
- data/lib/merb-core/controller/template.rb +44 -20
- data/lib/merb-core/core_ext/kernel.rb +8 -3
- data/lib/merb-core/dispatch/default_exception/default_exception.rb +1 -1
- data/lib/merb-core/dispatch/default_exception/views/_css.html.erb +3 -1
- data/lib/merb-core/dispatch/default_exception/views/_javascript.html.erb +71 -67
- data/lib/merb-core/dispatch/default_exception/views/index.html.erb +6 -2
- data/lib/merb-core/dispatch/dispatcher.rb +5 -9
- data/lib/merb-core/dispatch/request.rb +46 -57
- data/lib/merb-core/dispatch/router.rb +83 -6
- data/lib/merb-core/dispatch/router/behavior.rb +87 -27
- data/lib/merb-core/dispatch/router/resources.rb +281 -167
- data/lib/merb-core/dispatch/router/route.rb +141 -27
- data/lib/merb-core/logger.rb +213 -202
- data/lib/merb-core/rack.rb +3 -1
- data/lib/merb-core/rack/adapter.rb +7 -4
- data/lib/merb-core/rack/adapter/ebb.rb +12 -13
- data/lib/merb-core/rack/adapter/evented_mongrel.rb +2 -15
- data/lib/merb-core/rack/adapter/irb.rb +3 -2
- data/lib/merb-core/rack/adapter/mongrel.rb +22 -15
- data/lib/merb-core/rack/adapter/swiftiplied_mongrel.rb +4 -16
- data/lib/merb-core/rack/adapter/thin.rb +21 -22
- data/lib/merb-core/rack/adapter/thin_turbo.rb +4 -11
- data/lib/merb-core/rack/adapter/webrick.rb +54 -18
- data/lib/merb-core/rack/handler/mongrel.rb +12 -13
- data/lib/merb-core/rack/middleware/csrf.rb +1 -1
- data/lib/merb-core/server.rb +135 -98
- data/lib/merb-core/tasks/gem_management.rb +50 -12
- data/lib/merb-core/tasks/merb.rb +1 -0
- data/lib/merb-core/tasks/merb_rake_helper.rb +9 -38
- data/lib/merb-core/tasks/stats.rake +2 -2
- data/lib/merb-core/test.rb +9 -3
- data/lib/merb-core/test/helpers.rb +1 -0
- data/lib/merb-core/test/helpers/multipart_request_helper.rb +3 -2
- data/lib/merb-core/test/helpers/request_helper.rb +40 -372
- data/lib/merb-core/test/helpers/route_helper.rb +15 -7
- data/lib/merb-core/test/matchers.rb +1 -0
- data/lib/merb-core/test/matchers/controller_matchers.rb +4 -247
- data/lib/merb-core/test/matchers/view_matchers.rb +22 -4
- data/lib/merb-core/test/run_specs.rb +117 -25
- data/lib/merb-core/version.rb +1 -1
- metadata +1 -1
- data/lib/merb-core/vendor/facets.rb +0 -2
- data/lib/merb-core/vendor/facets/dictionary.rb +0 -433
- data/lib/merb-core/vendor/facets/inflect.rb +0 -342
data/CHANGELOG
CHANGED
@@ -1,4 +1,138 @@
|
|
1
|
-
== 0.9.
|
1
|
+
== 0.9.8 "Time Machine" 2008-06-10
|
2
|
+
|
3
|
+
* Pre-release contributors file update.
|
4
|
+
* Nillify Merb.logger first.
|
5
|
+
* Legacy Merb apps log again. And Merb tells you where it logs on boot unless you are testing.
|
6
|
+
* Fixes up RSpec matcher for request helper
|
7
|
+
* remove vestigal @_template_stack variable.
|
8
|
+
* remove rogure require no longer needed
|
9
|
+
* compile templates with preambles to assign locals, support recompiling partial templates if previously unseen locals are provided
|
10
|
+
* Add a note on Dictionary and inflection code to public changelog.
|
11
|
+
* Nuke files that are already part of Extlib.
|
12
|
+
* Update public changelog.
|
13
|
+
* Fixed Merb::BootLoader::Router issue
|
14
|
+
* -core now depends on most recent Extlib
|
15
|
+
* Revert "Added MinimalPrivilege to merb.thor. Thanks namelessjon."
|
16
|
+
* Fixed stats.rake to check if directory exists
|
17
|
+
* Move inflection code and Dictionary to extlib.
|
18
|
+
* Rakefiles should be empty by default (so RSpec is not pushed down test unit users' throat).
|
19
|
+
* Added MinimalPrivilege to merb.thor. Thanks namelessjon.
|
20
|
+
* Added Merb::BootLoader::Router
|
21
|
+
* Improve public specs for logger. Use Mash for log levels.
|
22
|
+
* Untabify logger.rb.
|
23
|
+
* Allow Merb.disable(:signals) to keep Merb from installing any signal handlers.
|
24
|
+
* Added the ability to specify resource actions in the block
|
25
|
+
* Fixed bug where subgems (of meta-gems) weren't reinstalled each time
|
26
|
+
* Added process title reporting as per: LH #517
|
27
|
+
* Making the :key a synonym to :keys for Behavior#resource
|
28
|
+
* Fixing the rspec error when running rake tasks
|
29
|
+
* Cleaned up the specs. Removed any stray pending specs.
|
30
|
+
* Added stacking and redirecting deferred routing blocks.
|
31
|
+
* Removed private/dispatch/route_params_spec.rb
|
32
|
+
* New spec helpers ported over. Old #request helper becomes #mock_request, which uses some mocking and stubbing to set up the request. The new #request API uses no mocking, and has the following API changes:
|
33
|
+
* Removed spec/private/config
|
34
|
+
* Added dependency 'foo', :immediate => true for loading dependencies immediately
|
35
|
+
* call to_s in the csrf middlewre
|
36
|
+
* make StreamWrapper more duck typed to the old body string.
|
37
|
+
* If --log-level or --log is explicitly given, never log to STDOUT, alsways to file
|
38
|
+
* If Merb.env?(:test) we don't need ugly = true spread all over the place
|
39
|
+
* use Proc === @body instead
|
40
|
+
* Bring the console adapter's #url back into action
|
41
|
+
* update specs for new rack stream_wrapper
|
42
|
+
* Updating streaming methods to work on *all* rack adapters.
|
43
|
+
* Make Merb::Config[]= work without calling setup 1st
|
44
|
+
* Default to = 'UTF8' - you can just set this in init.rb if needed
|
45
|
+
* Colorful GemManagement
|
46
|
+
* Removed unused directory under spec.
|
47
|
+
* Reorganized URL generation methods across Controller classes
|
48
|
+
* Added a :singular option to resource route building
|
49
|
+
* merb -k works right
|
50
|
+
* Fixes stupid issue in spec loader
|
51
|
+
* Route matching handles slashes according to the RFC
|
52
|
+
* Added the #resource controller helper for URL generation.
|
53
|
+
* Fixes #503; raise InternalServerError works now.
|
54
|
+
* We shouldn't use minigems explicitly in our code (yet)
|
55
|
+
* Add missing pieces of forking awesomeness.
|
56
|
+
* Executable wrappers use /usr/bin/env again - run them with /path/to/ruby -S if you need a specific Ruby version
|
57
|
+
* Merge in forking branch.
|
58
|
+
* Use trenary operator here.
|
59
|
+
* capture returns return value of passed in block if it is not a template block
|
60
|
+
* Updated PUBLIC_CHANGELOG regarding Merb::RakeHelper
|
61
|
+
* reverts URI generation on requests
|
62
|
+
* Updates full_uri for the changes to the Request#protocol
|
63
|
+
* Reorganized merb-core/tasks/merb to require merb-core/tasks/merb_rake_helper (see merb-gen too)
|
64
|
+
* Cleanup of tasks/merb_rake_helper.rb
|
65
|
+
* Added :gemspec task to Rakefile
|
66
|
+
* Fixed executable wrapper code (for loading local gems)
|
67
|
+
* Added Merb::RakeHelper.install_package method to install packages directly
|
68
|
+
* Merb::RakeHelper now handles local ./bin and GEM_DIR installs correctly
|
69
|
+
* Rakefile now uses Merb::RakeHelper.install
|
70
|
+
* Added GemManagement module - working towards new install/uninstall rake tasks
|
71
|
+
* Removed Merb::BootLoader::ReloadTemplates; Merb::Config[:reload_templates] needs to be set explicitly
|
72
|
+
* Marked Kernel#track_dependency as @api private - updated specs to reflect this
|
73
|
+
* Added warning when specs are run without memcached being available
|
74
|
+
* Refactored Kernel#dependency and #load_dependency to work with Gem::Dependency
|
75
|
+
* Include request uri in routing exception raised by request helpers.
|
76
|
+
* Added require 'thread' explicitly for Mutex to be available
|
77
|
+
* Revert "Initial support for fast redeploys and code reloading via forks."
|
78
|
+
* Revert "Split out the code transaction into a method and do some experimentation with cluster forking."
|
79
|
+
* Revert "Better exit message"
|
80
|
+
* Revert "Initial experiments are a success. TODO: Move the logic out of mongrel and make a proper clustering instead of hardcoding to 4"
|
81
|
+
* Fixes issue people were having
|
82
|
+
* Initial experiments are a success. TODO: Move the logic out of mongrel and make a proper clustering instead of hardcoding to 4
|
83
|
+
* Split out the code transaction into a method and do some experimentation with cluster forking.
|
84
|
+
* Better exit message
|
85
|
+
* Initial support for fast redeploys and code reloading via forks.
|
86
|
+
* Fixed that YAML plugin configuratator wasn't requiring YAML.
|
87
|
+
* Reindent core_ext/kernel.rb.
|
88
|
+
* Register dependencies even after the BootLoader has finished
|
89
|
+
* Fixes Merb::Request#protocol to remove the ://. May Break things in apps if you're checking protocol directly.
|
90
|
+
* Moves actual url generation methods onto the request object from the controller.
|
91
|
+
Also updates the Merb::Request#redirect method to be usable just like the controller version.
|
92
|
+
* Throw the correct error when generating a non existent route.
|
93
|
+
* Modify throw_content to not append. Add append_content for that purpose.
|
94
|
+
* Significant router refactoring and feature development
|
95
|
+
* Run specs in groups
|
96
|
+
* Added more discriptive message when a class fails to load
|
97
|
+
* Optimized Merb::Request.query_parse - fixed silly spec
|
98
|
+
* Update Rack application spec to reflect current affairs.
|
99
|
+
* Document template_for.
|
100
|
+
* Make merb fast again. Also make rake install work from any Ruby via -S
|
101
|
+
* ControllerMixin#html_escape => #escape_html (bring it in line with #escape_xml).
|
102
|
+
* Protected makes no sense for class methods.
|
103
|
+
* Remove dead code from responder.
|
104
|
+
* Adds abstract! and abstract? for controller classes for your inheritance pleasure
|
105
|
+
* Server#add_irb_trap should play nice with ruby-debugger.
|
106
|
+
* Reworked the Server#add_irb_trap to suppress the warnings.
|
107
|
+
* added flag for an IRB trap
|
108
|
+
* Add links to nginx_send_file examples: gist and app at GitHub.
|
109
|
+
* Untabify fixture controller for streaming.
|
110
|
+
* Make Merb::Controller#nginx_send_file more user friendly.
|
111
|
+
* More fine-grained check to see if a local ./bin executable should have been used
|
112
|
+
* Ignore products RDoc generates.
|
113
|
+
* Include RDoc in the gem.
|
114
|
+
* Ignore RDoc template cache.
|
115
|
+
* Remove RDoc template cache from version control.
|
116
|
+
* Session cookies now expire at the end of a browser session again (instead of 2 weeks)
|
117
|
+
* Second attempt: fixed load_dependency (hopefully)
|
118
|
+
* Fixed failing spec regarding 'dependency' change
|
119
|
+
* Make flat! more useful
|
120
|
+
* This rescue is obsolete and is obscuring useful failing information, as well as loading
|
121
|
+
from the system even when you require a specific version that isn't available in the bundled gems.
|
122
|
+
* Clean before installation. Remove *.so and *.log under spec.
|
123
|
+
* Make gem 3 times lighter.
|
124
|
+
* Merb::Release is gone.
|
125
|
+
* Bump up version
|
126
|
+
* Set @_content_type before running transform blocks
|
127
|
+
* sneaky merge failure piece that shouldn't be here
|
128
|
+
* Revert "Add specs for action-level only_provides"
|
129
|
+
* Revert "add specs for does_not_provide"
|
130
|
+
* add specs for does_not_provide
|
131
|
+
* Add specs for action-level only_provides
|
132
|
+
* Make controller.route work
|
133
|
+
|
134
|
+
|
135
|
+
== 0.9.7 "Universe In A Bundle" 2008-13-09
|
2
136
|
|
3
137
|
* Made the post body available to the routing when testing a request.
|
4
138
|
* Better local gems dir detection and end-user feedback
|
@@ -30,7 +164,7 @@
|
|
30
164
|
* Meaninful message when have_xpath matcher is used but libxml-ruby fails to load.
|
31
165
|
* Don't blow up when there are no system paths.
|
32
166
|
|
33
|
-
== 0.9.6 "Therapy session" 2008-09
|
167
|
+
== 0.9.6 "Therapy session" 2008-08-09
|
34
168
|
|
35
169
|
* Merge in simple conditional get support at controller level.
|
36
170
|
* Merged in new bundling (aka freezer) branch
|
data/CONTRIBUTORS
CHANGED
@@ -22,10 +22,12 @@ Daniel Siemssen
|
|
22
22
|
David James
|
23
23
|
Diego Scataglini
|
24
24
|
Dirkjan Bussink
|
25
|
+
Drew Colthorp
|
25
26
|
Dudley Flanders
|
26
27
|
Ezra Zygmuntowicz
|
27
28
|
Fabien Franzen
|
28
29
|
Flea
|
30
|
+
Foy Savas
|
29
31
|
Gabe
|
30
32
|
Geoffrey Grosenbach
|
31
33
|
Goh Toh Chye
|
@@ -57,6 +59,7 @@ Max Lapshin
|
|
57
59
|
Michael D'Auria
|
58
60
|
Michael D. Ivey
|
59
61
|
Michael Holub
|
62
|
+
Michael Klishin
|
60
63
|
Michael Latta
|
61
64
|
Michael S. Klishin
|
62
65
|
Michael Sheakoski
|
@@ -77,6 +80,8 @@ StarTrader
|
|
77
80
|
Steve Tooke
|
78
81
|
Thomas Reynolds
|
79
82
|
Tim Kofol
|
83
|
+
Tyler Hunt
|
84
|
+
Tymon (teamon) Tobolski
|
80
85
|
Wayne E. Seguin
|
81
86
|
Wayne Larsen
|
82
87
|
Wesley Beary
|
@@ -90,5 +95,6 @@ jonas
|
|
90
95
|
jonuts
|
91
96
|
macournoyer
|
92
97
|
mde
|
98
|
+
michael.s.klishin@gmail.com
|
93
99
|
rick
|
94
100
|
wvl
|
data/PUBLIC_CHANGELOG
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
10/06/2008:
|
2
|
+
|
3
|
+
* Use -L option or :log_file or :log_stream in init.rb or env init file
|
4
|
+
to point logger where you want.
|
5
|
+
|
6
|
+
10/05/2008:
|
7
|
+
* Merb does not add spec tasks to Rakefiles list by default. Add
|
8
|
+
require "merb-core/test/tasks/spectasks" in your existing Rakefiles
|
9
|
+
explicitly. This is done so that test unit users do not get spec
|
10
|
+
tasks they do not need down their throat in any merb application,
|
11
|
+
even running on just -core.
|
12
|
+
|
13
|
+
* Dictionary and inflection code are now parts of Extlib library and shared
|
14
|
+
with other frameworks that use it (DataMapper, Halcyon, Mack, etc).
|
15
|
+
|
1
16
|
9/26/2008:
|
2
17
|
* For Merb developers, Rakefile features a new implementation of the :install
|
3
18
|
and :uninstall tasks. These will work with Gems directly, without running
|
data/Rakefile
CHANGED
@@ -17,7 +17,6 @@ require __DIR__ + "/tools/annotation_extract"
|
|
17
17
|
include FileUtils
|
18
18
|
|
19
19
|
require "lib/merb-core/version"
|
20
|
-
require "lib/merb-core/test/run_specs"
|
21
20
|
require 'lib/merb-core/tasks/merb_rake_helper'
|
22
21
|
|
23
22
|
##############################################################################
|
@@ -58,7 +57,7 @@ spec = Gem::Specification.new do |s|
|
|
58
57
|
s.extra_rdoc_files = %w( README LICENSE TODO )
|
59
58
|
|
60
59
|
# Dependencies
|
61
|
-
s.add_dependency "extlib", ">= 0.9.
|
60
|
+
s.add_dependency "extlib", ">= 0.9.7"
|
62
61
|
s.add_dependency "erubis"
|
63
62
|
s.add_dependency "rake"
|
64
63
|
s.add_dependency "json_pure"
|
@@ -169,7 +168,7 @@ namespace :doc do
|
|
169
168
|
|
170
169
|
desc "rdoc to rubyforge"
|
171
170
|
task :rubyforge do
|
172
|
-
sh %{#{sudo} chmod -R 755 doc} unless windows?
|
171
|
+
sh %{#{Merb::RakeHelper.sudo} chmod -R 755 doc} unless Merb::RakeHelper.windows?
|
173
172
|
sh %{/usr/bin/scp -r -p doc/rdoc/* ezmobius@rubyforge.org:/var/www/gforge-projects/merb}
|
174
173
|
end
|
175
174
|
|
@@ -184,47 +183,46 @@ task :aok => [:specs, :rcov]
|
|
184
183
|
def setup_specs(name, spec_cmd='spec', run_opts = "-c")
|
185
184
|
except = []
|
186
185
|
except += Dir["spec/**/memcache*_spec.rb"] if ENV['MEMCACHED'] == 'no'
|
187
|
-
|
188
|
-
public_globs = ["abstract_controller", "boot_loader",
|
189
|
-
"controller/*_spec.rb", "core",
|
190
|
-
"core_ext", "directory_structure", "logger", "rack/*_spec.rb", "reloading",
|
191
|
-
"request", "router/*_spec.rb", "session/*_spec.rb", "template", "test"].map do |glob|
|
192
|
-
"spec/public/#{glob}"
|
193
|
-
end
|
194
186
|
|
195
|
-
|
196
|
-
|
197
|
-
|
187
|
+
public_globs = Dir["#{Dir.pwd}/spec/public/**/*_spec.rb"]
|
188
|
+
|
189
|
+
private_globs = Dir["#{Dir.pwd}/spec/private/**/*_spec.rb"]
|
198
190
|
|
199
191
|
desc "Run all specs (#{name})"
|
200
192
|
task "specs:#{name}" do
|
193
|
+
require "lib/merb-core/test/run_specs"
|
201
194
|
globs = public_globs + private_globs
|
202
195
|
run_specs(globs, spec_cmd, ENV['RSPEC_OPTS'] || run_opts, except)
|
203
196
|
end
|
204
197
|
|
205
198
|
desc "Run private specs (#{name})"
|
206
199
|
task "specs:#{name}:private" do
|
200
|
+
require "lib/merb-core/test/run_specs"
|
207
201
|
run_specs(private_globs, spec_cmd, ENV['RSPEC_OPTS'] || run_opts)
|
208
202
|
end
|
209
203
|
|
210
204
|
desc "Run public specs (#{name})"
|
211
205
|
task "specs:#{name}:public" do
|
206
|
+
require "lib/merb-core/test/run_specs"
|
212
207
|
run_specs(public_globs, spec_cmd, ENV['RSPEC_OPTS'] || run_opts)
|
213
208
|
end
|
214
209
|
|
215
210
|
# With profiling formatter
|
216
211
|
desc "Run all specs (#{name}) with profiling formatter"
|
217
212
|
task "specs:#{name}_profiled" do
|
213
|
+
require "lib/merb-core/test/run_specs"
|
218
214
|
run_specs("spec/**/*_spec.rb", spec_cmd, "-c -f o")
|
219
215
|
end
|
220
216
|
|
221
217
|
desc "Run private specs (#{name}) with profiling formatter"
|
222
218
|
task "specs:#{name}_profiled:private" do
|
219
|
+
require "lib/merb-core/test/run_specs"
|
223
220
|
run_specs("spec/private/**/*_spec.rb", spec_cmd, "-c -f o")
|
224
221
|
end
|
225
222
|
|
226
223
|
desc "Run public specs (#{name}) with profiling formatter"
|
227
224
|
task "specs:#{name}_profiled:public" do
|
225
|
+
require "lib/merb-core/test/run_specs"
|
228
226
|
run_specs("spec/public/**/*_spec.rb", spec_cmd, "-c -f o")
|
229
227
|
end
|
230
228
|
end
|
@@ -338,7 +336,7 @@ def contributors(since_release = nil)
|
|
338
336
|
git_log(since_release).split("\n").uniq.sort
|
339
337
|
end
|
340
338
|
|
341
|
-
PREVIOUS_RELEASE = '0.9.
|
339
|
+
PREVIOUS_RELEASE = '0.9.8'
|
342
340
|
namespace :history do
|
343
341
|
namespace :update do
|
344
342
|
desc "updates contributors list"
|
data/lib/merb-core.rb
CHANGED
@@ -22,6 +22,7 @@ require 'fileutils'
|
|
22
22
|
require 'socket'
|
23
23
|
require 'pathname'
|
24
24
|
require "extlib"
|
25
|
+
require "extlib/dictionary"
|
25
26
|
|
26
27
|
__DIR__ = File.dirname(__FILE__)
|
27
28
|
|
@@ -29,13 +30,12 @@ $LOAD_PATH.unshift __DIR__ unless
|
|
29
30
|
$LOAD_PATH.include?(__DIR__) ||
|
30
31
|
$LOAD_PATH.include?(File.expand_path(__DIR__))
|
31
32
|
|
32
|
-
require 'merb-core' / 'vendor' / 'facets'
|
33
|
-
|
34
33
|
module Merb
|
35
34
|
# Create stub module for global controller helpers.
|
36
35
|
module GlobalHelpers; end
|
37
36
|
|
38
37
|
class << self
|
38
|
+
attr_accessor :exiting
|
39
39
|
|
40
40
|
# Merge environment settings
|
41
41
|
# Can allow you to have a "localdev" that runs like your "development"
|
@@ -47,8 +47,9 @@ module Merb
|
|
47
47
|
# staging.rb:
|
48
48
|
# Merb.merge_env "production" #We want to use all the settings production uses
|
49
49
|
# Merb::Config.use { |c|
|
50
|
-
# c[:log_level] = "debug" #except we want debug log level
|
51
|
-
# c[:
|
50
|
+
# c[:log_level] = "debug" # except we want debug log level
|
51
|
+
# c[:log_stream] = @some_io # and log to this IO handle
|
52
|
+
# c[:exception_details] = true # and we want to see exception details
|
52
53
|
# }
|
53
54
|
#
|
54
55
|
# ==== Parameters
|
@@ -85,7 +86,6 @@ module Merb
|
|
85
86
|
end
|
86
87
|
end
|
87
88
|
|
88
|
-
|
89
89
|
# Startup Merb by setting up the Config and starting the server.
|
90
90
|
# This is where Merb application environment and root path are set.
|
91
91
|
#
|
@@ -93,18 +93,24 @@ module Merb
|
|
93
93
|
# argv<String, Hash>::
|
94
94
|
# The config arguments to start Merb with. Defaults to +ARGV+.
|
95
95
|
def start(argv=ARGV)
|
96
|
+
# Hardcode the log stream to STDOUT
|
97
|
+
Merb::Config[:log_stream] = STDOUT
|
96
98
|
if Hash === argv
|
97
99
|
Merb::Config.setup(argv)
|
98
100
|
else
|
99
101
|
Merb::Config.parse_args(argv)
|
100
102
|
end
|
103
|
+
Merb::Config[:log_stream] = STDOUT
|
104
|
+
|
101
105
|
Merb.environment = Merb::Config[:environment]
|
102
106
|
Merb.root = Merb::Config[:merb_root]
|
103
107
|
case Merb::Config[:action]
|
104
108
|
when :kill
|
105
|
-
Merb::Server.kill(Merb::Config[:port],
|
109
|
+
Merb::Server.kill(Merb::Config[:port], 2)
|
106
110
|
when :kill_9
|
107
111
|
Merb::Server.kill(Merb::Config[:port], 9)
|
112
|
+
when :fast_deploy
|
113
|
+
Merb::Server.kill("main", "HUP")
|
108
114
|
else
|
109
115
|
Merb::Server.start(Merb::Config[:port], Merb::Config[:cluster])
|
110
116
|
end
|
@@ -263,21 +269,43 @@ module Merb
|
|
263
269
|
end
|
264
270
|
|
265
271
|
# Logger settings
|
266
|
-
|
272
|
+
def logger
|
273
|
+
Thread.current[:merb_logger] ||= Merb::Logger.new
|
274
|
+
end
|
275
|
+
|
276
|
+
def logger=(obj)
|
277
|
+
unless obj
|
278
|
+
Thread.current[:merb_logger] = nil
|
279
|
+
end
|
280
|
+
end
|
267
281
|
|
268
282
|
# ==== Returns
|
269
283
|
# String::
|
270
284
|
# The path to the log file. If this Merb instance is running as a daemon
|
271
285
|
# this will return +STDOUT+.
|
272
|
-
def
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
286
|
+
def log_stream(port = "main")
|
287
|
+
@streams ||= {}
|
288
|
+
@streams[port] ||= begin
|
289
|
+
log = if Merb.testing?
|
290
|
+
log_path / "merb_test.log"
|
291
|
+
elsif !Merb::Config[:daemonize] && !Merb::Config[:force_logging]
|
292
|
+
STDOUT
|
293
|
+
else
|
294
|
+
log_path / "merb.#{port}.log"
|
295
|
+
end
|
296
|
+
|
297
|
+
if log.is_a?(IO)
|
298
|
+
stream = log
|
299
|
+
elsif File.exist?(log)
|
300
|
+
stream = File.open(log, (File::WRONLY | File::APPEND))
|
301
|
+
else
|
302
|
+
FileUtils.mkdir_p(File.dirname(log))
|
303
|
+
stream = File.open(log, (File::WRONLY | File::APPEND | File::CREAT))
|
304
|
+
stream.write("#{Time.now.httpdate} #{Merb::Config[:log_delimiter]} " \
|
305
|
+
"info #{Merb::Config[:log_delimiter]} Logfile created\n")
|
306
|
+
end
|
307
|
+
stream.sync = true
|
308
|
+
stream
|
281
309
|
end
|
282
310
|
end
|
283
311
|
|
@@ -314,26 +342,26 @@ module Merb
|
|
314
342
|
end
|
315
343
|
end
|
316
344
|
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
}
|
330
|
-
|
331
|
-
Merb::Config[:framework] = default.merge(framework)
|
332
|
-
|
333
|
-
Merb::Router.prepare do |r|
|
334
|
-
yield(r) if block_given?
|
335
|
-
r.default_routes
|
345
|
+
def fatal!(str, e = nil)
|
346
|
+
Merb.logger.fatal!
|
347
|
+
Merb.logger.fatal!("\e[1;31;47mFATAL: #{str}\e[0m")
|
348
|
+
Merb.logger.fatal!
|
349
|
+
|
350
|
+
print_colorized_backtrace(e) if e && Merb::Config[:verbose]
|
351
|
+
exit(1)
|
352
|
+
end
|
353
|
+
|
354
|
+
def print_colorized_backtrace(e)
|
355
|
+
e.backtrace.map! do |line|
|
356
|
+
line.gsub!(/^#{Merb.framework_root}/, "\e[34mFRAMEWORK_ROOT\e[31m")
|
336
357
|
end
|
358
|
+
|
359
|
+
Merb.logger.fatal! "\e[34mFRAMEWORK_ROOT\e[0m = #{Merb.framework_root}"
|
360
|
+
Merb.logger.fatal!
|
361
|
+
Merb.logger.fatal! "\e[31m#{e.class}: \e[1;31;47m#{e.message}\e[0m"
|
362
|
+
e.backtrace.each do |line|
|
363
|
+
Merb.logger.fatal! "\e[31m#{line}\e[0m"
|
364
|
+
end
|
337
365
|
end
|
338
366
|
|
339
367
|
# Set up default variables under Merb
|
@@ -428,9 +456,11 @@ module Merb
|
|
428
456
|
# flush after new messages are
|
429
457
|
# added, defaults to true.
|
430
458
|
#
|
431
|
-
# :
|
459
|
+
# :log_stream<IO>:: IO handle for logger. Defaults to STDOUT.
|
460
|
+
#
|
461
|
+
# :log_file<String>:: File path for logger. Overrides :log_stream.
|
432
462
|
#
|
433
|
-
# :log_level<Symbol>:: logger level, default is :
|
463
|
+
# :log_level<Symbol>:: logger level, default is :info
|
434
464
|
#
|
435
465
|
# :disabled_components<Array[Symbol]>::
|
436
466
|
# array of disabled component names,
|
@@ -446,7 +476,7 @@ module Merb
|
|
446
476
|
# application start, some of them are set in Merb init file
|
447
477
|
# or environment-specific.
|
448
478
|
def load_config(options = {})
|
449
|
-
Merb::Config.setup(
|
479
|
+
Merb::Config.setup(Merb::Config.defaults.merge(options))
|
450
480
|
Merb::BootLoader::Logger.run
|
451
481
|
end
|
452
482
|
|
@@ -475,7 +505,7 @@ module Merb
|
|
475
505
|
# Boolean:: True if Merb environment is testing for instance,
|
476
506
|
# Merb is running with RSpec, Test::Unit of other testing facility.
|
477
507
|
def testing?
|
478
|
-
$TESTING || Merb::Config[:testing]
|
508
|
+
$TESTING ||= env?(:test) || Merb::Config[:testing]
|
479
509
|
end
|
480
510
|
|
481
511
|
# Ask the question about which environment you're in.
|
@@ -551,7 +581,7 @@ module Merb
|
|
551
581
|
# Recommended way to find out what paths Rakefiles
|
552
582
|
# are loaded from.
|
553
583
|
def rakefiles
|
554
|
-
@rakefiles ||= [
|
584
|
+
@rakefiles ||= []
|
555
585
|
end
|
556
586
|
|
557
587
|
# === Returns
|
@@ -565,12 +595,12 @@ module Merb
|
|
565
595
|
end
|
566
596
|
|
567
597
|
# ==== Parameters
|
568
|
-
# *rakefiles:: Rakefile
|
598
|
+
# *rakefiles:: Rakefile paths to add to the list of Rakefiles.
|
569
599
|
#
|
570
600
|
# ==== Notes
|
571
601
|
# Recommended way to add Rakefiles load path for plugins authors.
|
572
602
|
def add_rakefiles(*rakefiles)
|
573
|
-
@rakefiles ||= [
|
603
|
+
@rakefiles ||= []
|
574
604
|
@rakefiles += rakefiles
|
575
605
|
end
|
576
606
|
|
@@ -584,6 +614,15 @@ module Merb
|
|
584
614
|
@generators += generators
|
585
615
|
end
|
586
616
|
|
617
|
+
# Install a signal handler for a given signal unless signals have
|
618
|
+
# been disabled with Merb.disable(:signals)
|
619
|
+
# ==== Parameters
|
620
|
+
# signal:: The name of the signal to install a handler for.
|
621
|
+
# &block:: The block to be run when the given signal is received.
|
622
|
+
def trap(signal, &block)
|
623
|
+
Kernel.trap(signal, &block) unless Merb.disabled?(:signals)
|
624
|
+
end
|
625
|
+
|
587
626
|
end
|
588
627
|
end
|
589
628
|
|
@@ -595,4 +634,4 @@ require 'merb-core/version'
|
|
595
634
|
require 'merb-core/controller/mime'
|
596
635
|
|
597
636
|
# Set the environment if it hasn't already been set.
|
598
|
-
Merb.environment ||= ENV['MERB_ENV'] || Merb::Config[:environment] || (Merb.testing? ? 'test' : 'development')
|
637
|
+
Merb.environment ||= ENV['MERB_ENV'] || Merb::Config[:environment] || (Merb.testing? ? 'test' : 'development')
|