Changeset 4158
- Timestamp:
- 04/04/06 19:37:29 (2 years ago)
- Files:
-
- trunk/actionpack/CHANGELOG (modified) (1 diff)
- trunk/actionpack/lib/action_controller/templates/rescues/diagnostics.rhtml (modified) (1 diff)
- trunk/activesupport/CHANGELOG (modified) (1 diff)
- trunk/activesupport/lib/active_support/core_ext/exception.rb (modified) (2 diffs)
- trunk/activesupport/lib/active_support/core_ext/pathname (added)
- trunk/activesupport/lib/active_support/core_ext/pathname.rb (added)
- trunk/activesupport/lib/active_support/core_ext/pathname/clean_within.rb (added)
- trunk/activesupport/test/core_ext/exception_test.rb (modified) (1 diff)
- trunk/activesupport/test/core_ext/symbol_test.rb (moved) (moved from trunk/activesupport/test/core_ext/symbol.rb) (1 diff)
- trunk/activesupport/test/core_ext/symbol_tests.rb (copied) (copied from trunk/activesupport/test/core_ext/symbol.rb)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/CHANGELOG
r4157 r4158 1 1 *SVN* 2 3 * Update the diagnostics template skip the useless '<controller not set>' text. [Nicholas Seckar] 2 4 3 5 * CHANGED DEFAULT: Don't parse YAML input by default, but keep it available as an easy option [DHH] trunk/actionpack/lib/action_controller/templates/rescues/diagnostics.rhtml
r2624 r4158 1 1 <h1> 2 <%=h @exception.class.to_s %> in 3 <%=h (@request.parameters["controller"] || "<controller not set>").capitalize %>#<%=h @request.parameters["action"] || "<action not set>" %> 2 <%=h @exception.class.to_s %> 3 <% if @request.parameters['controller'] %> 4 in <%=h @request.parameters['controller'].humanize %>Controller<% if @request.parameters['action'] %>#<%=h @request.parameters['action'] %><% end %> 5 <% end %> 4 6 </h1> 5 7 <pre><%=h @exception.clean_message %></pre> trunk/activesupport/CHANGELOG
r4136 r4158 1 1 * SVN * 2 3 * Clean paths inside of exception messages and traces. [Nicholas Seckar] 4 5 * Add Pathname.clean_within for cleaning all the paths inside of a string. [Nicholas Seckar] 2 6 3 7 * provide an empty Dependencies::LoadingModule.load which prints deprecation warnings. Lets 1.0 applications function with .13-style environment.rb. trunk/activesupport/lib/active_support/core_ext/exception.rb
r3493 r4158 1 class Exception 2 alias :clean_message :message 1 class Exception # :nodoc: 2 def clean_message 3 Pathname.clean_within message 4 end 3 5 4 6 TraceSubstitutions = [] 5 FrameworkRegexp = /generated _code|vendor|dispatch|ruby|script\/\w+/7 FrameworkRegexp = /generated|vendor|dispatch|ruby|script\/\w+/ 6 8 7 9 def clean_backtrace 8 10 backtrace.collect do |line| 9 TraceSubstitutions.inject(line) do |line, (regexp, sub)|11 Pathname.clean_within(TraceSubstitutions.inject(line) do |line, (regexp, sub)| 10 12 line.gsub regexp, sub 11 end 13 end) 12 14 end 13 15 end … … 16 18 before_application_frame = true 17 19 18 clean_backtrace.reject do |line|19 non_app_frame = !!(line =~ FrameworkRegexp)20 trace = clean_backtrace.reject do |line| 21 non_app_frame = (line =~ FrameworkRegexp) 20 22 before_application_frame = false unless non_app_frame 21 23 non_app_frame && ! before_application_frame 22 24 end 25 26 # If we didn't find any application frames, return an empty app trace. 27 before_application_frame ? [] : trace 23 28 end 24 29 trunk/activesupport/test/core_ext/exception_test.rb
r2676 r4158 42 42 assert_equal ['vendor/file.rb some stuff', ' vendor/file.rb some stuff'], e.framework_backtrace 43 43 end 44 45 44 45 def test_backtrace_should_clean_paths 46 Exception::TraceSubstitutions << [/\s*hidden.*/, ''] 47 e = get_exception RuntimeError, 'RAWR', ['a/b/c/../d/../../../bhal.rb', 'rawh hid den stuff is not here', 'almost all'] 48 assert_kind_of Exception, e 49 assert_equal ['bhal.rb', 'rawh hid den stuff is not here', 'almost all'], e.clean_backtrace 50 end 51 52 def test_clean_message_should_clean_paths 53 Exception::TraceSubstitutions << [/\s*hidden.*/, ''] 54 e = get_exception RuntimeError, "I dislike a/z/x/../../b/y/../c", ['a/b/c/../d/../../../bhal.rb', 'rawh hid den stuff is not here', 'almost all'] 55 assert_kind_of Exception, e 56 assert_equal "I dislike a/b/c", e.clean_message 57 end 58 59 def test_app_trace_should_be_empty_when_no_app_frames 60 Exception::TraceSubstitutions << [/\s*hidden.*/, ''] 61 e = get_exception RuntimeError, 'RAWR', ['vendor/file.rb some stuff', 'generated/bhal.rb', ' vendor/file.rb some stuff', 'generated/almost all'] 62 assert_kind_of Exception, e 63 assert_equal [], e.application_backtrace 64 end 46 65 end trunk/activesupport/test/core_ext/symbol_test.rb
r3118 r4158 2 2 require File.dirname(__FILE__) + '/../../lib/active_support/core_ext/symbol' 3 3 4 class TestSymbol < Test::Case::TestUnit4 class SymbolTests < Test::Unit::TestCase 5 5 def test_to_proc 6 assert_equal %w(one two three), [:one, :two, :three].map &:to_s6 assert_equal %w(one two three), [:one, :two, :three].map(&:to_s) 7 7 end 8 8 end