exception2db 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (213) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/Rakefile +48 -0
  3. data/app/controllers/exception2db/main_controller.rb +34 -0
  4. data/app/models/e2db.rb +68 -0
  5. data/app/views/exception2db/main/index.html.erb +15 -0
  6. data/app/views/exception2db/main/show.html.erb +77 -0
  7. data/app/views/layouts/exception2db.html.erb +25 -0
  8. data/config/routes.rb +12 -0
  9. data/init.rb +23 -0
  10. data/lib/css/style.css +377 -0
  11. data/lib/exception2db.rb +27 -0
  12. data/lib/exception2db/config.rb +22 -0
  13. data/lib/exception2db/railtie.rb +12 -0
  14. data/lib/exception2db/util.rb +17 -0
  15. data/lib/exception2db/version.rb +3 -0
  16. data/lib/js/app.js +1 -0
  17. data/spec/exception2db_spec.rb +74 -0
  18. data/spec/spec_helper.rb +175 -0
  19. data/test/error_xml.rb +134 -0
  20. data/test/rails_root/Rakefile +10 -0
  21. data/test/rails_root/app/controllers/application_controller.rb +10 -0
  22. data/test/rails_root/app/controllers/articles_controller.rb +7 -0
  23. data/test/rails_root/app/models/article.rb +25 -0
  24. data/test/rails_root/app/models/city.rb +15 -0
  25. data/test/rails_root/app/models/comment.rb +13 -0
  26. data/test/rails_root/app/models/tech_magazine.rb +2 -0
  27. data/test/rails_root/app/models/vehicle/car.rb +4 -0
  28. data/test/rails_root/app/models/vehicle/door.rb +3 -0
  29. data/test/rails_root/app/models/vehicle/engine.rb +3 -0
  30. data/test/rails_root/config/boot.rb +110 -0
  31. data/test/rails_root/config/database.yml +14 -0
  32. data/test/rails_root/config/environment.rb +17 -0
  33. data/test/rails_root/config/environments/cucumber.rb +26 -0
  34. data/test/rails_root/config/environments/development.rb +0 -0
  35. data/test/rails_root/config/environments/test.rb +0 -0
  36. data/test/rails_root/config/initializers/new_rails_defaults.rb +19 -0
  37. data/test/rails_root/config/routes.rb +6 -0
  38. data/test/rails_root/db/migrate/20090809061114_create_tables.rb +15 -0
  39. data/test/rails_root/db/schema.rb +74 -0
  40. data/test/rails_root/db/sqlite3.db +0 -0
  41. data/test/rails_root/log/cucumber.log +3531 -0
  42. data/test/rails_root/log/development.log +445 -0
  43. data/test/rails_root/log/test.log +59223 -0
  44. data/test/rails_root/script/console +3 -0
  45. data/test/rails_root/script/dbconsole +3 -0
  46. data/test/rails_root/script/runner +3 -0
  47. data/test/rails_root/script/server +3 -0
  48. data/test/rspec-rails/Contribute.rdoc +4 -0
  49. data/test/rspec-rails/History.rdoc +283 -0
  50. data/test/rspec-rails/License.txt +33 -0
  51. data/test/rspec-rails/Manifest.txt +165 -0
  52. data/test/rspec-rails/README.rdoc +45 -0
  53. data/test/rspec-rails/Rakefile +72 -0
  54. data/test/rspec-rails/TODO.txt +17 -0
  55. data/test/rspec-rails/Upgrade.rdoc +148 -0
  56. data/test/rspec-rails/generators/integration_spec/integration_spec_generator.rb +10 -0
  57. data/test/rspec-rails/generators/integration_spec/templates/integration_spec.rb +4 -0
  58. data/test/rspec-rails/generators/rspec/CHANGES +1 -0
  59. data/test/rspec-rails/generators/rspec/rspec_generator.rb +53 -0
  60. data/test/rspec-rails/generators/rspec/templates/previous_failures.txt +0 -0
  61. data/test/rspec-rails/generators/rspec/templates/rcov.opts +2 -0
  62. data/test/rspec-rails/generators/rspec/templates/rspec.rake +144 -0
  63. data/test/rspec-rails/generators/rspec/templates/script/autospec +6 -0
  64. data/test/rspec-rails/generators/rspec/templates/script/spec +10 -0
  65. data/test/rspec-rails/generators/rspec/templates/spec.opts +4 -0
  66. data/test/rspec-rails/generators/rspec/templates/spec_helper.rb +54 -0
  67. data/test/rspec-rails/generators/rspec_controller/USAGE +33 -0
  68. data/test/rspec-rails/generators/rspec_controller/rspec_controller_generator.rb +47 -0
  69. data/test/rspec-rails/generators/rspec_controller/templates/controller_spec.rb +25 -0
  70. data/test/rspec-rails/generators/rspec_controller/templates/helper_spec.rb +11 -0
  71. data/test/rspec-rails/generators/rspec_controller/templates/view_spec.rb +12 -0
  72. data/test/rspec-rails/generators/rspec_default_values.rb +28 -0
  73. data/test/rspec-rails/generators/rspec_model/USAGE +18 -0
  74. data/test/rspec-rails/generators/rspec_model/rspec_model_generator.rb +35 -0
  75. data/test/rspec-rails/generators/rspec_model/templates/model_spec.rb +13 -0
  76. data/test/rspec-rails/generators/rspec_scaffold/rspec_scaffold_generator.rb +154 -0
  77. data/test/rspec-rails/generators/rspec_scaffold/templates/controller_spec.rb +131 -0
  78. data/test/rspec-rails/generators/rspec_scaffold/templates/edit_erb_spec.rb +25 -0
  79. data/test/rspec-rails/generators/rspec_scaffold/templates/helper_spec.rb +11 -0
  80. data/test/rspec-rails/generators/rspec_scaffold/templates/index_erb_spec.rb +27 -0
  81. data/test/rspec-rails/generators/rspec_scaffold/templates/new_erb_spec.rb +25 -0
  82. data/test/rspec-rails/generators/rspec_scaffold/templates/routing_spec.rb +33 -0
  83. data/test/rspec-rails/generators/rspec_scaffold/templates/show_erb_spec.rb +22 -0
  84. data/test/rspec-rails/init.rb +9 -0
  85. data/test/rspec-rails/lib/autotest/discover.rb +5 -0
  86. data/test/rspec-rails/lib/autotest/rails_rspec.rb +76 -0
  87. data/test/rspec-rails/lib/spec/rails.rb +26 -0
  88. data/test/rspec-rails/lib/spec/rails/example.rb +48 -0
  89. data/test/rspec-rails/lib/spec/rails/example/assigns_hash_proxy.rb +39 -0
  90. data/test/rspec-rails/lib/spec/rails/example/controller_example_group.rb +278 -0
  91. data/test/rspec-rails/lib/spec/rails/example/cookies_proxy.rb +29 -0
  92. data/test/rspec-rails/lib/spec/rails/example/functional_example_group.rb +106 -0
  93. data/test/rspec-rails/lib/spec/rails/example/helper_example_group.rb +153 -0
  94. data/test/rspec-rails/lib/spec/rails/example/integration_example_group.rb +16 -0
  95. data/test/rspec-rails/lib/spec/rails/example/model_example_group.rb +14 -0
  96. data/test/rspec-rails/lib/spec/rails/example/render_observer.rb +80 -0
  97. data/test/rspec-rails/lib/spec/rails/example/routing_example_group.rb +13 -0
  98. data/test/rspec-rails/lib/spec/rails/example/routing_helpers.rb +66 -0
  99. data/test/rspec-rails/lib/spec/rails/example/view_example_group.rb +199 -0
  100. data/test/rspec-rails/lib/spec/rails/extensions.rb +11 -0
  101. data/test/rspec-rails/lib/spec/rails/extensions/action_controller/rescue.rb +42 -0
  102. data/test/rspec-rails/lib/spec/rails/extensions/action_controller/test_case.rb +16 -0
  103. data/test/rspec-rails/lib/spec/rails/extensions/action_controller/test_response.rb +21 -0
  104. data/test/rspec-rails/lib/spec/rails/extensions/action_view/base.rb +33 -0
  105. data/test/rspec-rails/lib/spec/rails/extensions/active_record/base.rb +45 -0
  106. data/test/rspec-rails/lib/spec/rails/extensions/active_support/test_case.rb +7 -0
  107. data/test/rspec-rails/lib/spec/rails/extensions/spec/matchers/have.rb +23 -0
  108. data/test/rspec-rails/lib/spec/rails/extensions/spec/runner/configuration.rb +44 -0
  109. data/test/rspec-rails/lib/spec/rails/interop/testcase.rb +14 -0
  110. data/test/rspec-rails/lib/spec/rails/matchers.rb +33 -0
  111. data/test/rspec-rails/lib/spec/rails/matchers/ar_be_valid.rb +46 -0
  112. data/test/rspec-rails/lib/spec/rails/matchers/assert_select.rb +180 -0
  113. data/test/rspec-rails/lib/spec/rails/matchers/change.rb +13 -0
  114. data/test/rspec-rails/lib/spec/rails/matchers/have_text.rb +57 -0
  115. data/test/rspec-rails/lib/spec/rails/matchers/include_text.rb +54 -0
  116. data/test/rspec-rails/lib/spec/rails/matchers/redirect_to.rb +126 -0
  117. data/test/rspec-rails/lib/spec/rails/matchers/render_template.rb +129 -0
  118. data/test/rspec-rails/lib/spec/rails/matchers/route_to.rb +149 -0
  119. data/test/rspec-rails/lib/spec/rails/mocks.rb +135 -0
  120. data/test/rspec-rails/lib/spec/rails/version.rb +16 -0
  121. data/test/rspec-rails/spec/autotest/mappings_spec.rb +86 -0
  122. data/test/rspec-rails/spec/rails_suite.rb +7 -0
  123. data/test/rspec-rails/spec/resources/controllers/action_view_base_spec_controller.rb +2 -0
  124. data/test/rspec-rails/spec/resources/controllers/application.rb +9 -0
  125. data/test/rspec-rails/spec/resources/controllers/controller_spec_controller.rb +127 -0
  126. data/test/rspec-rails/spec/resources/controllers/example.txt +1 -0
  127. data/test/rspec-rails/spec/resources/controllers/redirect_spec_controller.rb +70 -0
  128. data/test/rspec-rails/spec/resources/controllers/render_spec_controller.rb +34 -0
  129. data/test/rspec-rails/spec/resources/controllers/rjs_spec_controller.rb +58 -0
  130. data/test/rspec-rails/spec/resources/helpers/addition_helper.rb +5 -0
  131. data/test/rspec-rails/spec/resources/helpers/explicit_helper.rb +46 -0
  132. data/test/rspec-rails/spec/resources/helpers/more_explicit_helper.rb +5 -0
  133. data/test/rspec-rails/spec/resources/helpers/plugin_application_helper.rb +6 -0
  134. data/test/rspec-rails/spec/resources/helpers/view_spec_helper.rb +13 -0
  135. data/test/rspec-rails/spec/resources/models/animal.rb +4 -0
  136. data/test/rspec-rails/spec/resources/models/person.rb +18 -0
  137. data/test/rspec-rails/spec/resources/models/thing.rb +3 -0
  138. data/test/rspec-rails/spec/resources/views/controller_spec/_partial.html.erb +0 -0
  139. data/test/rspec-rails/spec/resources/views/controller_spec/action_setting_flash_after_session_reset.html.erb +1 -0
  140. data/test/rspec-rails/spec/resources/views/controller_spec/action_setting_flash_before_session_reset.html.erb +1 -0
  141. data/test/rspec-rails/spec/resources/views/controller_spec/action_setting_the_assigns_hash.html.erb +0 -0
  142. data/test/rspec-rails/spec/resources/views/controller_spec/action_with_errors_in_template.html.erb +1 -0
  143. data/test/rspec-rails/spec/resources/views/controller_spec/action_with_template.html.erb +1 -0
  144. data/test/rspec-rails/spec/resources/views/controller_spec/non_existent_action_with_existent_template.html.erb +0 -0
  145. data/test/rspec-rails/spec/resources/views/layouts/application.html.erb +0 -0
  146. data/test/rspec-rails/spec/resources/views/layouts/simple.html.erb +0 -0
  147. data/test/rspec-rails/spec/resources/views/objects/_object.html.erb +1 -0
  148. data/test/rspec-rails/spec/resources/views/render_spec/_a_partial.html.erb +0 -0
  149. data/test/rspec-rails/spec/resources/views/render_spec/action_with_alternate_layout.html.erb +0 -0
  150. data/test/rspec-rails/spec/resources/views/render_spec/some_action.html.erb +0 -0
  151. data/test/rspec-rails/spec/resources/views/render_spec/some_action.js.rjs +1 -0
  152. data/test/rspec-rails/spec/resources/views/rjs_spec/_replacement_partial.html.erb +1 -0
  153. data/test/rspec-rails/spec/resources/views/rjs_spec/hide_div.js.rjs +1 -0
  154. data/test/rspec-rails/spec/resources/views/rjs_spec/hide_page_element.js.rjs +1 -0
  155. data/test/rspec-rails/spec/resources/views/rjs_spec/insert_html.js.rjs +1 -0
  156. data/test/rspec-rails/spec/resources/views/rjs_spec/replace.js.rjs +1 -0
  157. data/test/rspec-rails/spec/resources/views/rjs_spec/replace_html.js.rjs +1 -0
  158. data/test/rspec-rails/spec/resources/views/rjs_spec/replace_html_with_partial.js.rjs +1 -0
  159. data/test/rspec-rails/spec/resources/views/rjs_spec/visual_effect.js.rjs +1 -0
  160. data/test/rspec-rails/spec/resources/views/rjs_spec/visual_toggle_effect.js.rjs +1 -0
  161. data/test/rspec-rails/spec/resources/views/tag_spec/no_tags.html.erb +1 -0
  162. data/test/rspec-rails/spec/resources/views/tag_spec/single_div_with_no_attributes.html.erb +1 -0
  163. data/test/rspec-rails/spec/resources/views/tag_spec/single_div_with_one_attribute.html.erb +1 -0
  164. data/test/rspec-rails/spec/resources/views/view_spec/_partial.html.erb +2 -0
  165. data/test/rspec-rails/spec/resources/views/view_spec/_partial_used_twice.html.erb +0 -0
  166. data/test/rspec-rails/spec/resources/views/view_spec/_partial_with_local_variable.html.erb +1 -0
  167. data/test/rspec-rails/spec/resources/views/view_spec/_partial_with_sub_partial.html.erb +1 -0
  168. data/test/rspec-rails/spec/resources/views/view_spec/_spacer.html.erb +1 -0
  169. data/test/rspec-rails/spec/resources/views/view_spec/accessor.html.erb +5 -0
  170. data/test/rspec-rails/spec/resources/views/view_spec/block_helper.html.erb +3 -0
  171. data/test/rspec-rails/spec/resources/views/view_spec/entry_form.html.erb +2 -0
  172. data/test/rspec-rails/spec/resources/views/view_spec/explicit_helper.html.erb +2 -0
  173. data/test/rspec-rails/spec/resources/views/view_spec/foo/show.html.erb +1 -0
  174. data/test/rspec-rails/spec/resources/views/view_spec/implicit_helper.html.erb +2 -0
  175. data/test/rspec-rails/spec/resources/views/view_spec/multiple_helpers.html.erb +3 -0
  176. data/test/rspec-rails/spec/resources/views/view_spec/path_params.html.erb +1 -0
  177. data/test/rspec-rails/spec/resources/views/view_spec/should_not_receive.html.erb +3 -0
  178. data/test/rspec-rails/spec/resources/views/view_spec/template_with_partial.html.erb +5 -0
  179. data/test/rspec-rails/spec/resources/views/view_spec/template_with_partial_using_collection.html.erb +3 -0
  180. data/test/rspec-rails/spec/resources/views/view_spec/template_with_partial_with_array.html.erb +1 -0
  181. data/test/rspec-rails/spec/resources/views/view_spec/view_helpers.html.erb +1 -0
  182. data/test/rspec-rails/spec/spec/rails/example/assigns_hash_proxy_spec.rb +109 -0
  183. data/test/rspec-rails/spec/spec/rails/example/configuration_spec.rb +65 -0
  184. data/test/rspec-rails/spec/spec/rails/example/controller_example_group_spec.rb +307 -0
  185. data/test/rspec-rails/spec/spec/rails/example/controller_isolation_spec.rb +75 -0
  186. data/test/rspec-rails/spec/spec/rails/example/cookies_proxy_spec.rb +87 -0
  187. data/test/rspec-rails/spec/spec/rails/example/error_handling_spec.rb +90 -0
  188. data/test/rspec-rails/spec/spec/rails/example/example_group_factory_spec.rb +112 -0
  189. data/test/rspec-rails/spec/spec/rails/example/helper_example_group_spec.rb +233 -0
  190. data/test/rspec-rails/spec/spec/rails/example/model_example_group_spec.rb +20 -0
  191. data/test/rspec-rails/spec/spec/rails/example/routing_example_group_spec.rb +10 -0
  192. data/test/rspec-rails/spec/spec/rails/example/shared_routing_example_group_examples.rb +237 -0
  193. data/test/rspec-rails/spec/spec/rails/example/test_unit_assertion_accessibility_spec.rb +33 -0
  194. data/test/rspec-rails/spec/spec/rails/example/view_example_group_spec.rb +349 -0
  195. data/test/rspec-rails/spec/spec/rails/extensions/action_view_base_spec.rb +74 -0
  196. data/test/rspec-rails/spec/spec/rails/extensions/active_record_spec.rb +14 -0
  197. data/test/rspec-rails/spec/spec/rails/interop/testcase_spec.rb +70 -0
  198. data/test/rspec-rails/spec/spec/rails/matchers/ar_be_valid_spec.rb +19 -0
  199. data/test/rspec-rails/spec/spec/rails/matchers/assert_select_spec.rb +835 -0
  200. data/test/rspec-rails/spec/spec/rails/matchers/errors_on_spec.rb +37 -0
  201. data/test/rspec-rails/spec/spec/rails/matchers/have_text_spec.rb +69 -0
  202. data/test/rspec-rails/spec/spec/rails/matchers/include_text_spec.rb +62 -0
  203. data/test/rspec-rails/spec/spec/rails/matchers/redirect_to_spec.rb +253 -0
  204. data/test/rspec-rails/spec/spec/rails/matchers/render_template_spec.rb +208 -0
  205. data/test/rspec-rails/spec/spec/rails/matchers/should_change_spec.rb +15 -0
  206. data/test/rspec-rails/spec/spec/rails/mocks/ar_classes.rb +10 -0
  207. data/test/rspec-rails/spec/spec/rails/mocks/mock_model_spec.rb +106 -0
  208. data/test/rspec-rails/spec/spec/rails/mocks/stub_model_spec.rb +80 -0
  209. data/test/rspec-rails/spec/spec/rails/sample_modified_fixture.rb +8 -0
  210. data/test/rspec-rails/spec/spec/rails/sample_spec.rb +8 -0
  211. data/test/rspec-rails/spec/spec/rails/spec_spec.rb +11 -0
  212. data/test/rspec-rails/spec/spec_helper.rb +78 -0
  213. metadata +476 -0
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 [name of plugin creator]
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,48 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+
5
+ desc 'Default: run unit tests.'
6
+ task :default => :test
7
+
8
+ desc 'Test exception2db gem.'
9
+ Rake::TestTask.new(:test) do |t|
10
+ t.libs << 'lib' << 'test'
11
+ t.pattern = 'test/**/*_test.rb'
12
+ t.verbose = true
13
+ end
14
+
15
+ desc 'Generate documentation for exception2db gem.'
16
+ Rake::RDocTask.new(:rdoc) do |rdoc|
17
+ rdoc.rdoc_dir = 'rdoc'
18
+ rdoc.title = 'exception2db'
19
+ rdoc.options << '--line-numbers' << '--inline-source'
20
+ rdoc.rdoc_files.include('README.textile')
21
+ rdoc.rdoc_files.include('lib/**/*.rb')
22
+ end
23
+
24
+ begin
25
+ require 'jeweler'
26
+ require './lib/exception2db/version'
27
+ Jeweler::Tasks.new do |s|
28
+ s.name = "exception2db"
29
+ s.version = Exception2db::VERSION
30
+ s.summary = s.description = "Store exceptions in local datbase using Hoptoad API"
31
+ s.email = "neerajdotname@gmail.com"
32
+ s.homepage = "http://github.com/neerajdotname/exception2db"
33
+ s.authors = ['Neeraj Singh']
34
+ s.files = FileList["[A-Z]*", "{app,config,lib,test}/**/*", 'init.rb']
35
+
36
+ s.add_dependency('will_paginate', '>= 3.0.pre2')
37
+ s.add_dependency('hoptoad_notifier', '>= 2.3.5')
38
+
39
+ s.add_development_dependency 'flexmock', '>= 0.8.7'
40
+ s.add_development_dependency 'shoulda', '>= 2.11.3'
41
+ s.add_development_dependency 'factory_girl_rails'
42
+ s.add_development_dependency 'nokogiri', '>= 1.4.3.1'
43
+ end
44
+ Jeweler::GemcutterTasks.new
45
+ rescue LoadError => le
46
+ puts "Jeweler not available. Install it for jeweler-related tasks with: gem install jeweler: #{le.message}"
47
+ end
48
+
@@ -0,0 +1,34 @@
1
+ class Exception2db::MainController < ApplicationController
2
+
3
+ unloadable
4
+
5
+ layout 'exception2db'
6
+
7
+ before_filter :ensure_is_allowed_to_view
8
+
9
+ def index
10
+ @exception2dbs = E2db.paginate(:page => params[:page], :order => 'created_at desc')
11
+ respond_to do |format|
12
+ format.html
13
+ end
14
+ end
15
+
16
+ def show
17
+ @record = E2db.find(params[:id])
18
+ respond_to do |format|
19
+ format.html
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def ensure_is_allowed_to_view
26
+ # not using Rails.env.development? because cucumber test was failing with Rails.env
27
+ # but worked with RAILS_ENV. need to investigate further. TODO
28
+ return true if RAILS_ENV == 'production'
29
+ unless Exception2dbConfig.setting[:is_allowed_to_view].call(self)
30
+ render :text => '<h2>Not Authorized</h2>', :status => :unauthorized
31
+ end
32
+ end
33
+
34
+ end
@@ -0,0 +1,68 @@
1
+ class E2db < ActiveRecord::Base
2
+ set_table_name 'exception2dbs'
3
+
4
+ validates_presence_of :exception
5
+
6
+ def document
7
+ @document ||= REXML::Document.new(self.exception)
8
+ end
9
+
10
+ def error_message
11
+ REXML::XPath.first(document, '//notice/error/message/text()').to_s
12
+ end
13
+
14
+ def cgi_data
15
+ {}.tap { |e| REXML::XPath.each(document, '//notice/request/cgi-data/var') { |node| e.store(node.attributes['key'].to_s, node.text) } }
16
+ end
17
+
18
+ def user_agent
19
+ node = REXML::XPath.first(document, '//notice/request/cgi-data/var[@key="HTTP_USER_AGENT"]')
20
+ node.blank? ? "N/A" : node.text
21
+ end
22
+
23
+ def parameters
24
+ output = [].tap{ |e|
25
+ REXML::XPath.each(document, '//notice/request/params/var') do |node|
26
+ item = ':' + node.attributes['key'].to_s
27
+ item << ' => '
28
+ item << (node.text || '')
29
+ e << item
30
+ end
31
+ }.join(' , ')
32
+
33
+ '{ ' + output + ' }'
34
+ end
35
+
36
+ def controller
37
+ REXML::XPath.first(document, '//notice/request/component/text()').to_s
38
+ end
39
+
40
+ def action
41
+ REXML::XPath.first(document, '//notice/request/action/text()').to_s
42
+ end
43
+
44
+ def url
45
+ REXML::XPath.first(document, '//notice/request/url/text()').to_s
46
+ end
47
+
48
+ def environment
49
+ REXML::XPath.first(document, '//notice/server-environment/environment-name/text()').to_s
50
+ end
51
+
52
+ def top_file_and_line_number
53
+ top_file = REXML::XPath.match(document, '//notice/error/backtrace/line').first
54
+ "#{top_file.attributes['file']}:#{top_file.attributes['number']}"
55
+ end
56
+
57
+ def formatted_backtrace
58
+ REXML::XPath.match(document, '//notice/error/backtrace/line').inject('') do |sum, elem|
59
+ sum << '<p>'
60
+ sum << elem.attributes['file']
61
+ sum << ':'
62
+ sum << elem.attributes['number']
63
+ sum << ':in '
64
+ sum << elem.attributes['method']
65
+ sum << '</p>'
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,15 @@
1
+ <% @exception2dbs.each do |exception2db|
2
+ @doc = REXML::Document.new(exception2db.exception) %>
3
+ <h2>
4
+ <%= exception2db.created_at.strftime('%B %d, %Y %I:%M:%S %p') %>
5
+ <%= link_to REXML::XPath.first(@doc,
6
+ '//notice/error/message/text()'),
7
+ "/exception2db/#{exception2db.id}" %>
8
+ </h2>
9
+ <% end %>
10
+
11
+ <% if @exception2dbs.blank? %>
12
+ <h2>So far no exceptions. </h2>
13
+ <% end %>
14
+
15
+ <%= will_paginate @exception2dbs %>
@@ -0,0 +1,77 @@
1
+ <table class='translations'>
2
+ <tr>
3
+ <td class='translation'>Error</td>
4
+ <td class="phrase">
5
+ <%= @record.error_message %>
6
+ </td>
7
+ </tr>
8
+
9
+ <tr>
10
+ <td class='translation'>Action</td>
11
+ <td class='phrase'>
12
+ <%= @record.controller %>#<%= @record.action %>
13
+ </td>
14
+ </tr>
15
+
16
+ <tr>
17
+ <td class='translation'>URL</td>
18
+ <td class='phrase'>
19
+ <%=link_to(@record.url, @record.url)%>
20
+ </td>
21
+ </tr>
22
+
23
+ <tr>
24
+ <td class='translation'>Rails environment</td>
25
+ <td class='phrase'>
26
+ <%= @record.environment %>
27
+ </td>
28
+ </tr>
29
+
30
+ <tr>
31
+ <td class='translation'>User Agent</td>
32
+ <td class='phrase'>
33
+ <%= @record.user_agent %>
34
+ </td>
35
+ </tr>
36
+
37
+ <tr>
38
+ <td class='translation'>Received at</td>
39
+ <td class='phrase'>
40
+ <%= @record.created_at.strftime('%B %d, %Y %I:%M:%S %p') %>
41
+ </td>
42
+ </tr>
43
+
44
+ <tr>
45
+ <td class='translation'>
46
+ Parameters
47
+ </th>
48
+ <td class='phrase'>
49
+ <%= @record.parameters %>
50
+ </td>
51
+ </tr>
52
+
53
+ <tr>
54
+ <td class='translation'>File</td>
55
+ <td class='phrase'>
56
+ <%= @record.top_file_and_line_number %>
57
+ </td>
58
+ </tr>
59
+ </table>
60
+
61
+ <br />
62
+
63
+ <table class="translations">
64
+ <% @record.cgi_data.each_pair do |key,value| %>
65
+ <tr>
66
+ <td class='translation'><%=key%></td>
67
+ <td class='phrase'>
68
+ <%=value%>
69
+ </td>
70
+ </tr>
71
+ <% end %>
72
+ </table>
73
+
74
+ <pre>
75
+ <%= @record.formatted_backtrace %>
76
+ </pre>
77
+
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3
+
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
6
+ <title>excption2db <%=@page_title%></title>
7
+ <%= Exception2db::Util.stylesheet_link_tag('style')%>
8
+ <%= javascript_include_tag('http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js') %>
9
+ <%= Exception2db::Util.javascript_include_tag('app')%>
10
+ </head>
11
+
12
+ <body>
13
+ <div id="container">
14
+ <div id="head">
15
+ <h1><span class="home"><a href="/exception2db">exception2db</a></span></h1>
16
+ </div>
17
+ <%= yield %>
18
+ <p id='footer'>
19
+ <a href="http://github.com/neerajdotname/exception2db">Powered by exception2db</a>
20
+ <a href="http://github.com/neerajdotname/exception2db/issues">Report bug</a>
21
+ </p>
22
+ </div>
23
+ </body>
24
+ </html>
25
+
@@ -0,0 +1,12 @@
1
+ Rails.application.routes.draw do |map|
2
+
3
+ map.namespace(:exception2db) do |edb|
4
+
5
+ edb.with_options :controller => 'main' do |m|
6
+ m.index '/', :action => 'index'
7
+ m.show ':id', :action => 'show'
8
+ end
9
+
10
+ end
11
+
12
+ end
data/init.rb ADDED
@@ -0,0 +1,23 @@
1
+ def load_will_paginate
2
+ begin
3
+ require 'will_paginate'
4
+ rescue LoadError => e
5
+ $stderr.puts %{
6
+ ************************************************
7
+ * gem will_paginate is missing *
8
+ * plugin exception2db depends on will_paginate *
9
+ * Please install will_paginate by executing *
10
+ * sudo gem install will_paginate *
11
+ ************************************************
12
+ }
13
+ end
14
+ end
15
+
16
+ load_will_paginate
17
+
18
+ require File.join(RAILS_ROOT, 'vendor', 'plugins', 'exception2db', 'lib', 'exception2db', 'config.rb')
19
+ Exception2dbConfig.initialize_defaults
20
+
21
+ require File.join(RAILS_ROOT, 'vendor', 'plugins', 'exception2db', 'lib', 'exception2db', 'util.rb')
22
+
23
+ require 'rexml/document'
@@ -0,0 +1,377 @@
1
+ /*-------------------------------------------------
2
+ RESET
3
+ -------------------------------------------------*/
4
+
5
+ body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td {
6
+ margin:0;
7
+ padding:0;
8
+ }
9
+ table {
10
+ border-collapse:collapse;
11
+ border-spacing:0;
12
+ }
13
+ fieldset,img {border:0;}
14
+ address,caption,cite,code,dfn,th,var {
15
+ font-style:normal;
16
+ font-weight:normal;
17
+ }
18
+
19
+ h1,h2,h3,h4,h5,h6 {
20
+ font-size:100%;
21
+ font-weight:normal;
22
+ }
23
+
24
+ ol,ul {list-style:none;}
25
+ caption,th {text-align:left;}
26
+ q:before,q:after {content:'';}
27
+ abbr,acronym {border:0;}
28
+
29
+ img {border: none;}
30
+ em em {font-style: normal;}
31
+
32
+ /*-------------------------------------------------
33
+ Defaults
34
+ -------------------------------------------------*/
35
+
36
+ acronym, abbr {
37
+ font-variant: small-caps;
38
+ text-transform: lowercase;
39
+ font-weight: bold;
40
+ }
41
+
42
+ .center {text-align: center;}
43
+ .large {font-size: larger;}
44
+ .small {font-size: smaller;}
45
+ strong {font-weight: bold;}
46
+ em {font-style: italic;}
47
+
48
+ .clear {clear: both;}
49
+ .clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
50
+ .clearfix { display: inline-block; }
51
+ .clearfix{ display: block; }
52
+
53
+ a {color: #888;}
54
+ a:hover {color: #000;}
55
+
56
+ /*-------------------------------------------------
57
+ Layout
58
+ -------------------------------------------------*/
59
+
60
+ body {
61
+ font-family: "Lucida Sans", "Lucida Grande", "Lucida Sans Unicode", sans-serif;
62
+ background: #e5e5e5;
63
+ color: #333;
64
+ margin: 0;
65
+ padding: 0;
66
+ font-size: 14px;
67
+ line-height: 21px;
68
+ text-align: left;
69
+ }
70
+
71
+ div#container {
72
+ margin: 2% 4%;
73
+ padding: 25px;
74
+ background: #fff;
75
+ -webkit-border-radius: 20px;
76
+ -moz-border-radius: 20px;
77
+ border-radius: 20px;
78
+ box-shadow: 0px 0px 15px rgba(00,00,00,0.5);
79
+ -moz-box-shadow: 0px 0px 15px rgba(00,00,00,0.5);
80
+ -webkit-box-shadow: 0px 0px 15px rgba(00,00,00,0.5);
81
+ }
82
+
83
+ div#head {
84
+ margin: -25px -25px 0;
85
+ background: #111;
86
+ color: #999;
87
+ padding: 25px 25px 20px 15px;
88
+ -webkit-border-top-left-radius: 20px;
89
+ -webkit-border-top-right-radius: 20px;
90
+ -moz-border-radius-topleft: 20px;
91
+ -moz-border-radius-topright: 20px;
92
+ border-top-left-radius: 20px;
93
+ border-top-right-radius: 20px;
94
+ font-size: 18px;
95
+ }
96
+
97
+ div#head a {
98
+ color: #2fadcf;
99
+ font-weight: bold;
100
+ text-decoration: none;
101
+ }
102
+
103
+ div#head span.home {
104
+ -webkit-border-top-left-radius: 10px;
105
+ -webkit-border-bottom-left-radius: 10px;
106
+ -moz-border-radius-topleft: 10px;
107
+ -moz-border-radius-bottomleft: 10px;
108
+ border-top-left-radius: 10px;
109
+ border-bottom-left-radius: 10px;
110
+ background: #333;
111
+ padding: 8px 6px 8px 12px;
112
+ margin-right: 1px;
113
+ }
114
+
115
+ div#head span.locale {
116
+ color: #fff;
117
+ font-weight: bold;
118
+ background: #444;
119
+ padding: 8px 12px 8px 6px;
120
+ -webkit-border-top-right-radius: 10px;
121
+ -webkit-border-bottom-right-radius: 10px;
122
+ -moz-border-radius-topright: 10px;
123
+ -moz-border-radius-bottomright: 10px;
124
+ border-top-right-radius: 10px;
125
+ border-bottom-right-radius: 10px;
126
+ }
127
+
128
+ div#head span.locale.empty {
129
+ background: #333;
130
+ padding-left: 0;
131
+ margin-left: -6px;
132
+ }
133
+
134
+ div#head span.locale em {
135
+ font-style: normal;
136
+ font-weight: normal;
137
+ }
138
+
139
+ div#head span.note {
140
+ color: #777;
141
+ font-size: 13px;
142
+ font-weight: normal;
143
+ margin-left: 10px;
144
+ }
145
+
146
+ h2,
147
+ h3 {
148
+ font-size: 18px;
149
+ color: #2fadcf;
150
+ margin: 25px 0 10px;
151
+ }
152
+
153
+ h2 span,
154
+ h3 span {
155
+ font-size: 13px;
156
+ color: #888;
157
+ }
158
+
159
+ ul.locales {
160
+ margin: 25px 0;
161
+ }
162
+
163
+ ul.locales li {
164
+ /*width: 230px;*/
165
+ width: 150px;
166
+ display: block;
167
+ float: left;
168
+ margin: 0 10px 10px 0;
169
+ /* background: #fff;
170
+ -webkit-border-radius: 5px;
171
+ -moz-border-radius: 5px;
172
+ border-radius: 5px;
173
+ border: 1px solid #e5e5e5;
174
+ padding: 5px 10px;*/
175
+ }
176
+
177
+ ul.locales a {
178
+ font-weight: bold;
179
+ text-decoration: underline;
180
+ color: #2fadcf;
181
+ }
182
+
183
+ /*ul.locales li:hover {
184
+ background: #f5f5f5;
185
+ border-color: #ccc;
186
+ }*/
187
+
188
+ ul.locales span.missing_translations {
189
+ color: #fff;
190
+ font-weight: bold;
191
+ background: #c00;
192
+ font-size: 9px;
193
+ padding: 3px;
194
+ -webkit-border-radius: 3px;
195
+ -moz-border-radius: 3px;
196
+ border-radius: 3px;
197
+ line-height: 9px;
198
+ vertical-align: top;
199
+ display: inline-block;
200
+ }
201
+
202
+ ul.locales span {
203
+ font-size: 13px;
204
+ color: #666;
205
+ }
206
+
207
+ div.submit {
208
+ background: #f5f5f5;
209
+ margin: 25px -25px -25px;
210
+ padding: 15px 25px;
211
+ border-top: 1px dashed #ccc;
212
+ -webkit-border-bottom-right-radius: 20px;
213
+ -webkit-border-bottom-left-radius: 20px;
214
+ -moz-border-radius-bottomright: 20px;
215
+ -moz-border-radius-bottomleft: 20px;
216
+ border-bottom-right-radius: 20px;
217
+ border-bottom-left-radius: 20px;
218
+ }
219
+
220
+ span.updated {
221
+ font-size: 11px;
222
+ padding: 1px;
223
+ background: #ffc;
224
+ color: #777;
225
+ margin-bottom: 10px;
226
+ float: right;
227
+ }
228
+
229
+ div.table_submit {
230
+ background: #f5f5f5;
231
+ margin: -25px 0 0;
232
+ padding: 12px 15px 15px;
233
+ text-align: left;
234
+ }
235
+
236
+ div.translations {
237
+ width: 96%;
238
+ text-align: center;
239
+ }
240
+
241
+ span.notice {
242
+ background: #ffc;
243
+ color: #666;
244
+ font-size: 12px;
245
+ padding: 2px 5px;
246
+ margin: -5px 0 15px;
247
+ display: inline-block;
248
+ }
249
+
250
+ div.original {
251
+ color: #999;
252
+ margin: 5px 0;
253
+ padding: 1px 8px 4px;
254
+ }
255
+
256
+ div.updated {
257
+ background: #ffc;
258
+ padding: 1px 8px 4px;
259
+ }
260
+
261
+ table.translations div.original span.key {
262
+ margin: 0 0 -2px;
263
+ padding: 0;
264
+ }
265
+
266
+ table.translations div.updated span.key {
267
+ margin: 0 0 -2px;
268
+ color: orange !important;
269
+ padding: 0;
270
+ }
271
+
272
+ /*-------------------------------------------------
273
+ Translation tables
274
+ -------------------------------------------------*/
275
+
276
+ table.translations {
277
+ margin: 0 0 25px;
278
+ width: 100%;
279
+ text-align: left;
280
+ }
281
+
282
+ table.translations td,
283
+ table.translations th {
284
+ font-size: 14px;
285
+ color: #222;
286
+ padding: 12px 8px;
287
+ border-bottom: 1px solid #e5e5e5;
288
+ vertical-align: top;
289
+ width: 50%;
290
+ }
291
+
292
+ table.translations th {
293
+ border-bottom-color: #bbb;
294
+ font-size: 11px;
295
+ font-weight: bold;
296
+ text-transform: uppercase;
297
+ color: #999;
298
+ padding-bottom: 2px;
299
+ }
300
+
301
+ table.translations textarea.locale {
302
+ font-family: "Lucida Sans", "Lucida Grande", "Lucida Sans Unicode", sans-serif;
303
+ font-size: 14px;
304
+ line-height: 21px;
305
+ color: #222;
306
+ padding: 1px;
307
+ width: 100%;
308
+ height: 42px;
309
+ }
310
+
311
+ table.translations span.key {
312
+ color: #aaa;
313
+ font-size: 9px;
314
+ display: block;
315
+ }
316
+
317
+ table.translations td.translation {
318
+ padding: 10px 8px;
319
+ }
320
+
321
+ table.translations tr.active td {
322
+ background: #edf9fe;
323
+ }
324
+
325
+ table.translations .highlight {
326
+ background-color: yellow;
327
+ }
328
+
329
+ /*-------------------------------------------------
330
+ Pagination
331
+ -------------------------------------------------*/
332
+
333
+ div.paginate {
334
+ margin: 15px auto 20px;
335
+ font-size: 12px;
336
+ color: #777;
337
+ }
338
+
339
+ div.paginate a,
340
+ div.paginate span {
341
+ padding: 2px 6px;
342
+ text-decoration: none;
343
+ }
344
+
345
+ div.paginate a:hover,
346
+ div.paginate span.current {
347
+ -webkit-border-radius: 5px;
348
+ -moz-border-radius: 5px;
349
+ border-radius: 5px;
350
+ background: #eee;
351
+ color: #333;
352
+ }
353
+
354
+ div.paginate .next_page,
355
+ div.paginate .prev_page {
356
+ margin: 0 15px;
357
+ -webkit-border-radius: 5px;
358
+ -moz-border-radius: 5px;
359
+ border-radius: 5px;
360
+ border: 1px solid #bbb;
361
+ padding: 4px 8px;
362
+ }
363
+
364
+ div.paginate .disabled {
365
+ color: #ccc;
366
+ border-color: #eee;
367
+ }
368
+
369
+ /*-------------------------------------------------
370
+ Custom Work
371
+ -------------------------------------------------*/
372
+ table.translations td.translation {
373
+ width:20%;
374
+ }
375
+ p#footer {
376
+ margin-top: 10px;
377
+ }