Skip to content

Commit

Permalink
hopefully add the shell environment to the default templating
Browse files Browse the repository at this point in the history
  • Loading branch information
atmos committed Nov 23, 2009
1 parent 512cd0e commit 870c790
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
12 changes: 12 additions & 0 deletions lib/notice.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@
%backtrace
- backtrace.each do |line|
%line{:method => line.method, :file => line.file, :number => line.number}
%request
%url= url
%component= component
- if request && request.params.any?
%params
- request.params.each do |key,value|
%var{:key => key}= value
- if environment && environment.any?
%cgi-data
- environment.each do |key,value|
%var{:key => key}= value

%server-environment
%project-root= Dir.pwd
%environment-name= framework_env
13 changes: 9 additions & 4 deletions lib/toadhopper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,17 @@ def filter(hash)
end

private
def document_for(exception)
locals = { :error => exception,
def document_for(exception, options = { })
locals = {
:error => exception,
:api_key => api_key,
:environment => scrub_environment(ENV.to_hash),
:backtrace => Backtrace.from_exception(exception),
:framework_env => ENV['RACK_ENV'] || 'development' }
:backtrace => Backtrace.from_exception(exception),
:url => 'http://localhost/',
:component => 'http://localhost/',
:request => nil,
:framework_env => ENV['RACK_ENV'] || 'development' }.merge(options)

Haml::Engine.new(notice_template).render(Object.new, locals)
end

Expand Down
4 changes: 2 additions & 2 deletions test/helper.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'rubygems'
Bundler.require_env(:test)

require File.dirname(__FILE__) + "/../lib/toadhopper"
require File.join(File.dirname(__FILE__), "..", "lib", "toadhopper")
require 'ruby-debug'
require 'test/unit'

0 comments on commit 870c790

Please sign in to comment.