merb-core 0.9.6 → 0.9.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +67 -0
- data/CONTRIBUTORS +1 -0
- data/PUBLIC_CHANGELOG +34 -0
- data/Rakefile +7 -4
- data/bin/merb +1 -31
- data/lib/merb-core.rb +17 -6
- data/lib/merb-core/config.rb +0 -7
- data/lib/merb-core/controller/abstract_controller.rb +6 -3
- data/lib/merb-core/dispatch/cookies.rb +11 -10
- data/lib/merb-core/dispatch/dispatcher.rb +11 -5
- data/lib/merb-core/dispatch/request.rb +7 -2
- data/lib/merb-core/dispatch/session.rb +33 -17
- data/lib/merb-core/dispatch/session/container.rb +19 -9
- data/lib/merb-core/dispatch/session/cookie.rb +27 -12
- data/lib/merb-core/dispatch/session/memcached.rb +47 -27
- data/lib/merb-core/dispatch/session/memory.rb +10 -6
- data/lib/merb-core/dispatch/session/store_container.rb +25 -20
- data/lib/merb-core/test/helpers/request_helper.rb +6 -3
- data/lib/merb-core/test/helpers/route_helper.rb +1 -1
- data/lib/merb-core/test/matchers/view_matchers.rb +5 -1
- data/lib/merb-core/version.rb +1 -1
- data/spec/private/dispatch/fixture/log/merb_test.log +144 -0
- data/spec/private/router/fixture/log/merb_test.log +16 -0
- data/spec/public/controller/controllers/cookies.rb +14 -3
- data/spec/public/controller/cookies_spec.rb +53 -10
- data/spec/public/controller/url_spec.rb +6 -0
- data/spec/public/directory_structure/directory/log/merb_test.log +112 -0
- data/spec/public/reloading/directory/log/merb_test.log +16 -0
- data/spec/public/request/request_spec.rb +19 -10
- data/spec/public/router/fixture/log/merb_test.log +224 -0
- data/spec/public/session/controllers/sessions.rb +4 -0
- data/spec/public/session/memcached_session_spec.rb +2 -2
- data/spec/public/session/multiple_sessions_spec.rb +2 -2
- data/spec/public/session/session_spec.rb +15 -0
- data/spec/public/test/request_helper_spec.rb +21 -0
- data/spec/public/test/route_helper_spec.rb +7 -0
- metadata +6 -17
- data/lib/merb-core/script.rb +0 -112
@@ -4,8 +4,8 @@ require File.join(File.dirname(__FILE__), "..", "..", "spec_helper")
|
|
4
4
|
require File.join(File.dirname(__FILE__), "session_spec")
|
5
5
|
require File.join(File.dirname(__FILE__), "controllers", "sessions")
|
6
6
|
|
7
|
-
require '
|
8
|
-
Merb::MemcacheSession.store =
|
7
|
+
require 'memcache'
|
8
|
+
Merb::MemcacheSession.store = MemCache.new('127.0.0.1:11211', { :namespace => 'my_app' })
|
9
9
|
|
10
10
|
describe Merb::MemcacheSession do
|
11
11
|
|
@@ -4,8 +4,8 @@ require File.join(File.dirname(__FILE__), "..", "..", "spec_helper")
|
|
4
4
|
require File.join(File.dirname(__FILE__), "session_spec")
|
5
5
|
require File.join(File.dirname(__FILE__), "controllers", "sessions")
|
6
6
|
|
7
|
-
require '
|
8
|
-
Merb::MemcacheSession.store =
|
7
|
+
require 'memcache'
|
8
|
+
Merb::MemcacheSession.store = MemCache.new('127.0.0.1:11211', { :namespace => 'my_app' })
|
9
9
|
|
10
10
|
describe "An app with multiple session stores configured" do
|
11
11
|
|
@@ -70,6 +70,21 @@ describe "All session-stores mixed into Merb::Controller", :shared => true do
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
+
it "should allow the session to be destroyed" do
|
74
|
+
session_store_type = @session_class.session_store_type.to_s
|
75
|
+
with_cookies(@controller_klass) do
|
76
|
+
controller = dispatch_to(@controller_klass, :index, :foo => session_store_type)
|
77
|
+
controller = dispatch_to(@controller_klass, :retrieve)
|
78
|
+
controller.request.session[:foo].should == session_store_type
|
79
|
+
|
80
|
+
controller = dispatch_to(@controller_klass, :destroy)
|
81
|
+
controller.request.session.should be_empty
|
82
|
+
cookie_header = controller.headers["Set-Cookie"].first
|
83
|
+
cookie_header.should match(/_session_id=;/)
|
84
|
+
cookie_header.should match(/01-Jan-1970/)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
73
88
|
it "should not set the Set-Cookie header when the session(_id) didn't change" do
|
74
89
|
session_store_type = @session_class.session_store_type.to_s
|
75
90
|
with_cookies(@controller_klass) do
|
@@ -65,6 +65,11 @@ describe Merb::Test::RequestHelper do
|
|
65
65
|
|
66
66
|
controller.params[:action].should == "show"
|
67
67
|
end
|
68
|
+
|
69
|
+
it "should support setting request.raw_post" do
|
70
|
+
controller = dispatch_to(@controller_klass, :show, {}, {:post_body => 'some XML'})
|
71
|
+
controller.request.raw_post.should == 'some XML'
|
72
|
+
end
|
68
73
|
end
|
69
74
|
|
70
75
|
describe "#dispatch_with_basic_authentication_to" do
|
@@ -213,11 +218,27 @@ describe Merb::Test::RequestHelper do
|
|
213
218
|
end
|
214
219
|
end
|
215
220
|
|
221
|
+
it "should support setting request.raw_post" do
|
222
|
+
controller = request("/namespaced/spec_helper_controller", {}, {:post_body => 'some XML'})
|
223
|
+
controller.request.raw_post.should == 'some XML'
|
224
|
+
end
|
225
|
+
|
216
226
|
it "should get namespaced index action" do
|
217
227
|
Merb::Test::ControllerAssertionMock.should_receive(:called).with(:index)
|
218
228
|
controller = request("/namespaced/spec_helper_controller")
|
219
229
|
controller.class.should == Namespaced::SpecHelperController
|
220
230
|
end
|
231
|
+
|
232
|
+
it "should make the post body available in the request on deferred routing" do
|
233
|
+
Merb::Router.prepare do |r|
|
234
|
+
r.match('/xmlrpc').defer_to do |request, params|
|
235
|
+
request.raw_post.should == 'XMLRPC request body'
|
236
|
+
{:controller => 'spec_helper_controller', :action => :index}
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
request('/xmlrpc', {}, {:post_body => 'XMLRPC request body'})
|
241
|
+
end
|
221
242
|
end
|
222
243
|
|
223
244
|
end
|
@@ -8,6 +8,9 @@ end
|
|
8
8
|
describe Merb::Test::RouteHelper do
|
9
9
|
before(:each) do
|
10
10
|
Merb::Router.prepare do |r|
|
11
|
+
r.match("/").defer_to do |request, params|
|
12
|
+
{ :controller => 'test_controller', :action => request.raw_post } unless request.raw_post.blank?
|
13
|
+
end
|
11
14
|
r.match("/", :method => :get).to(:controller => "test_controller", :action => "get").name(:getter)
|
12
15
|
r.match("/", :method => :post).to(:controller => "test_controller", :action => "post")
|
13
16
|
r.match("/:id").to(:controller => "test_controller", :action => "get").name(:with_id)
|
@@ -67,5 +70,9 @@ describe Merb::Test::RouteHelper do
|
|
67
70
|
it "should contain any parameters in the result" do
|
68
71
|
request_to("/123")[:id].should == "123"
|
69
72
|
end
|
73
|
+
|
74
|
+
it "should play nice with raw_post in deferred routing" do
|
75
|
+
request_to("/", :post, {:post_body => 'deferred'})[:action].should == 'deferred'
|
76
|
+
end
|
70
77
|
end
|
71
78
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: merb-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ezra Zygmuntowicz
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-09-
|
12
|
+
date: 2008-09-14 00:00:00 +03:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.9.
|
23
|
+
version: 0.9.6
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: erubis
|
@@ -93,24 +93,14 @@ dependencies:
|
|
93
93
|
version: "0"
|
94
94
|
version:
|
95
95
|
- !ruby/object:Gem::Dependency
|
96
|
-
name:
|
97
|
-
type: :
|
98
|
-
version_requirement:
|
99
|
-
version_requirements: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: "0"
|
104
|
-
version:
|
105
|
-
- !ruby/object:Gem::Dependency
|
106
|
-
name: memcache-client
|
107
|
-
type: :development
|
96
|
+
name: thor
|
97
|
+
type: :runtime
|
108
98
|
version_requirement:
|
109
99
|
version_requirements: !ruby/object:Gem::Requirement
|
110
100
|
requirements:
|
111
101
|
- - ">="
|
112
102
|
- !ruby/object:Gem::Version
|
113
|
-
version:
|
103
|
+
version: 0.9.6
|
114
104
|
version:
|
115
105
|
description: Merb. Pocket rocket web framework.
|
116
106
|
email: ez@engineyard.com
|
@@ -540,7 +530,6 @@ files:
|
|
540
530
|
- lib/merb-core/rack/middleware/tracer.rb
|
541
531
|
- lib/merb-core/rack/middleware.rb
|
542
532
|
- lib/merb-core/rack.rb
|
543
|
-
- lib/merb-core/script.rb
|
544
533
|
- lib/merb-core/server.rb
|
545
534
|
- lib/merb-core/tasks
|
546
535
|
- lib/merb-core/tasks/audit.rake
|
data/lib/merb-core/script.rb
DELETED
@@ -1,112 +0,0 @@
|
|
1
|
-
module Merb
|
2
|
-
module ScriptHelpers
|
3
|
-
|
4
|
-
# Adapt rubygems - shortcut for setup_local_gems that figures out the
|
5
|
-
# local gem path to use.
|
6
|
-
def setup_local_gems!(rootdir = nil)
|
7
|
-
if bundled? && local_gems = setup_local_gems(File.join(rootdir || merb_root, 'gems'))
|
8
|
-
if local_gems.is_a?(Array)
|
9
|
-
puts "Using local gems in addition to system gems..."
|
10
|
-
if verbose?
|
11
|
-
puts "Found #{local_gems.length} local gems:"
|
12
|
-
local_gems.each { |name| puts "- #{name}" }
|
13
|
-
end
|
14
|
-
elsif local_gems
|
15
|
-
puts "Using MiniGems to locate local/system gems..."
|
16
|
-
end
|
17
|
-
elsif use_minigems?
|
18
|
-
puts "Using MiniGems to locate system gems..."
|
19
|
-
else
|
20
|
-
puts "Using system gems..."
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
# Adapt rubygems - because the /usr/bin/merb script already setup merb-core loadpaths
|
25
|
-
# from the system-wide rubygem paths. The code below will make sure local gems always
|
26
|
-
# get precedence over system gems and resolves any conflicts that may arise.
|
27
|
-
#
|
28
|
-
# Only native Gem methods are used to handle the internal logic transparently.
|
29
|
-
# These methods are proved either by minigems or standard rubygems.
|
30
|
-
#
|
31
|
-
# Note: currently the Kernel.load_dependency method will always load local gems.
|
32
|
-
def setup_local_gems(gems_path)
|
33
|
-
if File.directory?(gems_path)
|
34
|
-
if use_minigems?
|
35
|
-
# Reset all loaded system gems - replace with local gems
|
36
|
-
Gem.clear_paths
|
37
|
-
Gem.path.unshift(gems_path)
|
38
|
-
return true
|
39
|
-
else
|
40
|
-
# Remember originally loaded system gems and create a lookup of gems to load paths
|
41
|
-
system_gemspecs = Gem.cache.gems
|
42
|
-
system_load_paths = extract_gem_load_paths(system_gemspecs)
|
43
|
-
|
44
|
-
# Reset all loaded system gems - replace with local gems
|
45
|
-
Gem.clear_paths
|
46
|
-
Gem.path.unshift(gems_path)
|
47
|
-
Gem.cache.load_gems_in(File.join(gems_path, "specifications"))
|
48
|
-
|
49
|
-
# Collect any local gems we're going to use
|
50
|
-
local_gems = Gem.cache.map { |name, spec| name }
|
51
|
-
|
52
|
-
# Create a lookup of gems to load paths for all local gems
|
53
|
-
local_load_paths = extract_gem_load_paths(Gem.cache.gems)
|
54
|
-
|
55
|
-
# Filter out local gems from the originally loaded system gems to prevent conflicts
|
56
|
-
active_system_gems = []
|
57
|
-
system_gemspecs.each do |name, spec|
|
58
|
-
active_system_gems << spec unless local_load_paths[spec.name]
|
59
|
-
end
|
60
|
-
|
61
|
-
# Re-add the system gems - conflicts with local gems have been avoided
|
62
|
-
Gem.cache.add_specs(*active_system_gems)
|
63
|
-
|
64
|
-
# Add local paths to LOAD_PATH - remove overlapping system gem paths
|
65
|
-
local_load_paths.each do |name, paths|
|
66
|
-
$LOAD_PATH.unshift(*paths)
|
67
|
-
$LOAD_PATH.replace($LOAD_PATH - system_load_paths[name] || [])
|
68
|
-
end
|
69
|
-
return local_gems
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
# Figure out the merb root or default to current directory
|
75
|
-
def merb_root
|
76
|
-
root_key = %w[-m --merb-root].detect { |o| ARGV.index(o) }
|
77
|
-
root = ARGV[ARGV.index(root_key) + 1] if root_key
|
78
|
-
root.to_a.empty? ? Dir.getwd : root
|
79
|
-
end
|
80
|
-
|
81
|
-
# See if we're running merb locally - enabled by default
|
82
|
-
# The ENV variables are considered for Rakefile usage.
|
83
|
-
def bundled?
|
84
|
-
enabled = ENV.key?("BUNDLE") || %w[-B --bundle].detect { |o| ARGV.index(o) }
|
85
|
-
disabled = ENV.key?("NO_BUNDLE") || %w[--no-bundle].detect { |o| ARGV.index(o) }
|
86
|
-
enabled || !disabled
|
87
|
-
end
|
88
|
-
|
89
|
-
# Add some extra feedback if verbose is enabled
|
90
|
-
def verbose?
|
91
|
-
%w[-V --verbose].detect { |o| ARGV.index(o) }
|
92
|
-
end
|
93
|
-
|
94
|
-
# Whether minigems has been loaded instead of the full rubygems
|
95
|
-
def use_minigems?
|
96
|
-
Gem.respond_to?(:minigems?) && Gem.minigems?
|
97
|
-
end
|
98
|
-
|
99
|
-
# Helper method to extract a Hash lookup of gem name to load paths
|
100
|
-
def extract_gem_load_paths(source_index)
|
101
|
-
source_index.inject({}) do |load_paths, (name, spec)|
|
102
|
-
require_paths = spec.require_paths
|
103
|
-
require_paths << spec.bindir unless spec.executables.empty?
|
104
|
-
load_paths[spec.name] = require_paths.map do |path|
|
105
|
-
File.join(spec.full_gem_path, path)
|
106
|
-
end
|
107
|
-
load_paths
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
end
|
112
|
-
end
|