mack 0.6.1.2 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. data/CHANGELOG +49 -3
  2. data/README +4 -4
  3. data/bin/mack +1 -2
  4. data/lib/mack/controller/controller.rb +1 -1
  5. data/lib/mack/controller/cookie_jar.rb +4 -0
  6. data/lib/mack/controller/request.rb +55 -3
  7. data/lib/mack/controller/session.rb +9 -0
  8. data/lib/mack/controller/tell.rb +13 -0
  9. data/lib/mack/core_extensions/kernel.rb +39 -11
  10. data/lib/mack/core_extensions/symbol.rb +107 -0
  11. data/lib/mack/generators/controller_generator/controller_generator.rb +64 -0
  12. data/lib/mack/generators/controller_generator/manifest.yml +18 -0
  13. data/lib/mack/generators/controller_generator/templates/app/controllers/controller.rb.template +7 -0
  14. data/lib/mack/generators/controller_generator/templates/test/controllers/rspec.rb.template +15 -0
  15. data/lib/mack/generators/controller_generator/templates/test/controllers/test_case.rb.template +15 -0
  16. data/lib/mack/generators/controller_helper_generator/controller_helper_generator.rb +16 -0
  17. data/lib/mack/generators/controller_helper_generator/manifest.yml +15 -0
  18. data/lib/mack/generators/controller_helper_generator/templates/app/helpers/controllers/helper.rb.template +7 -0
  19. data/lib/mack/generators/controller_helper_generator/templates/test/helpers/controllers/rspec.rb.template +6 -0
  20. data/lib/mack/generators/controller_helper_generator/templates/test/helpers/controllers/test_case.rb.template +10 -0
  21. data/lib/mack/generators/mack_application_generator/mack_application_generator.rb +1 -0
  22. data/lib/mack/generators/mack_application_generator/manifest.yml +26 -10
  23. data/lib/mack/generators/mack_application_generator/templates/Rakefile.template +1 -1
  24. data/lib/mack/generators/mack_application_generator/templates/app/controllers/default_controller.rb.template +7 -1
  25. data/lib/mack/generators/mack_application_generator/templates/app/helpers/controllers/default_controller_helper.rb.template +1 -1
  26. data/lib/mack/generators/mack_application_generator/templates/app/helpers/views/application_helper.rb.template +3 -0
  27. data/lib/mack/generators/mack_application_generator/templates/app/views/default/index.html.erb.template +60 -2
  28. data/lib/mack/generators/mack_application_generator/templates/app/views/layouts/application.html.erb.template +10 -2
  29. data/lib/mack/generators/mack_application_generator/templates/config/app_config/default.yml.template +21 -0
  30. data/lib/mack/generators/mack_application_generator/templates/config/app_config/development.yml.template +1 -0
  31. data/lib/mack/generators/mack_application_generator/templates/config/app_config/production.yml.template +1 -0
  32. data/lib/mack/generators/mack_application_generator/templates/config/app_config/test.yml.template +1 -0
  33. data/lib/mack/generators/mack_application_generator/templates/config/database.yml.template +24 -0
  34. data/lib/mack/generators/mack_application_generator/templates/config/initializers/inflections.rb.template +13 -0
  35. data/lib/mack/generators/mack_application_generator/templates/config/initializers/mime_types.rb.template +1 -0
  36. data/lib/mack/generators/mack_application_generator/templates/public/stylesheets/scaffold.css.template +125 -29
  37. data/lib/mack/generators/mack_application_generator/templates/test/{functional → controllers}/default_controller_spec.rb.template +2 -0
  38. data/lib/mack/generators/mack_application_generator/templates/test/{functional → controllers}/default_controller_test.rb.template +2 -0
  39. data/lib/mack/generators/mack_application_generator/templates/test/helpers/controllers/default_controller_helper_spec.rb.template +6 -0
  40. data/lib/mack/generators/mack_application_generator/templates/test/helpers/controllers/default_controller_helper_test.rb.template +10 -0
  41. data/lib/mack/generators/mack_application_generator/templates/test/helpers/views/application_helper_spec.rb.template +6 -0
  42. data/lib/mack/generators/mack_application_generator/templates/test/helpers/views/application_helper_test.rb.template +10 -0
  43. data/lib/mack/generators/view_helper_generator/manifest.yml +15 -0
  44. data/lib/mack/generators/view_helper_generator/templates/app/helpers/views/helper.rb.template +7 -0
  45. data/lib/mack/generators/view_helper_generator/templates/test/helpers/views/rspec.rb.template +6 -0
  46. data/lib/mack/generators/view_helper_generator/templates/test/helpers/views/test_case.rb.template +10 -0
  47. data/lib/mack/generators/view_helper_generator/view_helper_generator.rb +16 -0
  48. data/lib/mack/initialization/application.rb +6 -6
  49. data/lib/mack/initialization/configuration.rb +17 -9
  50. data/lib/mack/initialization/helpers.rb +3 -3
  51. data/lib/mack/initialization/logging.rb +30 -20
  52. data/lib/mack/rendering/view_template.rb +1 -0
  53. data/lib/mack/routing/route_map.rb +10 -12
  54. data/lib/mack/routing/urls.rb +0 -40
  55. data/lib/mack/runner.rb +7 -2
  56. data/lib/mack/runner_helpers/request_logger.rb +1 -1
  57. data/lib/mack/runner_helpers/session.rb +13 -6
  58. data/lib/mack/tasks/mack_dump_tasks.rake +1 -8
  59. data/lib/mack/tasks/mack_tasks.rake +1 -1
  60. data/lib/mack/tasks/test_tasks.rake +2 -2
  61. data/lib/mack/testing/file.rb +28 -0
  62. data/lib/mack/testing/helpers.rb +59 -4
  63. data/lib/mack/testing/rspec.rb +19 -7
  64. data/lib/mack/utils/mime_types.yml +1 -0
  65. data/lib/mack/utils/server.rb +1 -1
  66. data/lib/mack/version.rb +3 -0
  67. data/lib/mack/view_helpers/date_time_helpers.rb +106 -0
  68. data/lib/mack/view_helpers/form_helpers.rb +282 -0
  69. data/lib/mack/view_helpers/html_helpers.rb +4 -88
  70. data/lib/mack/view_helpers/link_helpers.rb +171 -0
  71. data/lib/mack/view_helpers/object_helpers.rb +14 -0
  72. data/lib/mack/view_helpers/string_helpers.rb +41 -0
  73. data/lib/mack_app.rb +1 -0
  74. data/lib/mack_core.rb +3 -7
  75. data/lib/mack_tasks.rb +8 -16
  76. metadata +36 -27
  77. data/bin/mack_ring_server +0 -33
  78. data/lib/mack/core_extensions/string.rb +0 -21
  79. data/lib/mack/distributed/errors/errors.rb +0 -27
  80. data/lib/mack/distributed/routing/urls.rb +0 -44
  81. data/lib/mack/distributed/utils/rinda.rb +0 -45
  82. data/lib/mack/initialization/orm_support.rb +0 -20
  83. data/lib/mack/tasks/mack_ring_server_tasks.rake +0 -33
  84. data/lib/mack/utils/crypt/default_worker.rb +0 -28
  85. data/lib/mack/utils/crypt/keeper.rb +0 -46
@@ -1,9 +1,11 @@
1
1
  require File.join(File.dirname(__FILE__), "..", "spec_helper.rb")
2
2
 
3
3
  describe DefaultController do
4
+
4
5
  it "should be able to successfully connect to home page" do
5
6
  get home_page_url
6
7
  response.should be_successful
7
8
  response.body.should match(/Welcome to your Mack application!/)
8
9
  end
10
+
9
11
  end
@@ -2,9 +2,11 @@
2
2
  require File.join(File.dirname(__FILE__), "..", "test_helper.rb")
3
3
 
4
4
  class DefaultControllerTest < Test::Unit::TestCase
5
+
5
6
  def test_home_page
6
7
  get home_page_url
7
8
  assert_response :success
8
9
  assert_match("Welcome to your Mack application!", response.body)
9
10
  end
11
+
10
12
  end
@@ -0,0 +1,6 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
2
+
3
+ describe Mack::ControllerHelpers::DefaultController do
4
+ include Mack::ControllerHelpers::DefaultController
5
+
6
+ end
@@ -0,0 +1,10 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
2
+
3
+ class DefaultControllerHelperTest < Test::Unit::TestCase
4
+ include Mack::ControllerHelpers::DefaultController
5
+
6
+ def test_truth
7
+ assert true
8
+ end
9
+
10
+ end
@@ -0,0 +1,6 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
2
+
3
+ describe Mack::ViewHelpers::ApplicationHelper do
4
+ include Mack::ViewHelpers
5
+
6
+ end
@@ -0,0 +1,10 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
2
+
3
+ class ApplicationHelperTest < Test::Unit::TestCase
4
+ include Mack::ViewHelpers
5
+
6
+ def test_truth
7
+ assert true
8
+ end
9
+
10
+ end
@@ -0,0 +1,15 @@
1
+ helper_template:
2
+ type: file
3
+ template_path: <%= File.join(templates_directory_path, "app", "helpers", "views", "helper.rb.template") %>
4
+ output_path: <%= File.join("app", "helpers", "views", "#{@name_singular}_helper.rb") %>
5
+ <% if app_config.mack.testing_framework == "test_case" -%>
6
+ helper_test_template:
7
+ type: file
8
+ template_path: <%= File.join(templates_directory_path, "test", "helpers", "views", "test_case.rb.template") %>
9
+ output_path: <%= File.join("test", "helpers", "views", "#{@name_singular}_helper_test.rb") %>
10
+ <% elsif app_config.mack.testing_framework == "rspec" -%>
11
+ helper_test_template:
12
+ type: file
13
+ template_path: <%= File.join(templates_directory_path, "test", "helpers", "views", "rspec.rb.template") %>
14
+ output_path: <%= File.join("test", "helpers", "views", "#{@name_singular}_helper_spec.rb") %>
15
+ <% end -%>
@@ -0,0 +1,7 @@
1
+ module Mack
2
+ module ViewHelpers
3
+ module <%= @name_singular_camel %>Helper
4
+
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'spec_helper')
2
+
3
+ describe Mack::ViewHelpers::<%= @name_singular_camel %>Helper do
4
+ include Mack::ViewHelpers
5
+
6
+ end
@@ -0,0 +1,10 @@
1
+ require File.join(File.dirname(__FILE__), '..', '..', 'test_helper')
2
+
3
+ class <%= @name_singular_camel %>HelperTest < Test::Unit::TestCase
4
+ include Mack::ViewHelpers
5
+
6
+ def test_truth
7
+ assert true
8
+ end
9
+
10
+ end
@@ -0,0 +1,16 @@
1
+ # Generates view helpers for Mack applications.
2
+ #
3
+ # Example:
4
+ # rake generate:view_helper name=post
5
+ class ViewHelperGenerator < Genosaurus
6
+
7
+ require_param :name
8
+
9
+ def setup # :nodoc:
10
+ @name_singular = param(:name).singular.underscore
11
+ @name_plural = param(:name).plural.underscore
12
+ @name_singular_camel = @name_singular.camelcase
13
+ @name_plural_camel = @name_plural.camelcase
14
+ end
15
+
16
+ end
@@ -1,13 +1,13 @@
1
1
  # set up initializers:
2
- Mack.logger.debug "Initializing custom initializers..."
2
+ Mack.logger.debug "Initializing custom initializers..." unless app_config.log.disable_initialization_logging
3
3
  Dir.glob(File.join(Mack.root, "config", "initializers", "**/*.rb")) do |d|
4
4
  require d
5
5
  end
6
- Mack.logger.debug "Initializing custom gems..."
6
+ Mack.logger.debug "Initializing custom gems..." unless app_config.log.disable_initialization_logging
7
7
  Mack::Utils::GemManager.instance.do_requires
8
8
 
9
9
  # require 'plugins':
10
- Mack.logger.debug "Initializing plugins..."
10
+ Mack.logger.debug "Initializing plugins..." unless app_config.log.disable_initialization_logging
11
11
  require File.join(File.dirname(__FILE__), "plugins.rb")
12
12
 
13
13
  # make sure that default_controller is available to other controllers
@@ -15,17 +15,17 @@ path = File.join(Mack.root, "app", "controllers", "default_controller.rb")
15
15
  require path if File.exists?(path)
16
16
 
17
17
  # require 'lib' files:
18
- Mack.logger.debug "Initializing lib classes..."
18
+ Mack.logger.debug "Initializing lib classes..." unless app_config.log.disable_initialization_logging
19
19
  Dir.glob(File.join(Mack.root, "lib", "**/*.rb")).each do |d|
20
20
  require d
21
21
  end
22
22
 
23
23
  # set up routes:
24
- Mack.logger.debug "Initializing routes..."
24
+ Mack.logger.debug "Initializing routes..." unless app_config.log.disable_initialization_logging
25
25
  require File.join(Mack.root, "config", "routes")
26
26
 
27
27
  # require 'app' files:
28
- Mack.logger.debug "Initializing 'app' classes..."
28
+ Mack.logger.debug "Initializing 'app' classes..." unless app_config.log.disable_initialization_logging
29
29
  Dir.glob(File.join(Mack.root, "app", "**/*.rb")).each do |d|
30
30
  # puts "d: #{d}"
31
31
  begin
@@ -52,7 +52,6 @@ module Mack
52
52
  DEFAULTS_TEST = {
53
53
  "log_level" => "error",
54
54
  "run_remote_tests" => true,
55
- "mack::drb_timeout" => 0,
56
55
  "mack::cookie_values" => {}
57
56
  } unless self.const_defined?("DEFAULTS_TEST")
58
57
 
@@ -79,24 +78,33 @@ module Mack
79
78
  }
80
79
  },
81
80
  "mack::site_domain" => "http://localhost:3000",
82
- "mack::use_distributed_routes" => false,
83
- "mack::distributed_app_name" => nil,
84
- "mack::distributed_site_domain" => "http://localhost:3000",
85
- "mack::drb_timeout" => 1,
86
- "mack::default_respository_name" => "default",
87
81
  "mack::testing_framework" => "rspec",
88
82
  "log::detailed_requests" => true,
89
- "log::db_color" => "yellow",
83
+ "log::db_color" => "cyan",
90
84
  "log::error_color" => "red",
91
- "log::completed_color" => "green",
85
+ "log::fatal_color" => "red",
86
+ "log::warn_color" => "yellow",
87
+ "log::completed_color" => "purple",
92
88
  "log_level" => "info"
93
- }.merge(eval("DEFAULTS_#{Mack.env.upcase}"))
89
+ }#.merge(eval("DEFAULTS_#{Mack.env.upcase}"))
94
90
  end
95
91
 
96
92
  app_config.load_hash(DEFAULTS, "mack_defaults")
93
+ app_config.load_hash(eval("DEFAULTS_#{Mack.env.upcase}"), "mack_defaults_#{Mack.env}")
97
94
  app_config.load_file(File.join(Mack.root, "config", "app_config", "default.yml"))
98
95
  app_config.load_file(File.join(Mack.root, "config", "app_config", "#{Mack.env}.yml"))
99
96
  # app_config.reload
100
97
 
98
+ def self.dump
99
+ fcs = app_config.instance.instance_variable_get("@final_configuration_settings")
100
+ conf = {}
101
+ fcs.each_pair do |k, v|
102
+ unless v.is_a?(Application::Configuration::Namespace)
103
+ conf[k.to_s] = v unless k.to_s.match("__")
104
+ end
105
+ end
106
+ conf
107
+ end
108
+
101
109
  end
102
110
  end
@@ -1,8 +1,8 @@
1
1
  # Include ApplicationHelper into all controllers:
2
- Mack.logger.debug "Initializing helpers..."
2
+ Mack.logger.debug "Initializing helpers..." unless app_config.log.disable_initialization_logging
3
3
  # adding application_helper module into all defined controllers
4
4
  if Object.const_defined?("ApplicationHelper")
5
- Mack.logger.warn("ApplicationHelper has been deprecated! Please use move it to Mack::ViewHelpers::ApplicationHelper instead.")
5
+ deprecate_method("ApplicationHelper", "Mack::ViewHelpers::ApplicationHelper", "0.7.0")
6
6
  ApplicationHelper.include_safely_into(Mack::Rendering::ViewTemplate)
7
7
  end
8
8
 
@@ -27,5 +27,5 @@ end
27
27
  # Find view level Helpers and include them into the Mack::Rendering::ViewTemplate
28
28
  Mack::ViewHelpers.constants.each do |cont|
29
29
  h = "Mack::ViewHelpers::#{cont}".constantize
30
- h.include_safely_into(Mack::Rendering::ViewTemplate)
30
+ Mack::Rendering::ViewTemplate.send(:include, h)
31
31
  end
@@ -1,7 +1,7 @@
1
1
  #--
2
2
  # Configure logging
3
3
  #++
4
-
4
+ require File.join(File.dirname(__FILE__), "..", "utils", "ansi", "ansi_color")
5
5
  module Mack
6
6
 
7
7
  def self.logger
@@ -12,10 +12,30 @@ module Mack
12
12
  $mack_default_logger = log
13
13
  end
14
14
 
15
+ def self.reset_logger!
16
+ log_directory = app_config.log_root || File.join(Mack.root, "log")
17
+ begin
18
+ FileUtils.mkdir_p(log_directory)
19
+ rescue Exception => e
20
+ end
21
+
22
+ Mack.logger = Log4r::Logger.new('')
23
+ Mack.logger.level = Module.instance_eval("Log4r::#{(app_config.log_level || :info).to_s.upcase}")
24
+
25
+ format = Log4r::PatternFormatter.new(:pattern => "%l:\t[%d]\t%M")
26
+
27
+ if Mack.env == "development"
28
+ # console:
29
+ Mack.logger.add(Log4r::StdoutOutputter.new('console', :formatter => format))
30
+ end
31
+
32
+ # file:
33
+ Mack.logger.add(Log4r::FileOutputter.new('fileOutputter', :filename => File.join(log_directory, "#{Mack.env}.log"), :trunc => false, :formatter => format))
34
+ end
35
+
15
36
  end
16
37
 
17
38
  unless Mack.logger
18
-
19
39
  module Log4r # :nodoc:
20
40
  class IOOutputter # :nodoc:
21
41
 
@@ -28,10 +48,14 @@ unless Mack.logger
28
48
  case data
29
49
  when /^(DEBUG:|INFO:|WARN:|ERROR:|FATAL:)\s\[.*\]\s(SELECT|INSERT|UPDATE|DELETE|CREATE|DROP)/
30
50
  old_write(Mack::Utils::Ansi::Color.wrap(app_config.log.db_color, data))
31
- when /^(ERROR:|FATAL:)/
32
- old_write(Mack::Utils::Ansi::Color.wrap(app_config.log.error_color, data))
33
51
  else
34
- old_write(data)
52
+ level = data.match(/^\w+/).to_s
53
+ color = app_config.log.send("#{level.downcase}_color")
54
+ if color
55
+ old_write(Mack::Utils::Ansi::Color.wrap(color, data))
56
+ else
57
+ old_write(data)
58
+ end
35
59
  end
36
60
  end
37
61
 
@@ -40,21 +64,7 @@ unless Mack.logger
40
64
  end # IOOutputter
41
65
  end # Log4r
42
66
 
43
- log_directory = app_config.log_root || File.join(Mack.root, "log")
44
- FileUtils.mkdir_p(log_directory)
45
-
46
- Mack.logger = Log4r::Logger.new('')
47
- Mack.logger.level = Module.instance_eval("Log4r::#{(app_config.log_level || :info).to_s.upcase}")
48
-
49
- format = Log4r::PatternFormatter.new(:pattern => "%l:\t[%d]\t%M")
50
-
51
- if Mack.env == "development"
52
- # console:
53
- Mack.logger.add(Log4r::StdoutOutputter.new('console', :formatter => format))
54
- end
55
-
56
- # file:
57
- Mack.logger.add(Log4r::FileOutputter.new('fileOutputter', :filename => File.join(log_directory, "#{Mack.env}.log"), :trunc => false, :formatter => format))
67
+ Mack.reset_logger!
58
68
  end
59
69
 
60
70
  module Mack
@@ -14,6 +14,7 @@ module Mack
14
14
  self.render_value = render_value
15
15
  self.options = options
16
16
  @_yield_to_cache = {}
17
+ Thread.current[:view_template] = self
17
18
  end
18
19
 
19
20
  # Allows access to the current Mack::Controller object.
@@ -10,8 +10,7 @@ module Mack
10
10
  yield Mack::Routes::RouteMap.instance
11
11
  Mack::Routes::Urls.include_safely_into(Mack::Controller,
12
12
  Mack::Rendering::ViewTemplate,
13
- Test::Unit::TestCase,
14
- Mack::Distributed::Routes::Urls)
13
+ Test::Unit::TestCase)
15
14
  end
16
15
 
17
16
  # Routes are the back bone of the Mack framework. They are used to map incoming urls to controllers.
@@ -135,6 +134,7 @@ module Mack
135
134
  # If A HollyCrapError is thrown it will be caught and rendered using the OopsController and the 500 action.
136
135
  # You can catch all exceptions using Exception.
137
136
  class RouteMap
137
+ include Extlib::Hook
138
138
  include Singleton
139
139
 
140
140
  def initialize # :nodoc:
@@ -187,6 +187,7 @@ module Mack
187
187
  # also added to the 'params' object in the request.
188
188
  # If the route can not be found a Mack::Errors::UndefinedRoute exception is raised.
189
189
  def get_route_from_request(req)
190
+ orig_pattern = req.path_info.dup
190
191
  pattern = req.path_info.downcase
191
192
  unless pattern == "/"
192
193
  pattern.chop! if pattern.match(/\/$/)
@@ -199,7 +200,7 @@ module Mack
199
200
  rt.each do |route|
200
201
  if pattern.match(route.regex_pattern) && route.method == meth
201
202
  r = route
202
- opts = r.options_with_embedded_parameters(pattern)
203
+ opts = r.options_with_embedded_parameters(orig_pattern)
203
204
  req.merge_params(opts)
204
205
  return opts
205
206
  end
@@ -247,15 +248,6 @@ module Mack
247
248
  }
248
249
 
249
250
  Mack::Routes::Urls.class_eval(url)
250
-
251
- if app_config.mack.use_distributed_routes
252
-
253
- Mack::Routes::Urls.class_eval %{
254
- def #{n_route}_distributed_url(options = {})
255
- (@dsd || app_config.mack.distributed_site_domain) + #{n_route}_url(options)
256
- end
257
- }
258
- end
259
251
  end
260
252
 
261
253
  def regex_from_pattern(pattern)
@@ -316,6 +308,12 @@ module Mack
316
308
  opts[val] = split_uri[ind]
317
309
  end
318
310
  end
311
+ [:controller, :action].each do |key|
312
+ if opts[key]
313
+ opts[key] = opts[key].to_s.downcase.to_sym
314
+ end
315
+ end
316
+
319
317
  opts
320
318
  end
321
319
 
@@ -58,46 +58,6 @@ module Mack
58
58
  }
59
59
  end
60
60
 
61
- # Retrieves a distributed route from a DRb server.
62
- #
63
- # Example:
64
- # droute_url(:app_1, :home_page_url)
65
- # droute_url(:registration_app, :signup_url, {:from => :google})
66
- def droute_url(app_name, route_name, options = {})
67
- if app_config.mack.use_distributed_routes
68
- d_urls = Mack::Distributed::Routes::Urls.get(app_name)
69
- # return d_urls.send(route_name, options)
70
- # ivar_cache("droute_url_hash") do
71
- # {}
72
- # end
73
- # d_urls = @droute_url_hash[app_name.to_sym]
74
- # if d_urls.nil?
75
- # d_urls = Mack::Distributed::Routes::UrlCache.get(app_name.to_sym)
76
- # @droute_url_hash[app_name.to_sym] = d_urls
77
- # if d_urls.nil?
78
- # raise Mack::Distributed::Errors::UnknownApplication.new(app_name)
79
- # end
80
- # end
81
- route_name = route_name.to_s
82
- if route_name.match(/_url$/)
83
- unless route_name.match(/_distributed_url$/)
84
- route_name.gsub!("_url", "_distributed_url")
85
- end
86
- else
87
- route_name << "_distributed_url"
88
- end
89
- raise Mack::Distributed::Errors::UnknownRouteName.new(app_name, route_name) unless d_urls.respond_to?(route_name)
90
- return d_urls.run(route_name, options)
91
- # if d_urls.run.respond_to?(route_name)
92
- # return d_urls.run.send(route_name, options)
93
- # else
94
- # raise Mack::Distributed::Errors::UnknownRouteName.new(app_name, route_name)
95
- # end
96
- else
97
- return nil
98
- end
99
- end # droute_url
100
-
101
61
  end # Urls
102
62
  end # Routes
103
63
  end # Mack
@@ -10,6 +10,8 @@ module Mack
10
10
  attr_reader :request # :nodoc:
11
11
  attr_reader :cookies # :nodoc:
12
12
  attr_reader :runner_helpers # :nodoc:
13
+ attr_reader :original_controller
14
+ attr_reader :original_action
13
15
 
14
16
  # This method needs to be defined as part of the Rack framework. As is noted for the Mack::Runner
15
17
  # class, this is where the center of the Mack framework lies.
@@ -22,14 +24,17 @@ module Mack
22
24
  # because the route is specified to be a redirect, let's do that:
23
25
  redirect_to(route)
24
26
  else
25
- self.request.all_params[:original_controller] = route[:controller]
26
- self.request.all_params[:original_action] = route[:action]
27
+ # set these in case we need them for handling errors:
28
+ @original_controller = route[:controller]
29
+ @original_action = route[:action]
27
30
  run_controller(route)
28
31
  end
29
32
  # rescue Mack::Errors::ResourceNotFound, Mack::Errors::UndefinedRoute => e
30
33
  # return try_to_find_resource(env, e)
31
34
  rescue Exception => e
32
35
  route = Mack::Routes::RouteMap.instance.get_route_from_error(e.class)
36
+ self.request.all_params[:original_controller] = @original_controller
37
+ self.request.all_params[:original_action] = @original_action
33
38
  unless route.nil?
34
39
  run_controller(route, e)
35
40
  else