merb-core 0.9.8 → 0.9.9
Sign up to get free protection for your applications and to get access to all the features.
- data/CONTRIBUTORS +33 -0
- data/README +7 -3
- data/Rakefile +3 -3
- data/lib/merb-core.rb +165 -94
- data/lib/merb-core/bootloader.rb +469 -100
- data/lib/merb-core/config.rb +79 -3
- data/lib/merb-core/constants.rb +24 -2
- data/lib/merb-core/controller/abstract_controller.rb +172 -67
- data/lib/merb-core/controller/exceptions.rb +50 -6
- data/lib/merb-core/controller/merb_controller.rb +215 -108
- data/lib/merb-core/controller/mime.rb +36 -12
- data/lib/merb-core/controller/mixins/authentication.rb +52 -7
- data/lib/merb-core/controller/mixins/conditional_get.rb +14 -0
- data/lib/merb-core/controller/mixins/controller.rb +90 -58
- data/lib/merb-core/controller/mixins/render.rb +34 -10
- data/lib/merb-core/controller/mixins/responder.rb +40 -16
- data/lib/merb-core/controller/template.rb +37 -16
- data/lib/merb-core/core_ext/hash.rb +9 -0
- data/lib/merb-core/core_ext/kernel.rb +92 -41
- data/lib/merb-core/dispatch/dispatcher.rb +29 -45
- data/lib/merb-core/dispatch/request.rb +186 -82
- data/lib/merb-core/dispatch/router.rb +141 -53
- data/lib/merb-core/dispatch/router/behavior.rb +296 -139
- data/lib/merb-core/dispatch/router/resources.rb +51 -19
- data/lib/merb-core/dispatch/router/route.rb +76 -23
- data/lib/merb-core/dispatch/session.rb +80 -36
- data/lib/merb-core/dispatch/session/container.rb +31 -15
- data/lib/merb-core/dispatch/session/cookie.rb +51 -22
- data/lib/merb-core/dispatch/session/memcached.rb +10 -6
- data/lib/merb-core/dispatch/session/memory.rb +17 -5
- data/lib/merb-core/dispatch/session/store_container.rb +21 -9
- data/lib/merb-core/dispatch/worker.rb +16 -2
- data/lib/merb-core/gem_ext/erubis.rb +4 -0
- data/lib/merb-core/plugins.rb +13 -0
- data/lib/merb-core/rack.rb +1 -0
- data/lib/merb-core/rack/adapter.rb +1 -0
- data/lib/merb-core/rack/adapter/abstract.rb +95 -17
- data/lib/merb-core/rack/adapter/irb.rb +50 -5
- data/lib/merb-core/rack/application.rb +27 -5
- data/lib/merb-core/rack/handler/mongrel.rb +6 -6
- data/lib/merb-core/rack/helpers.rb +33 -0
- data/lib/merb-core/rack/middleware/conditional_get.rb +1 -1
- data/lib/merb-core/rack/middleware/path_prefix.rb +3 -3
- data/lib/merb-core/rack/middleware/static.rb +11 -7
- data/lib/merb-core/server.rb +134 -69
- data/lib/merb-core/tasks/gem_management.rb +153 -80
- data/lib/merb-core/tasks/merb_rake_helper.rb +12 -4
- data/lib/merb-core/tasks/stats.rake +1 -1
- data/lib/merb-core/test/helpers/mock_request_helper.rb +29 -22
- data/lib/merb-core/test/helpers/request_helper.rb +1 -1
- data/lib/merb-core/test/helpers/route_helper.rb +50 -4
- data/lib/merb-core/test/matchers/request_matchers.rb +2 -36
- data/lib/merb-core/test/matchers/view_matchers.rb +32 -22
- data/lib/merb-core/test/run_specs.rb +6 -5
- data/lib/merb-core/test/test_ext/rspec.rb +6 -19
- data/lib/merb-core/version.rb +1 -1
- metadata +5 -4
@@ -1,7 +1,4 @@
|
|
1
1
|
require 'rubygems'
|
2
|
-
require 'rubygems/dependency_installer'
|
3
|
-
require 'rubygems/uninstaller'
|
4
|
-
require 'rubygems/dependency'
|
5
2
|
|
6
3
|
module ColorfulMessages
|
7
4
|
|
@@ -22,12 +19,28 @@ module ColorfulMessages
|
|
22
19
|
|
23
20
|
alias_method :message, :success
|
24
21
|
|
22
|
+
# magenta
|
23
|
+
def note(*messages)
|
24
|
+
puts messages.map { |msg| "\033[1;35m#{msg}\033[0m" }
|
25
|
+
end
|
26
|
+
|
27
|
+
# blue
|
28
|
+
def info(*messages)
|
29
|
+
puts messages.map { |msg| "\033[1;34m#{msg}\033[0m" }
|
30
|
+
end
|
31
|
+
|
25
32
|
end
|
26
33
|
|
34
|
+
##############################################################################
|
35
|
+
|
36
|
+
require 'rubygems/dependency_installer'
|
37
|
+
require 'rubygems/uninstaller'
|
38
|
+
require 'rubygems/dependency'
|
39
|
+
|
27
40
|
module GemManagement
|
28
41
|
|
29
42
|
include ColorfulMessages
|
30
|
-
|
43
|
+
|
31
44
|
# Install a gem - looks remotely and local gem cache;
|
32
45
|
# won't process rdoc or ri options.
|
33
46
|
def install_gem(gem, options = {})
|
@@ -39,13 +52,13 @@ module GemManagement
|
|
39
52
|
version = options.delete(:version)
|
40
53
|
Gem.configuration.update_sources = false
|
41
54
|
|
55
|
+
# Limit source index to install dir
|
42
56
|
update_source_index(options[:install_dir]) if options[:install_dir]
|
43
57
|
|
44
58
|
installer = Gem::DependencyInstaller.new(options.merge(:user_install => false))
|
45
59
|
|
46
|
-
#
|
47
|
-
|
48
|
-
unless refresh.empty?
|
60
|
+
# Force-refresh certain gems by excluding them from the current index
|
61
|
+
if !options[:ignore_dependencies] && refresh.respond_to?(:include?) && !refresh.empty?
|
49
62
|
source_index = installer.instance_variable_get(:@source_index)
|
50
63
|
source_index.gems.each do |name, spec|
|
51
64
|
source_index.gems.delete(name) if refresh.include?(spec.name)
|
@@ -68,7 +81,7 @@ module GemManagement
|
|
68
81
|
exception = e
|
69
82
|
end
|
70
83
|
if installer.installed_gems.empty? && exception
|
71
|
-
error "Failed to install gem '#{gem} (#{version})' (#{exception.message})"
|
84
|
+
error "Failed to install gem '#{gem} (#{version || 'any version'})' (#{exception.message})"
|
72
85
|
end
|
73
86
|
installer.installed_gems.each do |spec|
|
74
87
|
success "Successfully installed #{spec.full_name}"
|
@@ -103,81 +116,73 @@ module GemManagement
|
|
103
116
|
end
|
104
117
|
|
105
118
|
# Install a gem from source - builds and packages it first then installs.
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
119
|
+
#
|
120
|
+
# Examples:
|
121
|
+
# install_gem_from_source(source_dir, :install_dir => ...)
|
122
|
+
# install_gem_from_source(source_dir, gem_name)
|
123
|
+
# install_gem_from_source(source_dir, :skip => [...])
|
124
|
+
def install_gem_from_source(source_dir, *args)
|
125
|
+
installed_gems = []
|
126
|
+
Dir.chdir(source_dir) do
|
127
|
+
opts = args.last.is_a?(Hash) ? args.pop : {}
|
128
|
+
gem_name = args[0] || File.basename(source_dir)
|
129
|
+
gem_pkg_dir = File.join(source_dir, 'pkg')
|
130
|
+
gem_pkg_glob = File.join(gem_pkg_dir, "#{gem_name}-*.gem")
|
131
|
+
skip_gems = opts.delete(:skip) || []
|
113
132
|
|
114
|
-
|
115
|
-
|
133
|
+
# Cleanup what's already there
|
134
|
+
clobber(source_dir)
|
135
|
+
FileUtils.mkdir_p(gem_pkg_dir) unless File.directory?(gem_pkg_dir)
|
116
136
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
FileUtils.rm_rf(gem_pkg_dir) if File.directory?(gem_pkg_dir)
|
125
|
-
# Create the package.
|
126
|
-
FileUtils.cd(gem_src_dir) { system("#{thor} :package") }
|
127
|
-
# Install the package using rubygems.
|
128
|
-
if package = Dir[File.join(gem_pkg_dir, "#{gem_name}-*.gem")].last
|
129
|
-
FileUtils.cd(File.dirname(package)) do
|
130
|
-
install_gem(File.basename(package), options.dup)
|
131
|
-
return true
|
132
|
-
end
|
137
|
+
# Recursively process all gem packages within the source dir
|
138
|
+
skip_gems << gem_name
|
139
|
+
packages = package_all(source_dir, skip_gems)
|
140
|
+
|
141
|
+
if packages.length == 1
|
142
|
+
# The are no subpackages for the main package
|
143
|
+
refresh = [gem_name]
|
133
144
|
else
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
else
|
138
|
-
# Clean and regenerate any subgems for meta gems.
|
139
|
-
Dir[File.join(gem_src_dir, '*', 'Rakefile')].each do |rakefile|
|
140
|
-
FileUtils.cd(File.dirname(rakefile)) do
|
141
|
-
system("#{rake} clobber_package; #{rake} package")
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
# Handle the main gem install.
|
146
|
-
if File.exists?(File.join(gem_src_dir, 'Rakefile'))
|
147
|
-
subgems = []
|
148
|
-
# Remove any existing packages.
|
149
|
-
FileUtils.cd(gem_src_dir) { system("#{rake} clobber_package") }
|
150
|
-
# Create the main gem pkg dir if it doesn't exist.
|
151
|
-
FileUtils.mkdir_p(gem_pkg_dir) unless File.directory?(gem_pkg_dir)
|
152
|
-
# Copy any subgems to the main gem pkg dir.
|
153
|
-
Dir[File.join(gem_src_dir, '*', 'pkg', '*.gem')].each do |subgem_pkg|
|
154
|
-
if name = File.basename(subgem_pkg, '.gem')[/^(.*?)-([\d\.]+)$/, 1]
|
155
|
-
subgems << name
|
156
|
-
end
|
157
|
-
dest = File.join(gem_pkg_dir, File.basename(subgem_pkg))
|
158
|
-
FileUtils.copy_entry(subgem_pkg, dest, true, false, true)
|
145
|
+
# Gather all packages into the top-level pkg directory
|
146
|
+
packages.each do |pkg|
|
147
|
+
FileUtils.copy_entry(pkg, File.join(gem_pkg_dir, File.basename(pkg)))
|
159
148
|
end
|
160
|
-
|
161
|
-
# Finally
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
149
|
+
|
150
|
+
# Finally package the main gem - without clobbering the already copied pkgs
|
151
|
+
package(source_dir, false)
|
152
|
+
|
153
|
+
# Gather subgems to refresh during installation of the main gem
|
154
|
+
refresh = packages.map do |pkg|
|
155
|
+
File.basename(pkg, '.gem')[/^(.*?)-([\d\.]+)$/, 1] rescue nil
|
156
|
+
end.compact
|
157
|
+
|
158
|
+
# Install subgems explicitly even if ignore_dependencies is set
|
159
|
+
if opts[:ignore_dependencies]
|
160
|
+
refresh.each do |name|
|
161
|
+
gem_pkg = Dir[File.join(gem_pkg_dir, "#{name}-*.gem")][0]
|
162
|
+
install_pkg(gem_pkg, opts)
|
173
163
|
end
|
174
|
-
return true
|
175
164
|
end
|
176
165
|
end
|
166
|
+
|
167
|
+
# Finally install the main gem
|
168
|
+
if install_pkg(Dir[gem_pkg_glob][0], opts.merge(:refresh => refresh))
|
169
|
+
installed_gems = refresh
|
170
|
+
else
|
171
|
+
installed_gems = []
|
172
|
+
end
|
177
173
|
end
|
178
|
-
|
174
|
+
installed_gems
|
179
175
|
end
|
180
|
-
|
176
|
+
|
177
|
+
def install_pkg(gem_pkg, opts = {})
|
178
|
+
if (gem_pkg && File.exists?(gem_pkg))
|
179
|
+
# Needs to be executed from the directory that contains all packages
|
180
|
+
Dir.chdir(File.dirname(gem_pkg)) { install_gem(gem_pkg, opts) }
|
181
|
+
else
|
182
|
+
false
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
181
186
|
# Uninstall a gem.
|
182
187
|
def uninstall_gem(gem, options = {})
|
183
188
|
if options[:version] && !options[:version].is_a?(Gem::Requirement)
|
@@ -187,6 +192,45 @@ module GemManagement
|
|
187
192
|
Gem::Uninstaller.new(gem, options).uninstall
|
188
193
|
end
|
189
194
|
|
195
|
+
def clobber(source_dir)
|
196
|
+
Dir.chdir(source_dir) do
|
197
|
+
system "#{Gem.ruby} -S rake -s clobber" unless File.exists?('Thorfile')
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def package(source_dir, clobber = true)
|
202
|
+
Dir.chdir(source_dir) do
|
203
|
+
if File.exists?('Thorfile')
|
204
|
+
thor ":package"
|
205
|
+
elsif File.exists?('Rakefile')
|
206
|
+
rake "clobber" if clobber
|
207
|
+
rake "package"
|
208
|
+
end
|
209
|
+
end
|
210
|
+
Dir[File.join(source_dir, 'pkg/*.gem')]
|
211
|
+
end
|
212
|
+
|
213
|
+
def package_all(source_dir, skip = [], packages = [])
|
214
|
+
if Dir[File.join(source_dir, '{Rakefile,Thorfile}')][0]
|
215
|
+
name = File.basename(source_dir)
|
216
|
+
Dir[File.join(source_dir, '*', '{Rakefile,Thorfile}')].each do |taskfile|
|
217
|
+
package_all(File.dirname(taskfile), skip, packages)
|
218
|
+
end
|
219
|
+
packages.push(*package(source_dir)) unless skip.include?(name)
|
220
|
+
end
|
221
|
+
packages.uniq
|
222
|
+
end
|
223
|
+
|
224
|
+
def rake(cmd)
|
225
|
+
cmd << " >/dev/null" if $SILENT && !Gem.win_platform?
|
226
|
+
system "#{Gem.ruby} -S #{which('rake')} -s #{cmd} >/dev/null"
|
227
|
+
end
|
228
|
+
|
229
|
+
def thor(cmd)
|
230
|
+
cmd << " >/dev/null" if $SILENT && !Gem.win_platform?
|
231
|
+
system "#{Gem.ruby} -S #{which('thor')} #{cmd}"
|
232
|
+
end
|
233
|
+
|
190
234
|
# Use the local bin/* executables if available.
|
191
235
|
def which(executable)
|
192
236
|
if File.executable?(exec = File.join(Dir.pwd, 'bin', executable))
|
@@ -196,17 +240,43 @@ module GemManagement
|
|
196
240
|
end
|
197
241
|
end
|
198
242
|
|
243
|
+
# Partition gems into system, local and missing gems
|
244
|
+
def partition_dependencies(dependencies, gem_dir)
|
245
|
+
system_specs, local_specs, missing_deps = [], [], []
|
246
|
+
if gem_dir && File.directory?(gem_dir)
|
247
|
+
gem_dir = File.expand_path(gem_dir)
|
248
|
+
::Gem.clear_paths; ::Gem.path.unshift(gem_dir)
|
249
|
+
::Gem.source_index.refresh!
|
250
|
+
dependencies.each do |dep|
|
251
|
+
gemspecs = ::Gem.source_index.search(dep)
|
252
|
+
local = gemspecs.reverse.find { |s| s.loaded_from.index(gem_dir) == 0 }
|
253
|
+
if local
|
254
|
+
local_specs << local
|
255
|
+
elsif gemspecs.last
|
256
|
+
system_specs << gemspecs.last
|
257
|
+
else
|
258
|
+
missing_deps << dep
|
259
|
+
end
|
260
|
+
end
|
261
|
+
::Gem.clear_paths
|
262
|
+
end
|
263
|
+
[system_specs, local_specs, missing_deps]
|
264
|
+
end
|
265
|
+
|
199
266
|
# Create a modified executable wrapper in the specified bin directory.
|
200
267
|
def ensure_bin_wrapper_for(gem_dir, bin_dir, *gems)
|
268
|
+
options = gems.last.is_a?(Hash) ? gems.last : {}
|
269
|
+
options[:no_minigems] ||= []
|
201
270
|
if bin_dir && File.directory?(bin_dir)
|
202
271
|
gems.each do |gem|
|
203
272
|
if gemspec_path = Dir[File.join(gem_dir, 'specifications', "#{gem}-*.gemspec")].last
|
204
273
|
spec = Gem::Specification.load(gemspec_path)
|
274
|
+
enable_minigems = !options[:no_minigems].include?(spec.name)
|
205
275
|
spec.executables.each do |exec|
|
206
276
|
executable = File.join(bin_dir, exec)
|
207
277
|
message "Writing executable wrapper #{executable}"
|
208
278
|
File.open(executable, 'w', 0755) do |f|
|
209
|
-
f.write(executable_wrapper(spec, exec))
|
279
|
+
f.write(executable_wrapper(spec, exec, enable_minigems))
|
210
280
|
end
|
211
281
|
end
|
212
282
|
end
|
@@ -216,7 +286,10 @@ module GemManagement
|
|
216
286
|
|
217
287
|
private
|
218
288
|
|
219
|
-
def executable_wrapper(spec, bin_file_name)
|
289
|
+
def executable_wrapper(spec, bin_file_name, minigems = true)
|
290
|
+
requirements = ['minigems', 'rubygems']
|
291
|
+
requirements.reverse! unless minigems
|
292
|
+
try_req, then_req = requirements
|
220
293
|
<<-TEXT
|
221
294
|
#!/usr/bin/env ruby
|
222
295
|
#
|
@@ -226,9 +299,9 @@ module GemManagement
|
|
226
299
|
# this file is here to facilitate running it.
|
227
300
|
|
228
301
|
begin
|
229
|
-
require '
|
302
|
+
require '#{try_req}'
|
230
303
|
rescue LoadError
|
231
|
-
require '
|
304
|
+
require '#{then_req}'
|
232
305
|
end
|
233
306
|
|
234
307
|
if File.directory?(gems_dir = File.join(Dir.pwd, 'gems')) ||
|
@@ -263,5 +336,5 @@ TEXT
|
|
263
336
|
def update_source_index(dir)
|
264
337
|
Gem.source_index.load_gems_in(File.join(dir, 'specifications'))
|
265
338
|
end
|
266
|
-
|
267
|
-
end
|
339
|
+
|
340
|
+
end
|
@@ -9,7 +9,12 @@ module Merb
|
|
9
9
|
defaults = { :cache => false }
|
10
10
|
defaults[:install_dir] = ENV['GEM_DIR'] if ENV['GEM_DIR']
|
11
11
|
opts = defaults.merge(options)
|
12
|
-
|
12
|
+
dir = if File.directory?(subdir = File.join(Dir.pwd, name))
|
13
|
+
subdir
|
14
|
+
else
|
15
|
+
Dir.pwd
|
16
|
+
end
|
17
|
+
install_gem_from_source(dir, name, opts)
|
13
18
|
ensure_wrapper(opts[:install_dir] || Gem.default_dir, name)
|
14
19
|
end
|
15
20
|
|
@@ -17,7 +22,10 @@ module Merb
|
|
17
22
|
defaults = { :cache => false }
|
18
23
|
defaults[:install_dir] = ENV['GEM_DIR'] if ENV['GEM_DIR']
|
19
24
|
opts = defaults.merge(options)
|
20
|
-
|
25
|
+
# Needs to be executed from the directory that contains all packages
|
26
|
+
Dir.chdir(File.dirname(pkg_file = File.expand_path(pkg))) do
|
27
|
+
install_gem(pkg_file, opts)
|
28
|
+
end
|
21
29
|
name = File.basename(pkg, '.gem')[/^(.*?)-([\d\.]+)$/, 1]
|
22
30
|
ensure_wrapper(opts[:install_dir] || Gem.default_dir, name)
|
23
31
|
end
|
@@ -26,7 +34,7 @@ module Merb
|
|
26
34
|
defaults = { :ignore => true, :executables => true }
|
27
35
|
defaults[:install_dir] = ENV['GEM_DIR'] if ENV['GEM_DIR']
|
28
36
|
uninstall_gem(name, defaults.merge(options))
|
29
|
-
end
|
37
|
+
end
|
30
38
|
|
31
39
|
def self.sudo
|
32
40
|
ENV['MERB_SUDO'] ||= "sudo"
|
@@ -44,7 +52,7 @@ module Merb
|
|
44
52
|
bindir = File.expand_path(File.join(gemdir, '..', 'bin'))
|
45
53
|
# Fall back to system wide bindir - usually needs sudo permissions
|
46
54
|
bindir = Gem.bindir unless File.directory?(bindir)
|
47
|
-
ensure_bin_wrapper_for(gemdir, bindir, name)
|
55
|
+
ensure_bin_wrapper_for(gemdir, bindir, name, :no_minigems => ['merb-gen'])
|
48
56
|
end
|
49
57
|
|
50
58
|
end
|
@@ -66,6 +66,6 @@ task :stats do
|
|
66
66
|
code_loc = [:controllers, :helpers, :models].inject(0) { |sum, e| sum += @all[e][:loc] }
|
67
67
|
test_loc = @all[:spec][:loc]
|
68
68
|
|
69
|
-
puts " Code LOC: #{cb}#{code_loc}#{ce} Test LOC: #{cb}#{test_loc}#{ce}
|
69
|
+
puts " Code LOC: #{cb}#{code_loc}#{ce} Test LOC: #{cb}#{test_loc}#{ce} Code to test radio: #{cb}1:%0.2f#{ce}" % (test_loc.to_f / code_loc.to_f)
|
70
70
|
puts
|
71
71
|
end
|
@@ -74,8 +74,8 @@ module Merb
|
|
74
74
|
# ==== Notes
|
75
75
|
# If you pass a post body, the content-type will be set to URL-encoded.
|
76
76
|
#
|
77
|
-
|
78
|
-
# @
|
77
|
+
# @api public
|
78
|
+
# @deprecated
|
79
79
|
def fake_request(env = {}, opt = {})
|
80
80
|
if opt[:post_body]
|
81
81
|
req = opt[:post_body]
|
@@ -111,8 +111,8 @@ module Merb
|
|
111
111
|
# ==== Notes
|
112
112
|
# Does not use routes.
|
113
113
|
#
|
114
|
-
|
115
|
-
# @
|
114
|
+
# @api public
|
115
|
+
# @deprecated
|
116
116
|
def dispatch_to(controller_klass, action, params = {}, env = {}, &blk)
|
117
117
|
params = merge_controller_and_action(controller_klass, action, params)
|
118
118
|
dispatch_request(build_request(params, env), controller_klass, action.to_s, &blk)
|
@@ -124,6 +124,9 @@ module Merb
|
|
124
124
|
# ==== Parameters
|
125
125
|
# *controller_classes:: Controller classes to operate on in the context of the block.
|
126
126
|
# &blk:: The context to operate on; optionally accepts the cookie jar as an argument.
|
127
|
+
#
|
128
|
+
# @api public
|
129
|
+
# @deprecated
|
127
130
|
def with_cookies(*controller_classes, &blk)
|
128
131
|
cookie_jar = CookieJar.new
|
129
132
|
before_cb = lambda { |c| c.cookies.update(cookie_jar) }
|
@@ -166,8 +169,8 @@ module Merb
|
|
166
169
|
# ==== Notes
|
167
170
|
# Does not use routes.
|
168
171
|
#
|
169
|
-
|
170
|
-
# @
|
172
|
+
# @api public
|
173
|
+
# @deprecated
|
171
174
|
def dispatch_with_basic_authentication_to(controller_klass, action, username, password, params = {}, env = {}, &blk)
|
172
175
|
env["X_HTTP_AUTHORIZATION"] = "Basic #{Base64.encode64("#{username}:#{password}")}"
|
173
176
|
|
@@ -175,6 +178,7 @@ module Merb
|
|
175
178
|
dispatch_request(build_request(params, env), controller_klass, action.to_s, &blk)
|
176
179
|
end
|
177
180
|
|
181
|
+
# @api private
|
178
182
|
def merge_controller_and_action(controller_klass, action, params)
|
179
183
|
params[:controller] = controller_klass.name.to_const_path
|
180
184
|
params[:action] = action.to_s
|
@@ -203,8 +207,8 @@ module Merb
|
|
203
207
|
# ==== Notes
|
204
208
|
# Does not use routes.
|
205
209
|
#
|
206
|
-
|
207
|
-
# @
|
210
|
+
# @api public
|
211
|
+
# @deprecated
|
208
212
|
def build_request(params = {}, env = {})
|
209
213
|
params = Merb::Request.params_to_query_string(params)
|
210
214
|
|
@@ -227,8 +231,9 @@ module Merb
|
|
227
231
|
# &blk::
|
228
232
|
# The controller is yielded to the block provided for actions *prior* to
|
229
233
|
# the action being dispatched.
|
230
|
-
|
231
|
-
# @public
|
234
|
+
#
|
235
|
+
# @api public
|
236
|
+
# @deprecated
|
232
237
|
def get(path, params = {}, env = {}, &block)
|
233
238
|
env[:request_method] = "GET"
|
234
239
|
mock_request(path, params, env, &block)
|
@@ -246,8 +251,9 @@ module Merb
|
|
246
251
|
# &blk::
|
247
252
|
# The controller is yielded to the block provided for actions *prior* to
|
248
253
|
# the action being dispatched.
|
249
|
-
|
250
|
-
# @public
|
254
|
+
#
|
255
|
+
# @api public
|
256
|
+
# @deprecated
|
251
257
|
def post(path, params = {}, env = {}, &block)
|
252
258
|
env[:request_method] = "POST"
|
253
259
|
mock_request(path, params, env, &block)
|
@@ -265,8 +271,8 @@ module Merb
|
|
265
271
|
# &blk::
|
266
272
|
# The controller is yielded to the block provided for actions *prior* to
|
267
273
|
# the action being dispatched.
|
268
|
-
|
269
|
-
# @public
|
274
|
+
#
|
275
|
+
# @api public
|
270
276
|
def put(path, params = {}, env = {}, &block)
|
271
277
|
env[:request_method] = "PUT"
|
272
278
|
mock_request(path, params, env, &block)
|
@@ -284,8 +290,9 @@ module Merb
|
|
284
290
|
# &blk::
|
285
291
|
# The controller is yielded to the block provided for actions *prior* to
|
286
292
|
# the action being dispatched.
|
287
|
-
|
288
|
-
# @public
|
293
|
+
#
|
294
|
+
# @api public
|
295
|
+
# @deprecated
|
289
296
|
def delete(path, params = {}, env = {}, &block)
|
290
297
|
env[:request_method] = "DELETE"
|
291
298
|
mock_request(path, params, env, &block)
|
@@ -313,8 +320,8 @@ module Merb
|
|
313
320
|
# ==== Notes
|
314
321
|
# Uses Routes.
|
315
322
|
#
|
316
|
-
|
317
|
-
# @
|
323
|
+
# @api plugin
|
324
|
+
# @deprecated
|
318
325
|
def mock_request(path, params = {}, env= {}, &block)
|
319
326
|
env[:request_method] ||= "GET"
|
320
327
|
env[:request_uri], env[:query_string] = path.split('?')
|
@@ -352,8 +359,8 @@ module Merb
|
|
352
359
|
# ==== Notes
|
353
360
|
# Does not use routes.
|
354
361
|
#
|
355
|
-
|
356
|
-
# @
|
362
|
+
# @api public
|
363
|
+
# @deprecated
|
357
364
|
def dispatch_request(request, controller_klass, action, &blk)
|
358
365
|
controller = controller_klass.new(request)
|
359
366
|
yield controller if block_given?
|
@@ -378,8 +385,8 @@ module Merb
|
|
378
385
|
# ==== Returns
|
379
386
|
# Hash:: The parameters built based on the matching route.
|
380
387
|
#
|
381
|
-
|
382
|
-
# @
|
388
|
+
# @api plugin
|
389
|
+
# @deprecated
|
383
390
|
def check_request_for_route(request)
|
384
391
|
match = ::Merb::Router.match(request)
|
385
392
|
if match[0].nil? && match[1].empty?
|