merb-core 0.9.5 → 0.9.6
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 +925 -0
- data/CONTRIBUTORS +93 -0
- data/PUBLIC_CHANGELOG +85 -0
- data/Rakefile +18 -28
- data/bin/merb +34 -5
- data/lib/merb-core/autoload.rb +2 -3
- data/lib/merb-core/bootloader.rb +60 -66
- data/lib/merb-core/config.rb +7 -1
- data/lib/merb-core/controller/abstract_controller.rb +35 -21
- data/lib/merb-core/controller/merb_controller.rb +15 -42
- data/lib/merb-core/controller/mixins/authentication.rb +42 -6
- data/lib/merb-core/controller/mixins/conditional_get.rb +83 -0
- data/lib/merb-core/controller/mixins/render.rb +3 -3
- data/lib/merb-core/core_ext/kernel.rb +6 -19
- data/lib/merb-core/dispatch/cookies.rb +96 -80
- data/lib/merb-core/dispatch/default_exception/views/index.html.erb +2 -0
- data/lib/merb-core/dispatch/request.rb +18 -16
- data/lib/merb-core/dispatch/router/route.rb +6 -0
- data/lib/merb-core/dispatch/router.rb +4 -1
- data/lib/merb-core/dispatch/session/container.rb +64 -0
- data/lib/merb-core/dispatch/session/cookie.rb +91 -101
- data/lib/merb-core/dispatch/session/memcached.rb +38 -174
- data/lib/merb-core/dispatch/session/memory.rb +62 -208
- data/lib/merb-core/dispatch/session/store_container.rb +145 -0
- data/lib/merb-core/dispatch/session.rb +174 -48
- data/lib/merb-core/rack/middleware/conditional_get.rb +14 -8
- data/lib/merb-core/rack/middleware/csrf.rb +73 -0
- data/lib/merb-core/rack.rb +1 -0
- data/lib/merb-core/script.rb +112 -0
- data/lib/merb-core/server.rb +2 -0
- data/lib/merb-core/tasks/merb_rake_helper.rb +25 -0
- data/lib/merb-core/test/helpers/request_helper.rb +40 -3
- data/lib/merb-core/test/run_specs.rb +4 -3
- data/lib/merb-core/vendor/facets/inflect.rb +7 -10
- data/lib/merb-core/version.rb +1 -1
- data/lib/merb-core.rb +11 -40
- data/spec/private/core_ext/kernel_spec.rb +0 -11
- data/spec/private/dispatch/fixture/log/merb_test.log +893 -0
- data/spec/private/router/fixture/log/merb_test.log +12 -1728
- data/spec/private/router/route_spec.rb +4 -0
- data/spec/private/router/router_spec.rb +8 -0
- data/spec/private/vendor/facets/plural_spec.rb +1 -1
- data/spec/private/vendor/facets/singular_spec.rb +1 -1
- data/spec/public/abstract_controller/controllers/display.rb +8 -2
- data/spec/public/abstract_controller/controllers/filters.rb +18 -0
- data/spec/public/abstract_controller/display_spec.rb +6 -2
- data/spec/public/abstract_controller/filter_spec.rb +4 -0
- data/spec/public/controller/authentication_spec.rb +114 -43
- data/spec/public/controller/base_spec.rb +8 -0
- data/spec/public/controller/conditional_get_spec.rb +100 -0
- data/spec/public/controller/config/init.rb +1 -1
- data/spec/public/controller/controllers/authentication.rb +29 -0
- data/spec/public/controller/controllers/base.rb +13 -0
- data/spec/public/controller/controllers/conditional_get.rb +35 -0
- data/spec/public/controller/controllers/cookies.rb +10 -1
- data/spec/public/controller/cookies_spec.rb +38 -9
- data/spec/public/controller/spec_helper.rb +1 -0
- data/spec/public/controller/url_spec.rb +70 -1
- data/spec/public/directory_structure/directory/log/merb_test.log +461 -0
- data/spec/public/rack/conditinal_get_middleware_spec.rb +77 -89
- data/spec/public/rack/csrf_middleware_spec.rb +70 -0
- data/spec/public/reloading/directory/log/merb_test.log +52 -0
- data/spec/public/request/request_spec.rb +19 -1
- data/spec/public/router/fixation_spec.rb +26 -4
- data/spec/public/router/fixture/log/merb_test.log +234 -30332
- data/spec/public/session/controllers/sessions.rb +52 -0
- data/spec/public/session/cookie_session_spec.rb +73 -0
- data/spec/public/session/memcached_session_spec.rb +31 -0
- data/spec/public/session/memory_session_spec.rb +28 -0
- data/spec/public/session/multiple_sessions_spec.rb +74 -0
- data/spec/public/session/no_session_spec.rb +12 -0
- data/spec/public/session/session_spec.rb +91 -0
- data/spec/public/test/controllers/spec_helper_controller.rb +2 -1
- data/spec/public/test/request_helper_spec.rb +15 -0
- data/spec/spec_helper.rb +2 -2
- metadata +23 -5
- data/spec/private/dispatch/cookies_spec.rb +0 -219
- data/spec/private/dispatch/session_mixin_spec.rb +0 -47
data/CONTRIBUTORS
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
Use merb? Say thanks the following people:
|
2
|
+
|
3
|
+
Aaron Wheeler
|
4
|
+
Abhay Kumar
|
5
|
+
Adam Jacob
|
6
|
+
Andy C
|
7
|
+
Antti Tarvainen
|
8
|
+
Ben Burkert
|
9
|
+
Ben Chiu
|
10
|
+
Ben Griffiths
|
11
|
+
Bradly Feeley
|
12
|
+
Brandon Dimcheff
|
13
|
+
Brian Mitchell
|
14
|
+
Bryan Ray
|
15
|
+
Carl Lerche
|
16
|
+
Charles Jolley
|
17
|
+
Coda Hale
|
18
|
+
Cory ODaniel
|
19
|
+
Daniel Neighman
|
20
|
+
Daniel Schierbeck
|
21
|
+
Daniel Siemssen
|
22
|
+
David James
|
23
|
+
Diego Scataglini
|
24
|
+
Dirkjan Bussink
|
25
|
+
Dudley Flanders
|
26
|
+
Ezra Zygmuntowicz
|
27
|
+
Fabien Franzen
|
28
|
+
Flea
|
29
|
+
Gabe
|
30
|
+
Geoffrey Grosenbach
|
31
|
+
Goh Toh Chye
|
32
|
+
Grant Hollingworth
|
33
|
+
Guillaume Maury
|
34
|
+
Hampton Catlin
|
35
|
+
Ho-Sheng Hsiao
|
36
|
+
Jack Dempsey
|
37
|
+
James Herdman
|
38
|
+
James Whiteman
|
39
|
+
Janne Asmala
|
40
|
+
Jaroslaw Zabiello
|
41
|
+
Jonas Nicklas
|
42
|
+
Jonathan Younger
|
43
|
+
Josh Nichols
|
44
|
+
Kyle Drake
|
45
|
+
Lance Carlson
|
46
|
+
Loren Segal
|
47
|
+
Lori Holden
|
48
|
+
Martin Grund
|
49
|
+
Mason Browne
|
50
|
+
Matt Aimonetti
|
51
|
+
Matt Todd
|
52
|
+
Matthew Ford
|
53
|
+
Matthew Windwer
|
54
|
+
Matthijs Langenberg
|
55
|
+
Max Aller
|
56
|
+
Max Lapshin
|
57
|
+
Michael D'Auria
|
58
|
+
Michael D. Ivey
|
59
|
+
Michael Holub
|
60
|
+
Michael Latta
|
61
|
+
Michael S. Klishin
|
62
|
+
Michael Sheakoski
|
63
|
+
Mirko Froehlich
|
64
|
+
Nathan Weizenbaum
|
65
|
+
Oliver Jakubiec
|
66
|
+
Paul Boone
|
67
|
+
Paul Carey
|
68
|
+
Ray Morgan
|
69
|
+
Rich Cavanaugh
|
70
|
+
Ross Lawley
|
71
|
+
Shalon Wood
|
72
|
+
Shay Arnett
|
73
|
+
Simon Jefford
|
74
|
+
Sindre Aarsaether
|
75
|
+
StarTrader
|
76
|
+
Steve Tooke
|
77
|
+
Thomas Reynolds
|
78
|
+
Tim Kofol
|
79
|
+
Wayne E. Seguin
|
80
|
+
Wayne Larsen
|
81
|
+
Wesley Beary
|
82
|
+
Will Prater
|
83
|
+
William Smith
|
84
|
+
Wilson Bilkovich
|
85
|
+
Yehuda Katz
|
86
|
+
Zach Holt
|
87
|
+
brainopia
|
88
|
+
jonas
|
89
|
+
jonuts
|
90
|
+
macournoyer
|
91
|
+
mde
|
92
|
+
rick
|
93
|
+
wvl
|
data/PUBLIC_CHANGELOG
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
9/5/2008:
|
2
|
+
* Language::English::Inflector is now English::Inflect - be sure to change your
|
3
|
+
custom inflections in config/init.rb. Additionally, the merb-gen template
|
4
|
+
config/init.rb has been changed to document the features accordingly.
|
5
|
+
|
6
|
+
9/2/2008:
|
7
|
+
* AbstractController now uniformly uses instance_eval for Procs where previously
|
8
|
+
the controller instance (self) was passed as an argument:
|
9
|
+
- Procs thrown during dispatch
|
10
|
+
- Procs used as before/after filters
|
11
|
+
- Procs used as conditions to before/after filters
|
12
|
+
|
13
|
+
This means that code like this:
|
14
|
+
|
15
|
+
proc { |c| c.a_controller_method }
|
16
|
+
|
17
|
+
Becomes the following for the cases mentioned:
|
18
|
+
|
19
|
+
proc { a_controller_method }
|
20
|
+
|
21
|
+
8/29/2008:
|
22
|
+
* The directory Merb.root / 'framework' is now gone - framework gems are
|
23
|
+
expected to be installed as local gems in Merb.root / 'gems':
|
24
|
+
sudo gem install merb -i ./gems
|
25
|
+
* The notion of a frozen application setup (using bundled gems) is now known
|
26
|
+
as a bundled setup; Merb.frozen? => Merb.bundled? By default an app uses
|
27
|
+
bundled gems (the -B or --bundle options to merb), to disable this use
|
28
|
+
the option --no-bundle.
|
29
|
+
|
30
|
+
8/27/2008:
|
31
|
+
* Merb::Request#protocol now returns valid protocol names: http, not http://.
|
32
|
+
|
33
|
+
8/22/2008:
|
34
|
+
* controller.cookies['foo'] = { ... } (Hash with options) is now deprecated;
|
35
|
+
use controller.cookies['foo'] = 'bar' for simple cookies without options, or
|
36
|
+
use controller.cookies.set_cookie('foo', 'bar', options) for more control.
|
37
|
+
|
38
|
+
8/21/2008:
|
39
|
+
* Memcached sessions are now configured by assignment to
|
40
|
+
Merb::MemcachedSession.store (previously the CACHE constant was used)
|
41
|
+
* Added Merb::Config[:ignore_tampered_cookies] option to skip cookie warnings
|
42
|
+
during development. This defaults to 'on' in the development environment.
|
43
|
+
* Merb::Config[:session_store] or Merb::Config[:session_stores] now accept an
|
44
|
+
Array (or String); when an Array is given, multiple session stores will be
|
45
|
+
available to the application.
|
46
|
+
* If you have custom session stores (that inherit from Merb::SessionContainer)
|
47
|
+
be sure to require them in your init.rb
|
48
|
+
|
49
|
+
8/20/2008:
|
50
|
+
* Merb::Config[:session_cookie_domain] is now
|
51
|
+
Merb::Config[:default_cookie_domain]
|
52
|
+
* Merb.registered_session_types is now Merb::Request.registered_session_types
|
53
|
+
* When running in :development env, cookie-based sessions won't bother you
|
54
|
+
by raising TamperedWithCookie anymore.
|
55
|
+
|
56
|
+
8/14/2008:
|
57
|
+
* Merb.orm_generator_scope and friends are renamed.
|
58
|
+
** Merb.orm_generator_scope => Merb.orm
|
59
|
+
** Merb.test_framework_generator_scope => Merb.test_framework
|
60
|
+
** Added Merb.template_engine
|
61
|
+
|
62
|
+
Merb-gen is updated accordingly. This let us add --haml and similar
|
63
|
+
options to merb-gen and plugin generators.
|
64
|
+
|
65
|
+
8/10/2008:
|
66
|
+
* Modified the way Exceptions are handled in the Dispatcher
|
67
|
+
** To rescue all exceptions, supply Exceptions#exception
|
68
|
+
** To rescue all Merb-generated exceptions, supply Exceptions#base
|
69
|
+
** Exceptions#internal_server_error is no longer a catch-all and should
|
70
|
+
not be used as such.
|
71
|
+
|
72
|
+
6/22/2008:
|
73
|
+
|
74
|
+
Erubis modified:
|
75
|
+
* <%= %> now can take a block, so <%= helper do %>Hello<% end %> now works
|
76
|
+
* Erubis buffer is now an ivar (@_erb_buf), which eliminates the need for
|
77
|
+
eval in capture helpers.
|
78
|
+
|
79
|
+
CONSEQUENCE:
|
80
|
+
Helpers that take a block should simply return a string, and should not
|
81
|
+
use concat. Example:
|
82
|
+
|
83
|
+
def my_helper(&blk)
|
84
|
+
"My helper says #{capture(&blk)}."
|
85
|
+
end
|
data/Rakefile
CHANGED
@@ -51,15 +51,14 @@ spec = Gem::Specification.new do |s|
|
|
51
51
|
s.description = PROJECT_DESCRIPTION
|
52
52
|
s.executables = %w( merb )
|
53
53
|
s.require_path = "lib"
|
54
|
-
s.files = %w( LICENSE README Rakefile TODO ) + Dir["{docs,bin,spec,lib
|
54
|
+
s.files = %w( LICENSE README Rakefile TODO CHANGELOG PUBLIC_CHANGELOG CONTRIBUTORS ) + Dir["{docs,bin,spec,lib}/**/*"]
|
55
55
|
|
56
56
|
# rdoc
|
57
57
|
s.has_rdoc = true
|
58
58
|
s.extra_rdoc_files = %w( README LICENSE TODO )
|
59
|
-
#s.rdoc_options += RDOC_OPTS + ["--exclude", "^(app|uploads)"]
|
60
59
|
|
61
60
|
# Dependencies
|
62
|
-
s.add_dependency "extlib", ">=0.9.
|
61
|
+
s.add_dependency "extlib", ">= 0.9.5"
|
63
62
|
s.add_dependency "erubis"
|
64
63
|
s.add_dependency "rake"
|
65
64
|
s.add_dependency "json_pure"
|
@@ -80,22 +79,27 @@ end
|
|
80
79
|
|
81
80
|
desc "Run :package and install the resulting .gem"
|
82
81
|
task :install => :package do
|
83
|
-
sh
|
82
|
+
sh install_command(GEM_NAME, GEM_VERSION)
|
84
83
|
end
|
85
84
|
|
86
85
|
desc "Install Merb with development dependencies"
|
87
86
|
task :dev_install => :package do
|
88
|
-
sh
|
87
|
+
sh dev_install_command(GEM_NAME, GEM_VERSION)
|
89
88
|
end
|
90
89
|
|
91
90
|
desc "Run :package and install the resulting .gem with jruby"
|
92
91
|
task :jinstall => :package do
|
93
|
-
sh
|
92
|
+
sh jinstall_command(GEM_NAME, GEM_VERSION)
|
93
|
+
end
|
94
|
+
|
95
|
+
desc "Run :package and install the resulting .gem with jruby (development dependencies)"
|
96
|
+
task :jinstall => :package do
|
97
|
+
sh dev_jinstall_command(GEM_NAME, GEM_VERSION)
|
94
98
|
end
|
95
99
|
|
96
100
|
desc "Run :clean and uninstall the .gem"
|
97
101
|
task :uninstall => :clean do
|
98
|
-
sh
|
102
|
+
sh uninstall_command(GEM_NAME)
|
99
103
|
end
|
100
104
|
|
101
105
|
CLEAN.include ["**/.*.sw?", "pkg", "lib/*.bundle", "*.gem", "doc/rdoc", ".config", "coverage", "cache"]
|
@@ -165,7 +169,6 @@ namespace :doc do
|
|
165
169
|
|
166
170
|
desc "rdoc to rubyforge"
|
167
171
|
task :rubyforge do
|
168
|
-
# sh %{rake doc}
|
169
172
|
sh %{#{sudo} chmod -R 755 doc} unless windows?
|
170
173
|
sh %{/usr/bin/scp -r -p doc/rdoc/* ezmobius@rubyforge.org:/var/www/gforge-projects/merb}
|
171
174
|
end
|
@@ -178,18 +181,14 @@ end
|
|
178
181
|
desc "Run :specs, :rcov"
|
179
182
|
task :aok => [:specs, :rcov]
|
180
183
|
|
181
|
-
# desc "Run all specs"
|
182
|
-
# Spec::Rake::SpecTask.new("specs") do |t|
|
183
|
-
# t.spec_opts = ["--format", "specdoc", "--colour"]
|
184
|
-
# t.spec_files = Dir["spec/**/*_spec.rb"].sort
|
185
|
-
# end
|
186
|
-
|
187
184
|
def setup_specs(name, spec_cmd='spec', run_opts = "-c")
|
188
185
|
desc "Run all specs (#{name})"
|
189
186
|
task "specs:#{name}" do
|
190
|
-
|
187
|
+
except = []
|
188
|
+
except += Dir["spec/**/memcache*_spec.rb"] if ENV['MEMCACHED'] == 'no'
|
189
|
+
run_specs("spec/**/*_spec.rb", spec_cmd, ENV['RSPEC_OPTS'] || run_opts, except)
|
191
190
|
end
|
192
|
-
|
191
|
+
|
193
192
|
desc "Run private specs (#{name})"
|
194
193
|
task "specs:#{name}:private" do
|
195
194
|
run_specs("spec/private/**/*_spec.rb", spec_cmd, ENV['RSPEC_OPTS'] || run_opts)
|
@@ -199,7 +198,7 @@ def setup_specs(name, spec_cmd='spec', run_opts = "-c")
|
|
199
198
|
task "specs:#{name}:public" do
|
200
199
|
run_specs("spec/public/**/*_spec.rb", spec_cmd, ENV['RSPEC_OPTS'] || run_opts)
|
201
200
|
end
|
202
|
-
|
201
|
+
|
203
202
|
# With profiling formatter
|
204
203
|
desc "Run all specs (#{name}) with profiling formatter"
|
205
204
|
task "specs:#{name}_profiled" do
|
@@ -214,7 +213,7 @@ def setup_specs(name, spec_cmd='spec', run_opts = "-c")
|
|
214
213
|
desc "Run public specs (#{name}) with profiling formatter"
|
215
214
|
task "specs:#{name}_profiled:public" do
|
216
215
|
run_specs("spec/public/**/*_spec.rb", spec_cmd, "-c -f o")
|
217
|
-
end
|
216
|
+
end
|
218
217
|
end
|
219
218
|
|
220
219
|
setup_specs("mri", "spec")
|
@@ -255,15 +254,6 @@ Spec::Rake::SpecTask.new("specs_html") do |t|
|
|
255
254
|
t.spec_files = Dir["spec/**/*_spec.rb"].sort
|
256
255
|
end
|
257
256
|
|
258
|
-
# desc "RCov"
|
259
|
-
# Spec::Rake::SpecTask.new("rcov") do |t|
|
260
|
-
# t.rcov_opts = ["--exclude", "gems", "--exclude", "spec"]
|
261
|
-
# t.spec_opts = ["--format", "specdoc", "--colour"]
|
262
|
-
# t.spec_files = Dir["spec/**/*_spec.rb"].sort
|
263
|
-
# t.libs = ["lib", "server/lib"]
|
264
|
-
# t.rcov = true
|
265
|
-
# end
|
266
|
-
|
267
257
|
STATS_DIRECTORIES = [
|
268
258
|
['Code', 'lib/'],
|
269
259
|
['Unit tests', 'spec']
|
@@ -335,7 +325,7 @@ def contributors(since_release = nil)
|
|
335
325
|
git_log(since_release).split("\n").uniq.sort
|
336
326
|
end
|
337
327
|
|
338
|
-
PREVIOUS_RELEASE = '0.9.
|
328
|
+
PREVIOUS_RELEASE = '0.9.5'
|
339
329
|
namespace :history do
|
340
330
|
namespace :update do
|
341
331
|
desc "updates contributors list"
|
data/bin/merb
CHANGED
@@ -1,12 +1,41 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require "merb-core"
|
3
2
|
|
4
|
-
|
5
|
-
ARGV.push "-H"
|
6
|
-
end
|
3
|
+
# See also: merb-gen scripts and script/merb
|
7
4
|
|
5
|
+
# Try to use minigems instead of the fully rubygems library
|
6
|
+
begin
|
7
|
+
require 'minigems'
|
8
|
+
rescue LoadError
|
9
|
+
require 'rubygems'
|
10
|
+
end
|
11
|
+
|
12
|
+
# Load script helpers if available - either local or system-wide.
|
13
|
+
begin
|
14
|
+
# Figure out the merb root - defaults to the current directory.
|
15
|
+
root_key = %w[-m --merb-root].detect { |o| ARGV.index(o) }
|
16
|
+
root = ARGV[ARGV.index(root_key) + 1] if root_key
|
17
|
+
__DIR__ = root.to_a.empty? ? Dir.getwd : root
|
18
|
+
|
19
|
+
# Piggyback on the merb-core rubygem for initial setup scripts.
|
20
|
+
# Requiring it doesn't affect the local gem version of merb-core
|
21
|
+
# we might effectively want to load here after.
|
22
|
+
if merb_core_dir = Dir[File.join(__DIR__, 'gems', 'gems', 'merb-core-*')].last
|
23
|
+
require File.join(merb_core_dir, 'lib', 'merb-core', 'script')
|
24
|
+
else
|
25
|
+
require 'merb-core/script'
|
26
|
+
end
|
27
|
+
# Now setup local gems to be incorporated into the normal loaded gems.
|
28
|
+
# Unless the option --no-bundle is given, bundled gems are enabled.
|
29
|
+
include Merb::ScriptHelpers
|
30
|
+
setup_local_gems!(__DIR__)
|
31
|
+
rescue LoadError
|
32
|
+
end
|
33
|
+
|
34
|
+
require 'merb-core'
|
35
|
+
|
36
|
+
ARGV.push '-H' if ARGV[0] && ARGV[0] =~ /^[^-]/
|
8
37
|
unless %w[-a --adapter -i --irb-console -r --script-runner].any? { |o| ARGV.index(o) }
|
9
38
|
ARGV.push *%w[-a mongrel]
|
10
39
|
end
|
11
40
|
|
12
|
-
Merb.start
|
41
|
+
Merb.start
|
data/lib/merb-core/autoload.rb
CHANGED
@@ -3,9 +3,9 @@ module Merb
|
|
3
3
|
autoload :BootLoader, "merb-core/bootloader"
|
4
4
|
autoload :Config, "merb-core/config"
|
5
5
|
autoload :Const, "merb-core/constants"
|
6
|
+
autoload :ConditionalGetMixin, "merb-core/controller/mixins/conditional_get"
|
6
7
|
autoload :ControllerMixin, "merb-core/controller/mixins/controller"
|
7
8
|
autoload :ControllerExceptions, "merb-core/controller/exceptions"
|
8
|
-
autoload :Cookies, "merb-core/dispatch/cookies"
|
9
9
|
autoload :Dispatcher, "merb-core/dispatch/dispatcher"
|
10
10
|
autoload :AuthenticationMixin, "merb-core/controller/mixins/authentication"
|
11
11
|
autoload :BasicAuthenticationMixin, "merb-core/controller/mixins/authentication/basic"
|
@@ -16,7 +16,6 @@ module Merb
|
|
16
16
|
autoload :Request, "merb-core/dispatch/request"
|
17
17
|
autoload :ResponderMixin, "merb-core/controller/mixins/responder"
|
18
18
|
autoload :Router, "merb-core/dispatch/router"
|
19
|
-
autoload :SessionMixin, "merb-core/dispatch/session"
|
20
19
|
autoload :Test, "merb-core/test"
|
21
20
|
autoload :Worker, "merb-core/dispatch/worker"
|
22
21
|
end
|
@@ -29,4 +28,4 @@ require "merb-core/controller/merb_controller"
|
|
29
28
|
|
30
29
|
module Merb
|
31
30
|
module InlineTemplates; end
|
32
|
-
end
|
31
|
+
end
|
data/lib/merb-core/bootloader.rb
CHANGED
@@ -58,6 +58,7 @@ module Merb
|
|
58
58
|
|
59
59
|
# Runs all boot loader classes by calling their run methods.
|
60
60
|
def run
|
61
|
+
Merb.started = true
|
61
62
|
subklasses = subclasses.dup
|
62
63
|
until subclasses.empty?
|
63
64
|
time = Time.now.to_i
|
@@ -261,7 +262,6 @@ class Merb::BootLoader::Dependencies < Merb::BootLoader
|
|
261
262
|
enable_json_gem unless Merb::disabled?(:json)
|
262
263
|
load_dependencies
|
263
264
|
update_logger
|
264
|
-
update_session_cookie_attributes
|
265
265
|
end
|
266
266
|
|
267
267
|
def self.load_dependencies
|
@@ -279,11 +279,6 @@ class Merb::BootLoader::Dependencies < Merb::BootLoader
|
|
279
279
|
Merb::BootLoader::Logger.run if updated_logger_options != Merb.logger.init_args
|
280
280
|
end
|
281
281
|
|
282
|
-
def self.update_session_cookie_attributes
|
283
|
-
Merb::Controller._session_expiry = Merb::Config[:session_expiry] || Merb::Const::WEEK * 2
|
284
|
-
Merb::Controller._session_cookie_domain = Merb::Config[:session_cookie_domain]
|
285
|
-
end
|
286
|
-
|
287
282
|
private
|
288
283
|
|
289
284
|
# Determines the path for the environment configuration file
|
@@ -318,6 +313,23 @@ class Merb::BootLoader::Dependencies < Merb::BootLoader
|
|
318
313
|
|
319
314
|
end
|
320
315
|
|
316
|
+
class Merb::BootLoader::MixinSession < Merb::BootLoader
|
317
|
+
|
318
|
+
# Mixin the session functionality; this is done before BeforeAppLoads
|
319
|
+
# so that SessionContainer and SessionStoreContainer can be subclassed by
|
320
|
+
# plugin session stores for example - these need to be loaded in a
|
321
|
+
# before_app_loads block or a BootLoader that runs after MixinSession.
|
322
|
+
#
|
323
|
+
# Note: access to Merb::Config is needed, so it needs to run after
|
324
|
+
# Merb::BootLoader::Dependencies is done.
|
325
|
+
def self.run
|
326
|
+
require 'merb-core/dispatch/session'
|
327
|
+
Merb::Controller.send(:include, ::Merb::SessionMixin)
|
328
|
+
Merb::Request.send(:include, ::Merb::SessionMixin::RequestMixin)
|
329
|
+
end
|
330
|
+
|
331
|
+
end
|
332
|
+
|
321
333
|
class Merb::BootLoader::BeforeAppLoads < Merb::BootLoader
|
322
334
|
|
323
335
|
# Call any before_app_loads hooks that were registered via before_app_loads
|
@@ -548,6 +560,48 @@ class Merb::BootLoader::MimeTypes < Merb::BootLoader
|
|
548
560
|
end
|
549
561
|
end
|
550
562
|
|
563
|
+
class Merb::BootLoader::Cookies < Merb::BootLoader
|
564
|
+
|
565
|
+
def self.run
|
566
|
+
require 'merb-core/dispatch/cookies'
|
567
|
+
Merb::Controller.send(:include, Merb::CookiesMixin)
|
568
|
+
Merb::Request.send(:include, Merb::CookiesMixin::RequestMixin)
|
569
|
+
end
|
570
|
+
|
571
|
+
end
|
572
|
+
|
573
|
+
class Merb::BootLoader::SetupSession < Merb::BootLoader
|
574
|
+
|
575
|
+
# Enable the configured session container(s); any class that inherits from
|
576
|
+
# SessionContainer will be considered by its session_store_type attribute.
|
577
|
+
def self.run
|
578
|
+
# Require all standard session containers.
|
579
|
+
Dir[Merb.framework_root / "merb-core" / "dispatch" / "session" / "*.rb"].each do |file|
|
580
|
+
base_name = File.basename(file, ".rb")
|
581
|
+
require file unless base_name == "container" || base_name == "store_container"
|
582
|
+
end
|
583
|
+
|
584
|
+
# Set some defaults.
|
585
|
+
Merb::Config[:session_id_key] ||= "_session_id"
|
586
|
+
|
587
|
+
# List of all session_stores from :session_stores and :session_store config options.
|
588
|
+
config_stores = Merb::Config.session_stores
|
589
|
+
|
590
|
+
# Register all configured session stores - any loaded session container class
|
591
|
+
# (subclassed from Merb::SessionContainer) will be available for registration.
|
592
|
+
Merb::SessionContainer.subclasses.each do |class_name|
|
593
|
+
if(store = Object.full_const_get(class_name)) &&
|
594
|
+
config_stores.include?(store.session_store_type)
|
595
|
+
Merb::Request.register_session_type(store.session_store_type, class_name)
|
596
|
+
end
|
597
|
+
end
|
598
|
+
|
599
|
+
# Mixin the Merb::Session module to add app-level functionality to sessions
|
600
|
+
Merb::SessionContainer.send(:include, Merb::Session)
|
601
|
+
end
|
602
|
+
|
603
|
+
end
|
604
|
+
|
551
605
|
class Merb::BootLoader::AfterAppLoads < Merb::BootLoader
|
552
606
|
|
553
607
|
# Call any after_app_loads hooks that were registered via after_app_loads in
|
@@ -573,66 +627,6 @@ class Merb::BootLoader::SetupStubClasses < Merb::BootLoader
|
|
573
627
|
end
|
574
628
|
end
|
575
629
|
|
576
|
-
class Merb::BootLoader::MixinSessionContainer < Merb::BootLoader
|
577
|
-
|
578
|
-
# Mixin the correct session container.
|
579
|
-
def self.run
|
580
|
-
Merb.register_session_type('memory',
|
581
|
-
Merb.framework_root / "merb-core" / "dispatch" / "session" / "memory",
|
582
|
-
"Using in-memory sessions; sessions will be lost whenever the server stops.")
|
583
|
-
|
584
|
-
Merb.register_session_type('memcache',
|
585
|
-
Merb.framework_root / "merb-core" / "dispatch" / "session" / "memcached",
|
586
|
-
"Using 'memcached' sessions")
|
587
|
-
|
588
|
-
Merb.register_session_type('cookie', # Last session type becomes the default
|
589
|
-
Merb.framework_root / "merb-core" / "dispatch" / "session" / "cookie",
|
590
|
-
"Using 'share-nothing' cookie sessions (4kb limit per client)")
|
591
|
-
|
592
|
-
|
593
|
-
|
594
|
-
Merb::Controller.class_eval do
|
595
|
-
session_store = Merb::Config[:session_store].to_s
|
596
|
-
if ["", "false", "none"].include?(session_store)
|
597
|
-
Merb.logger.warn "Not Using Sessions"
|
598
|
-
elsif reg = Merb.registered_session_types[session_store]
|
599
|
-
Merb::BootLoader::MixinSessionContainer.check_for_secret_key if session_store == "cookie"
|
600
|
-
Merb::BootLoader::MixinSessionContainer.check_for_session_id_key
|
601
|
-
require reg[:file]
|
602
|
-
include ::Merb::SessionMixin
|
603
|
-
Merb.logger.warn reg[:description]
|
604
|
-
else
|
605
|
-
Merb.logger.warn "Session store not found, '#{Merb::Config[:session_store]}'."
|
606
|
-
Merb.logger.warn "Defaulting to CookieStore Sessions"
|
607
|
-
Merb::BootLoader::MixinSessionContainer.check_for_secret_key
|
608
|
-
Merb::BootLoader::MixinSessionContainer.check_for_session_id_key
|
609
|
-
require Merb.registered_session_types['cookie'][:file]
|
610
|
-
include ::Merb::SessionMixin
|
611
|
-
Merb.logger.warn "(plugin not installed?)"
|
612
|
-
end
|
613
|
-
end
|
614
|
-
|
615
|
-
Merb.logger.flush
|
616
|
-
end
|
617
|
-
|
618
|
-
# Sets the controller session ID key if it has been set in config.
|
619
|
-
def self.check_for_session_id_key
|
620
|
-
if Merb::Config[:session_id_key]
|
621
|
-
Merb::Controller._session_id_key = Merb::Config[:session_id_key]
|
622
|
-
end
|
623
|
-
end
|
624
|
-
|
625
|
-
# Attempts to set the session secret key. This method will exit if the key
|
626
|
-
# does not exist or is shorter than 16 charaters.
|
627
|
-
def self.check_for_secret_key
|
628
|
-
unless Merb::Config[:session_secret_key] && (Merb::Config[:session_secret_key].length >= 16)
|
629
|
-
Merb.logger.warn("You must specify a session_secret_key in your init file, and it must be at least 16 characters\nbailing out...")
|
630
|
-
exit!
|
631
|
-
end
|
632
|
-
Merb::Controller._session_secret_key = Merb::Config[:session_secret_key]
|
633
|
-
end
|
634
|
-
end
|
635
|
-
|
636
630
|
class Merb::BootLoader::ChooseAdapter < Merb::BootLoader
|
637
631
|
|
638
632
|
# Choose the Rack adapter/server to use and set Merb.adapter.
|
data/lib/merb-core/config.rb
CHANGED
@@ -17,7 +17,6 @@ module Merb
|
|
17
17
|
:environment => "development",
|
18
18
|
:merb_root => Dir.pwd,
|
19
19
|
:use_mutex => true,
|
20
|
-
:session_id_key => "_session_id",
|
21
20
|
:log_delimiter => " ~ ",
|
22
21
|
:log_auto_flush => false,
|
23
22
|
:log_level => :info,
|
@@ -116,6 +115,9 @@ module Merb
|
|
116
115
|
|
117
116
|
# Environment variables always win
|
118
117
|
options[:environment] = ENV["MERB_ENV"] if ENV["MERB_ENV"]
|
118
|
+
|
119
|
+
# Enable bundled gems by default; used by bundled?
|
120
|
+
options[:bundle] = true
|
119
121
|
|
120
122
|
# Build a parser for the command line arguments
|
121
123
|
opts = OptionParser.new do |opts|
|
@@ -239,6 +241,10 @@ module Merb
|
|
239
241
|
opts.on("-V", "--verbose", "Print extra information") do
|
240
242
|
options[:verbose] = true
|
241
243
|
end
|
244
|
+
|
245
|
+
opts.on("-B", "--[no-]bundle", "Run application using bundled gems. Enabled by default.") do |b|
|
246
|
+
options[:bundle] = b
|
247
|
+
end
|
242
248
|
|
243
249
|
opts.on("-?", "-H", "--help", "Show this help message") do
|
244
250
|
puts opts
|