Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

removing old hoptoad notifier

  • Loading branch information...
commit c5afc6ff4d509ed338b6e9a7b3eaffdbba249b04 1 parent 51ce46b
@rick authored
Showing with 0 additions and 3,820 deletions.
  1. +0 −3  vendor/plugins/hoptoad_notifier/.yardopts
  2. +0 −25 vendor/plugins/hoptoad_notifier/INSTALL
  3. +0 −22 vendor/plugins/hoptoad_notifier/MIT-LICENSE
  4. +0 −227 vendor/plugins/hoptoad_notifier/README.rdoc
  5. +0 −29 vendor/plugins/hoptoad_notifier/Rakefile
  6. +0 −8 vendor/plugins/hoptoad_notifier/TESTING.rdoc
  7. +0 −31 vendor/plugins/hoptoad_notifier/ginger_scenarios.rb
  8. +0 −1  vendor/plugins/hoptoad_notifier/init.rb
  9. +0 −1  vendor/plugins/hoptoad_notifier/install.rb
  10. +0 −150 vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier.rb
  11. +0 −99 vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/backtrace.rb
  12. +0 −95 vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/catcher.rb
  13. +0 −229 vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/configuration.rb
  14. +0 −295 vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/notice.rb
  15. +0 −63 vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/sender.rb
  16. +0 −37 vendor/plugins/hoptoad_notifier/lib/hoptoad_tasks.rb
  17. +0 −91 vendor/plugins/hoptoad_notifier/lib/templates/rescue.erb
  18. +0 −8 vendor/plugins/hoptoad_notifier/rails/init.rb
  19. +0 −24 vendor/plugins/hoptoad_notifier/recipes/hoptoad.rb
  20. +0 −38 vendor/plugins/hoptoad_notifier/script/integration_test.rb
  21. +0 −89 vendor/plugins/hoptoad_notifier/tasks/hoptoad_notifier_tasks.rake
  22. +0 −94 vendor/plugins/hoptoad_notifier/test/backtrace_test.rb
  23. +0 −314 vendor/plugins/hoptoad_notifier/test/catcher_test.rb
  24. +0 −199 vendor/plugins/hoptoad_notifier/test/configuration_test.rb
  25. +0 −238 vendor/plugins/hoptoad_notifier/test/helper.rb
  26. +0 −76 vendor/plugins/hoptoad_notifier/test/hoptoad_2_0.xsd
  27. +0 −138 vendor/plugins/hoptoad_notifier/test/hoptoad_tasks_test.rb
  28. +0 −85 vendor/plugins/hoptoad_notifier/test/logger_test.rb
  29. +0 −357 vendor/plugins/hoptoad_notifier/test/notice_test.rb
  30. +0 −222 vendor/plugins/hoptoad_notifier/test/notifier_test.rb
  31. +0 −123 vendor/plugins/hoptoad_notifier/test/sender_test.rb
  32. +0 −1  vendor/plugins/hoptoad_notifier/vendor/ginger/.gitignore
  33. +0 −20 vendor/plugins/hoptoad_notifier/vendor/ginger/LICENCE
  34. +0 −50 vendor/plugins/hoptoad_notifier/vendor/ginger/README.textile
  35. +0 −57 vendor/plugins/hoptoad_notifier/vendor/ginger/Rakefile
  36. +0 −42 vendor/plugins/hoptoad_notifier/vendor/ginger/bin/ginger
  37. +0 −33 vendor/plugins/hoptoad_notifier/vendor/ginger/ginger.gemspec
  38. +0 −21 vendor/plugins/hoptoad_notifier/vendor/ginger/lib/ginger.rb
  39. +0 −20 vendor/plugins/hoptoad_notifier/vendor/ginger/lib/ginger/configuration.rb
  40. +0 −56 vendor/plugins/hoptoad_notifier/vendor/ginger/lib/ginger/kernel.rb
  41. +0 −24 vendor/plugins/hoptoad_notifier/vendor/ginger/lib/ginger/scenario.rb
  42. +0 −7 vendor/plugins/hoptoad_notifier/vendor/ginger/spec/ginger/configuration_spec.rb
  43. +0 −7 vendor/plugins/hoptoad_notifier/vendor/ginger/spec/ginger/kernel_spec.rb
  44. +0 −50 vendor/plugins/hoptoad_notifier/vendor/ginger/spec/ginger/scenario_spec.rb
  45. +0 −14 vendor/plugins/hoptoad_notifier/vendor/ginger/spec/ginger_spec.rb
  46. +0 −7 vendor/plugins/hoptoad_notifier/vendor/ginger/spec/spec_helper.rb
View
3  vendor/plugins/hoptoad_notifier/.yardopts
@@ -1,3 +0,0 @@
--
-TESTING.rdoc
-MIT-LICENSE
View
25 vendor/plugins/hoptoad_notifier/INSTALL
@@ -1,25 +0,0 @@
-=== Configuration
-
-You should have something like this in config/initializers/hoptoad.rb.
-
- HoptoadNotifier.configure do |config|
- config.api_key = '1234567890abcdef'
- end
-
-(Please note that this configuration should be in a global configuration, and
-is *not* environment-specific. Hoptoad is smart enough to know what errors are
-caused by what environments, so your staging errors don't get mixed in with
-your production errors.)
-
-You can test that Hoptoad is working in your production environment by using
-this rake task (from RAILS_ROOT):
-
- rake hoptoad:test
-
-If everything is configured properly, that task will send a notice to Hoptoad
-which will be visible immediately.
-
-NOTE FOR RAILS 1.2.* USERS:
-
-You will need to copy the hoptoad_notifier_tasks.rake file into your
-RAILS_ROOT/lib/tasks directory in order for the rake hoptoad:test task to work.
View
22 vendor/plugins/hoptoad_notifier/MIT-LICENSE
@@ -1,22 +0,0 @@
-Copyright (c) 2007, Tammer Saleh, Thoughtbot, Inc.
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
View
227 vendor/plugins/hoptoad_notifier/README.rdoc
@@ -1,227 +0,0 @@
-= HoptoadNotifier
-
-This is the notifier plugin for integrating apps with Hoptoad.
-
-When an uncaught exception occurs, HoptoadNotifier will POST the relevant data
-to the Hoptoad server specified in your environment.
-
-== Help
-
-* {IRC}[irc://irc.freenode.net/thoughtbot]
-* {mailing list}[http://groups.google.com/group/hoptoad-notifier-dev]
-
-== Installation
-
-=== Remove exception_notifier
-
-in your ApplicationController, REMOVE this line:
-
- include ExceptionNotifiable
-
-In your config/environment* files, remove all references to ExceptionNotifier
-
-Remove the vendor/plugins/exception_notifier directory.
-
-=== Install hoptoad_notifier
-
-from your project's RAILS_ROOT, run:
-
- script/plugin install -f git://github.com/thoughtbot/hoptoad_notifier.git
-
-=== Configuration
-
-You should have something like this in config/initializers/hoptoad.rb.
-
- HoptoadNotifier.configure do |config|
- config.api_key = '1234567890abcdef'
- end
-
-(Please note that this configuration should be in a global configuration, and
-is *not* environment-specific. Hoptoad is smart enough to know what errors are
-caused by what environments, so your staging errors don't get mixed in with
-your production errors.)
-
-After adding to your config/initializers like this you must restart your
-server. This will not affect the rake task but it bears stating.
-
-That should be it! Now all exceptions will be logged to Hoptoad where they can
-be aggregated, filtered, sorted, analyzed, massaged, and searched. In previous
-releases you had to include HoptoadNotifier::Catcher into your
-ApplicationController, but the plugin takes care of that now.
-
-You can test that Hoptoad is working in your production environment by using
-this rake task (from RAILS_ROOT):
-
- rake hoptoad:test
-
-If everything is configured properly, that task will send a notice to Hoptoad
-which will be visible immediately.
-
-=== NOTE FOR RAILS 1.2.* USERS:
-
-You will need to copy the hoptoad_notifier_tasks.rake file into your
-RAILS_ROOT/lib/tasks directory in order for the rake hoptoad:test task to work.
-
-== Usage
-
-for the most part, Hoptoad works for itself. Once you've included the notifier
-in your ApplicationController (which is now done automatically by the plugin),
-all errors will be rescued by the #rescue_action_in_public provided by the plugin.
-
-If you want to log arbitrary things which you've rescued yourself from a
-controller, you can do something like this:
-
- ...
- rescue => ex
- notify_hoptoad(ex)
- flash[:failure] = 'Encryptions could not be rerouted, try again.'
- end
- ...
-
-The #notify_hoptoad call will send the notice over to Hoptoad for later analysis. While in your controllers you use the notify_hoptoad method, anywhere else in your code, use HoptoadNotifier.notify.
-
-To perform custom error processing after Hoptoad has been notified, define the instance method #rescue_action_in_public_without_hoptoad(exception) in your controller.
-
-== Tracking deployments in Hoptoad
-
-Paying Hoptoad plans support the ability to track deployments of your application in Hoptoad.
-By notifying Hoptoad of your application deployments, all errors are resolved when a deploy occurs,
-so that you'll be notified again about any errors that reoccur after a deployment.
-
-Additionally, it's possible to review the errors in Hoptoad that occurred before and after a deploy.
-
-When Hoptoad is installed as a plugin this functionality is loaded automatically (if you have Capistrano version 2.0.0 or greater).
-
-When Hoptoad is installed as a gem, you need to add
-
- require 'hoptoad_notifier/recipes/hoptoad'
-
-to your deploy.rb
-
-== Going beyond exceptions
-
-You can also pass a hash to notify_hoptoad method and store whatever you want, not just an exception. And you can also use it anywhere, not just in controllers:
-
- begin
- params = {
- # params that you pass to a method that can throw an exception
- }
- my_unpredicable_method(params)
- rescue => e
- HoptoadNotifier.notify(
- :error_class => "Special Error",
- :error_message => "Special Error: #{e.message}",
- :parameters => params
- )
- end
-
-While in your controllers you use the notify_hoptoad method, anywhere else in your code, use HoptoadNotifier.notify. Hoptoad will get all the information about the error itself. As for a hash, these are the keys you should pass:
-
-* :error_class – Use this to group similar errors together. When Hoptoad catches an exception it sends the class name of that exception object.
-* :error_message – This is the title of the error you see in the errors list. For exceptions it is "#{exception.class.name}: #{exception.message}"
-* :parameters – While there are several ways to send additional data to Hoptoad, passing a Hash as :parameters as in the example above is the most common use case. When Hoptoad catches an exception in a controller, the actual HTTP client request parameters are sent using this key.
-
-Hoptoad merges the hash you pass with these default options:
-
- {
- :api_key => HoptoadNotifier.api_key,
- :error_message => 'Notification',
- :backtrace => caller,
- :parameters => {},
- :session => {}
- }
-
-You can override any of those parameters.
-
-== Filtering
-
-You can specify a whitelist of errors, that Hoptoad will not report on. Use
-this feature when you are so apathetic to certain errors that you don't want
-them even logged.
-
-This filter will only be applied to automatic notifications, not manual
-notifications (when #notify is called directly).
-
-Hoptoad ignores the following exceptions by default:
-
- ActiveRecord::RecordNotFound
- ActionController::RoutingError
- ActionController::InvalidAuthenticityToken
- ActionController::UnknownAction
- CGI::Session::CookieStore::TamperedWithCookie
-
-To ignore errors in addition to those, specify their names in your Hoptoad
-configuration block.
-
- HoptoadNotifier.configure do |config|
- config.api_key = '1234567890abcdef'
- config.ignore << ActiveRecord::IgnoreThisError
- end
-
-To ignore *only* certain errors (and override the defaults), use the
-#ignore_only attribute.
-
- HoptoadNotifier.configure do |config|
- config.api_key = '1234567890abcdef'
- config.ignore_only = [ActiveRecord::IgnoreThisError]
- end
-
-To ignore certain user agents, add in the #ignore_user_agent attribute as a
-string or regexp:
-
- HoptoadNotifier.configure do |config|
- config.api_key = '1234567890abcdef'
- config.ignore_user_agent << /Ignored/
- config.ignore_user_agent << 'IgnoredUserAgent'
- end
-
-To ignore exceptions based on other conditions, use #ignore_by_filter:
-
- HoptoadNotifier.configure do |config|
- config.api_key = '1234567890abcdef'
- config.ignore_by_filter do |exception_data|
- true if exception_data[:error_class] == "RuntimeError"
- end
- end
-
-To replace sensitive information sent to the Hoptoad service with [FILTERED] use #params_filters:
-
- HoptoadNotifier.configure do |config|
- config.api_key = '1234567890abcdef'
- config.params_filters << "credit_card_number"
- end
-
-Note that, when rescuing exceptions within an ActionController method,
-hoptoad_notifier will reuse filters specified by #filter_params_logging.
-
-== Testing
-
-When you run your tests, you might notice that the Hoptoad service is recording
-notices generated using #notify when you don't expect it to. You can
-use code like this in your test_helper.rb to redefine that method so those
-errors are not reported while running tests.
-
- module HoptoadNotifier::Catcher
- def notify(thing)
- # do nothing.
- end
- end
-
-== Supported rails versions
-
-the notifier currently supports the following versions of Rails:
-
-* 1.2.6
-* 2.0.2
-* 2.1.0
-* 2.1.2
-* 2.2.2
-* 2.3.2
-* 2.3.3
-* 2.3.4
-
-Please open up a support ticket on Tender ( http://help.hoptoadapp.com ) if you're using a version of Rails that is not listed above and the notifier is not working properly.
-
-== Thanks
-
-Thanks to Eugene Bolshakov for the excellent write-up on GOING BEYOND EXCEPTIONS, which we have included above.
View
29 vendor/plugins/hoptoad_notifier/Rakefile
@@ -1,29 +0,0 @@
-require 'rake'
-require 'rake/testtask'
-require 'rake/rdoctask'
-
-desc 'Default: run unit tests.'
-task :default => :test
-
-desc 'Test the hoptoad_notifier plugin.'
-Rake::TestTask.new(:test) do |t|
- t.libs << 'lib'
- t.pattern = 'test/**/*_test.rb'
- t.verbose = true
-end
-
-desc 'Run ginger tests'
-task :ginger do
- $LOAD_PATH << File.join(*%w[vendor ginger lib])
- ARGV.clear
- ARGV << 'test'
- load File.join(*%w[vendor ginger bin ginger])
-end
-
-begin
- require 'yard'
- YARD::Rake::YardocTask.new do |t|
- t.files = ['lib/**/*.rb', 'TESTING.rdoc']
- end
-rescue LoadError
-end
View
8 vendor/plugins/hoptoad_notifier/TESTING.rdoc
@@ -1,8 +0,0 @@
-= For Maintainers:
-
-When developing the Hoptoad Notifier, be sure to use the integration test
-against an existing project on staging before pushing to master.
-
-+./script/integration_test.rb <test project's api key> <staging server hostname>+
-
-+./script/integration_test.rb <test project's api key> <staging server hostname> secure+
View
31 vendor/plugins/hoptoad_notifier/ginger_scenarios.rb
@@ -1,31 +0,0 @@
-require 'ginger'
-
-def create_scenario(version)
- scenario = Ginger::Scenario.new
- scenario[/^active_?support$/] = version
- scenario[/^active_?record$/] = version
- scenario[/^action_?pack$/] = version
- scenario[/^action_?controller$/] = version
- scenario
-end
-
-Ginger.configure do |config|
- config.aliases["active_record"] = "activerecord"
- config.aliases["active_support"] = "activesupport"
- config.aliases["action_controller"] = "actionpack"
-
- rails_1_2_6 = Ginger::Scenario.new
- rails_1_2_6[/^active_?support$/] = "1.4.4"
- rails_1_2_6[/^active_?record$/] = "1.15.6"
- rails_1_2_6[/^action_?pack$/] = "1.13.6"
- rails_1_2_6[/^action_?controller$/] = "1.13.6"
-
- config.scenarios << rails_1_2_6
- config.scenarios << create_scenario("2.0.2")
- config.scenarios << create_scenario("2.1.2")
- config.scenarios << create_scenario("2.2.2")
- config.scenarios << create_scenario("2.3.2")
- # Rails 2.3.3 has broken params filtering
- # config.scenarios << create_scenario("2.3.3")
- config.scenarios << create_scenario("2.3.4")
-end
View
1  vendor/plugins/hoptoad_notifier/init.rb
@@ -1 +0,0 @@
-require File.join(File.dirname(__FILE__), 'rails', 'init')
View
1  vendor/plugins/hoptoad_notifier/install.rb
@@ -1 +0,0 @@
-puts IO.read(File.join(File.dirname(__FILE__), 'INSTALL'))
View
150 vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier.rb
@@ -1,150 +0,0 @@
-require 'net/http'
-require 'net/https'
-require 'rubygems'
-require 'active_support'
-require 'hoptoad_notifier/configuration'
-require 'hoptoad_notifier/notice'
-require 'hoptoad_notifier/sender'
-require 'hoptoad_notifier/catcher'
-require 'hoptoad_notifier/backtrace'
-
-# Plugin for applications to automatically post errors to the Hoptoad of their choice.
-module HoptoadNotifier
-
- VERSION = "2.0.16"
- API_VERSION = "2.0"
- LOG_PREFIX = "** [Hoptoad] "
-
- HEADERS = {
- 'Content-type' => 'text/xml',
- 'Accept' => 'text/xml, application/xml'
- }
-
- class << self
- # The sender object is responsible for delivering formatted data to the Hoptoad server.
- # Must respond to #send_to_hoptoad. See HoptoadNotifier::Sender.
- attr_accessor :sender
-
- # A Hoptoad configuration object. Must act like a hash and return sensible
- # values for all Hoptoad configuration options. See HoptoadNotifier::Configuration.
- attr_accessor :configuration
-
- # Tell the log that the Notifier is good to go
- def report_ready
- write_verbose_log("Notifier #{VERSION} ready to catch errors")
- end
-
- # Prints out the environment info to the log for debugging help
- def report_environment_info
- write_verbose_log("Environment Info: #{environment_info}")
- end
-
- # Prints out the response body from Hoptoad for debugging help
- def report_response_body(response)
- write_verbose_log("Response from Hoptoad: \n#{response}")
- end
-
- # Returns the Ruby version, Rails version, and current Rails environment
- def environment_info
- info = "[Ruby: #{RUBY_VERSION}]"
- info << " [Rails: #{::Rails::VERSION::STRING}]" if defined?(Rails)
- info << " [Env: #{configuration.environment_name}]"
- end
-
- # Writes out the given message to the #logger
- def write_verbose_log(message)
- logger.info LOG_PREFIX + message if logger
- end
-
- # Look for the Rails logger currently defined
- def logger
- if defined?(Rails.logger)
- Rails.logger
- elsif defined?(RAILS_DEFAULT_LOGGER)
- RAILS_DEFAULT_LOGGER
- end
- end
-
- # Call this method to modify defaults in your initializers.
- #
- # @example
- # HoptoadNotifier.configure do |config|
- # config.api_key = '1234567890abcdef'
- # config.secure = false
- # end
- def configure(silent = false)
- self.configuration ||= Configuration.new
- yield(configuration)
- self.sender = Sender.new(configuration)
- report_ready unless silent
- end
-
- # Sends an exception manually using this method, even when you are not in a controller.
- #
- # @param [Exception] exception The exception you want to notify Hoptoad about.
- # @param [Hash] opts Data that will be sent to Hoptoad.
- #
- # @option opts [String] :api_key The API key for this project. The API key is a unique identifier that Hoptoad uses for identification.
- # @option opts [String] :error_message The error returned by the exception (or the message you want to log).
- # @option opts [String] :backtrace A backtrace, usually obtained with +caller+.
- # @option opts [String] :request The controller's request object.
- # @option opts [String] :session The contents of the user's session.
- # @option opts [String] :environment ENV merged with the contents of the request's environment.
- def notify(exception, opts = {})
- send_notice(build_notice_for(exception, opts))
- end
-
- # Sends the notice unless it is one of the default ignored exceptions
- # @see HoptoadNotifier.notify
- def notify_or_ignore(exception, opts = {})
- notice = build_notice_for(exception, opts)
- send_notice(notice) unless notice.ignore?
- end
-
- def build_lookup_hash_for(exception, options = {})
- notice = build_notice_for(exception, options)
-
- result = {}
- result[:action] = notice.action rescue nil
- result[:component] = notice.component rescue nil
- result[:error_class] = notice.error_class if notice.error_class
- result[:environment_name] = 'production'
-
- unless notice.backtrace.lines.empty?
- result[:file] = notice.backtrace.lines.first.file
- result[:line_number] = notice.backtrace.lines.first.number
- end
-
- result
- end
-
- private
-
- def send_notice(notice)
- if configuration.public?
- sender.send_to_hoptoad(notice.to_xml)
- end
- end
-
- def build_notice_for(exception, opts = {})
- exception = unwrap_exception(exception)
- if exception.respond_to?(:to_hash)
- opts = opts.merge(exception)
- else
- opts = opts.merge(:exception => exception)
- end
- Notice.new(configuration.merge(opts))
- end
-
- def unwrap_exception(exception)
- if exception.respond_to?(:original_exception)
- exception.original_exception
- elsif exception.respond_to?(:continued_exception)
- exception.continued_exception
- else
- exception
- end
- end
- end
-end
-
View
99 vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/backtrace.rb
@@ -1,99 +0,0 @@
-module HoptoadNotifier
- # Front end to parsing the backtrace for each notice
- class Backtrace
-
- # Handles backtrace parsing line by line
- class Line
-
- INPUT_FORMAT = %r{^([^:]+):(\d+)(?::in `([^']+)')?$}.freeze
-
- # The file portion of the line (such as app/models/user.rb)
- attr_reader :file
-
- # The line number portion of the line
- attr_reader :number
-
- # The method of the line (such as index)
- attr_reader :method
-
- # Parses a single line of a given backtrace
- # @param [String] unparsed_line The raw line from +caller+ or some backtrace
- # @return [Line] The parsed backtrace line
- def self.parse(unparsed_line)
- _, file, number, method = unparsed_line.match(INPUT_FORMAT).to_a
- new(file, number, method)
- end
-
- def initialize(file, number, method)
- self.file = file
- self.number = number
- self.method = method
- end
-
- # Reconstructs the line in a readable fashion
- def to_s
- "#{file}:#{number}:in `#{method}'"
- end
-
- def ==(other)
- to_s == other.to_s
- end
-
- def inspect
- "<Line:#{to_s}>"
- end
-
- private
-
- attr_writer :file, :number, :method
- end
-
- # holder for an Array of Backtrace::Line instances
- attr_reader :lines
-
- def self.parse(ruby_backtrace, opts = {})
- ruby_lines = split_multiline_backtrace(ruby_backtrace)
-
- filters = opts[:filters] || []
- filtered_lines = ruby_lines.to_a.map do |line|
- filters.inject(line) do |line, proc|
- proc.call(line)
- end
- end.compact
-
- lines = filtered_lines.collect do |unparsed_line|
- Line.parse(unparsed_line)
- end
-
- instance = new(lines)
- end
-
- def initialize(lines)
- self.lines = lines
- end
-
- def inspect
- "<Backtrace: " + lines.collect { |line| line.inspect }.join(", ") + ">"
- end
-
- def ==(other)
- if other.respond_to?(:lines)
- lines == other.lines
- else
- false
- end
- end
-
- private
-
- attr_writer :lines
-
- def self.split_multiline_backtrace(backtrace)
- if backtrace.to_a.size == 1
- backtrace.to_a.first.split(/\n\s*/)
- else
- backtrace
- end
- end
- end
-end
View
95 vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/catcher.rb
@@ -1,95 +0,0 @@
-module HoptoadNotifier
- # Include this module in Controllers in which you want to be notified of errors.
- module Catcher
-
- # Sets up an alias chain to catch exceptions when Rails does
- def self.included(base) #:nodoc:
- if base.instance_methods.map(&:to_s).include? 'rescue_action_in_public' and !base.instance_methods.map(&:to_s).include? 'rescue_action_in_public_without_hoptoad'
- base.send(:alias_method, :rescue_action_in_public_without_hoptoad, :rescue_action_in_public)
- base.send(:alias_method, :rescue_action_in_public, :rescue_action_in_public_with_hoptoad)
- base.send(:alias_method, :rescue_action_locally_without_hoptoad, :rescue_action_locally)
- base.send(:alias_method, :rescue_action_locally, :rescue_action_locally_with_hoptoad)
- end
- end
-
- private
-
- # Overrides the rescue_action method in ActionController::Base, but does not inhibit
- # any custom processing that is defined with Rails 2's exception helpers.
- def rescue_action_in_public_with_hoptoad(exception)
- unless hoptoad_ignore_user_agent?
- HoptoadNotifier.notify_or_ignore(exception, hoptoad_request_data)
- end
- rescue_action_in_public_without_hoptoad(exception)
- end
-
- def rescue_action_locally_with_hoptoad(exception)
- result = rescue_action_locally_without_hoptoad(exception)
-
- if HoptoadNotifier.configuration.development_lookup
- path = File.join(File.dirname(__FILE__), '..', 'templates', 'rescue.erb')
- notice = HoptoadNotifier.build_lookup_hash_for(exception, hoptoad_request_data)
-
- result << @template.render(
- :file => path,
- :use_full_path => false,
- :locals => { :host => HoptoadNotifier.configuration.host,
- :api_key => HoptoadNotifier.configuration.api_key,
- :notice => notice })
- end
-
- result
- end
-
- # This method should be used for sending manual notifications while you are still
- # inside the controller. Otherwise it works like HoptoadNotifier.notify.
- def notify_hoptoad(hash_or_exception)
- unless consider_all_requests_local || local_request?
- HoptoadNotifier.notify(hash_or_exception, hoptoad_request_data)
- end
- end
-
- def hoptoad_ignore_user_agent? #:nodoc:
- # Rails 1.2.6 doesn't have request.user_agent, so check for it here
- user_agent = request.respond_to?(:user_agent) ? request.user_agent : request.env["HTTP_USER_AGENT"]
- HoptoadNotifier.configuration.ignore_user_agent.flatten.any? { |ua| ua === user_agent }
- end
-
- def hoptoad_request_data
- { :parameters => hoptoad_filter_if_filtering(params.to_hash),
- :session_data => hoptoad_session_data,
- :controller => params[:controller],
- :action => params[:action],
- :url => hoptoad_request_url,
- :cgi_data => hoptoad_filter_if_filtering(request.env),
- :environment_vars => hoptoad_filter_if_filtering(ENV) }
- end
-
- def hoptoad_filter_if_filtering(hash)
- if respond_to?(:filter_parameters)
- filter_parameters(hash) rescue hash
- else
- hash
- end
- end
-
- def hoptoad_session_data
- if session.respond_to?(:to_hash)
- session.to_hash
- else
- session.data
- end
- end
-
- def hoptoad_request_url
- url = "#{request.protocol}#{request.host}"
-
- unless [80, 443].include?(request.port)
- url << ":#{request.port}"
- end
-
- url << request.request_uri
- url
- end
- end
-end
View
229 vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/configuration.rb
@@ -1,229 +0,0 @@
-module HoptoadNotifier
- # Used to set up and modify settings for the notifier.
- class Configuration
-
- OPTIONS = [:api_key, :backtrace_filters, :development_environments,
- :development_lookup, :environment_name, :host,
- :http_open_timeout, :http_read_timeout, :ignore, :ignore_by_filters,
- :ignore_user_agent, :notifier_name, :notifier_url, :notifier_version,
- :params_filters, :project_root, :port, :protocol, :proxy_host,
- :proxy_pass, :proxy_port, :proxy_user, :secure].freeze
-
- # The API key for your project, found on the project edit form.
- attr_accessor :api_key
-
- # The host to connect to (defaults to hoptoadapp.com).
- attr_accessor :host
-
- # The port on which your Hoptoad server runs (defaults to 443 for secure
- # connections, 80 for insecure connections).
- attr_accessor :port
-
- # +true+ for https connections, +false+ for http connections.
- attr_accessor :secure
-
- # The HTTP open timeout in seconds (defaults to 2).
- attr_accessor :http_open_timeout
-
- # The HTTP read timeout in seconds (defaults to 5).
- attr_accessor :http_read_timeout
-
- # The hostname of your proxy server (if using a proxy)
- attr_accessor :proxy_host
-
- # The port of your proxy server (if using a proxy)
- attr_accessor :proxy_port
-
- # The username to use when logging into your proxy server (if using a proxy)
- attr_accessor :proxy_user
-
- # The password to use when logging into your proxy server (if using a proxy)
- attr_accessor :proxy_pass
-
- # A list of parameters that should be filtered out of what is sent to Hoptoad.
- # By default, all "password" attributes will have their contents replaced.
- attr_reader :params_filters
-
- # A list of filters for cleaning and pruning the backtrace. See #filter_backtrace.
- attr_reader :backtrace_filters
-
- # A list of filters for ignoring exceptions. See #ignore_by_filter.
- attr_reader :ignore_by_filters
-
- # A list of exception classes to ignore. The array can be appended to.
- attr_reader :ignore
-
- # A list of user agents that are being ignored. The array can be appended to.
- attr_reader :ignore_user_agent
-
- # A list of environments in which notifications should not be sent.
- attr_accessor :development_environments
-
- # +true+ if you want to check for production errors matching development errors, +false+ otherwise.
- attr_accessor :development_lookup
-
- # The name of the environment the application is running in
- attr_accessor :environment_name
-
- # The path to the project in which the error occurred, such as the RAILS_ROOT
- attr_accessor :project_root
-
- # The name of the notifier library being used to send notifications (such as "Hoptoad Notifier")
- attr_accessor :notifier_name
-
- # The version of the notifier library being used to send notifications (such as "1.0.2")
- attr_accessor :notifier_version
-
- # The url of the notifier library being used to send notifications
- attr_accessor :notifier_url
-
- DEFAULT_PARAMS_FILTERS = %w(password password_confirmation).freeze
-
- DEFAULT_BACKTRACE_FILTERS = [
- lambda { |line|
- if defined?(HoptoadNotifier.configuration.project_root)
- line.gsub(/#{HoptoadNotifier.configuration.project_root}/, "[PROJECT_ROOT]")
- else
- line
- end
- },
- lambda { |line| line.gsub(/^\.\//, "") },
- lambda { |line|
- if defined?(Gem)
- Gem.path.inject(line) do |line, path|
- line.gsub(/#{path}/, "[GEM_ROOT]")
- end
- end
- },
- lambda { |line| line if line !~ %r{lib/hoptoad_notifier} }
- ].freeze
-
- IGNORE_DEFAULT = ['ActiveRecord::RecordNotFound',
- 'ActionController::RoutingError',
- 'ActionController::InvalidAuthenticityToken',
- 'CGI::Session::CookieStore::TamperedWithCookie',
- 'ActionController::UnknownAction']
-
- # Some of these don't exist for Rails 1.2.*, so we have to consider that.
- IGNORE_DEFAULT.map!{|e| eval(e) rescue nil }.compact!
- IGNORE_DEFAULT.freeze
-
- alias_method :secure?, :secure
-
- def initialize
- @secure = false
- @host = 'hoptoadapp.com'
- @http_open_timeout = 2
- @http_read_timeout = 5
- @params_filters = DEFAULT_PARAMS_FILTERS.dup
- @backtrace_filters = DEFAULT_BACKTRACE_FILTERS.dup
- @ignore_by_filters = []
- @ignore = IGNORE_DEFAULT.dup
- @ignore_user_agent = []
- @development_environments = %w(development test)
- @development_lookup = true
- @notifier_name = 'Hoptoad Notifier'
- @notifier_version = VERSION
- @notifier_url = 'http://hoptoadapp.com'
- end
-
- # Takes a block and adds it to the list of backtrace filters. When the filters
- # run, the block will be handed each line of the backtrace and can modify
- # it as necessary.
- #
- # @example
- # config.filter_bracktrace do |line|
- # line.gsub(/^#{Rails.root}/, "[RAILS_ROOT]")
- # end
- #
- # @param [Proc] block The new backtrace filter.
- # @yieldparam [String] line A line in the backtrace.
- def filter_backtrace(&block)
- self.backtrace_filters << block
- end
-
- # Takes a block and adds it to the list of ignore filters.
- # When the filters run, the block will be handed the exception.
- # @example
- # config.ignore_by_filter do |exception_data|
- # true if exception_data[:error_class] == "RuntimeError"
- # end
- #
- # @param [Proc] block The new ignore filter
- # @yieldparam [Hash] data The exception data given to +HoptoadNotifier.notify+
- # @yieldreturn [Boolean] If the block returns true the exception will be ignored, otherwise it will be processed by hoptoad.
- def ignore_by_filter(&block)
- self.ignore_by_filters << block
- end
-
- # Overrides the list of default ignored errors.
- #
- # @param [Array<Exception>] names A list of exceptions to ignore.
- def ignore_only=(names)
- @ignore = [names].flatten
- end
-
- # Overrides the list of default ignored user agents
- #
- # @param [Array<String>] A list of user agents to ignore
- def ignore_user_agent_only=(names)
- @ignore_user_agent = [names].flatten
- end
-
- # Allows config options to be read like a hash
- #
- # @param [Symbol] option Key for a given attribute
- def [](option)
- send(option)
- end
-
- # Returns a hash of all configurable options
- def to_hash
- OPTIONS.inject({}) do |hash, option|
- hash.merge(option.to_sym => send(option))
- end
- end
-
- # Returns a hash of all configurable options merged with +hash+
- #
- # @param [Hash] hash A set of configuration options that will take precedence over the defaults
- def merge(hash)
- to_hash.merge(hash)
- end
-
- # Determines if the notifier will send notices.
- # @return [Boolean] Returns +false+ if in a development environment, +true+ otherwise.
- def public?
- !development_environments.include?(environment_name)
- end
-
- def port
- @port || default_port
- end
-
- def protocol
- if secure?
- 'https'
- else
- 'http'
- end
- end
-
- def environment_filters
- warn 'config.environment_filters has been deprecated and has no effect.'
- []
- end
-
- private
-
- def default_port
- if secure?
- 443
- else
- 80
- end
- end
-
- end
-
-end
View
295 vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/notice.rb
@@ -1,295 +0,0 @@
-module HoptoadNotifier
- class Notice
-
- # The exception that caused this notice, if any
- attr_reader :exception
-
- # The API key for the project to which this notice should be sent
- attr_reader :api_key
-
- # The backtrace from the given exception or hash.
- attr_reader :backtrace
-
- # The name of the class of error (such as RuntimeError)
- attr_reader :error_class
-
- # The name of the server environment (such as "production")
- attr_reader :environment_name
-
- # CGI variables such as HTTP_METHOD
- attr_reader :cgi_data
-
- # The message from the exception, or a general description of the error
- attr_reader :error_message
-
- # See Configuration#backtrace_filters
- attr_reader :backtrace_filters
-
- # See Configuration#params_filters
- attr_reader :params_filters
-
- # A hash of parameters from the query string or post body.
- attr_reader :parameters
- alias_method :params, :parameters
-
- # The component (if any) which was used in this request (usually the controller)
- attr_reader :component
- alias_method :controller, :component
-
- # The action (if any) that was called in this request
- attr_reader :action
-
- # A hash of session data from the request
- attr_reader :session_data
-
- # The path to the project that caused the error (usually RAILS_ROOT)
- attr_reader :project_root
-
- # The URL at which the error occurred (if any)
- attr_reader :url
-
- # See Configuration#ignore
- attr_reader :ignore
-
- # See Configuration#ignore_by_filters
- attr_reader :ignore_by_filters
-
- # The name of the notifier library sending this notice, such as "Hoptoad Notifier"
- attr_reader :notifier_name
-
- # The version number of the notifier library sending this notice, such as "2.1.3"
- attr_reader :notifier_version
-
- # A URL for more information about the notifier library sending this notice
- attr_reader :notifier_url
-
- def initialize(args)
- self.args = args
- self.exception = args[:exception]
- self.api_key = args[:api_key]
- self.project_root = args[:project_root]
- self.url = args[:url]
-
- self.notifier_name = args[:notifier_name]
- self.notifier_version = args[:notifier_version]
- self.notifier_url = args[:notifier_url]
-
- self.ignore = args[:ignore] || []
- self.ignore_by_filters = args[:ignore_by_filters] || []
- self.backtrace_filters = args[:backtrace_filters] || []
- self.params_filters = args[:params_filters] || []
- self.parameters = args[:parameters] || {}
- self.component = args[:component] || args[:controller]
- self.action = args[:action]
-
- self.environment_name = args[:environment_name]
- self.cgi_data = args[:cgi_data]
- self.backtrace = Backtrace.parse(exception_attribute(:backtrace, caller))
- self.error_class = exception_attribute(:error_class) {|exception| exception.class.name }
- self.error_message = exception_attribute(:error_message, 'Notification') do |exception|
- "#{exception.class.name}: #{exception.message}"
- end
-
- find_session_data
- clean_params
- end
-
- # Converts the given notice to XML
- def to_xml
- builder = Builder::XmlMarkup.new
- builder.instruct!
- xml = builder.notice(:version => HoptoadNotifier::API_VERSION) do |notice|
- notice.tag!("api-key", api_key)
- notice.notifier do |notifier|
- notifier.name(notifier_name)
- notifier.version(notifier_version)
- notifier.url(notifier_url)
- end
- notice.error do |error|
- error.tag!('class', error_class)
- error.message(error_message)
- error.backtrace do |backtrace|
- self.backtrace.lines.each do |line|
- backtrace.line(:number => line.number,
- :file => line.file,
- :method => line.method)
- end
- end
- end
- if url ||
- controller ||
- action ||
- !parameters.blank? ||
- !cgi_data.blank? ||
- !session_data.blank?
- notice.request do |request|
- request.url(url)
- request.component(controller)
- request.action(action)
- unless parameters.blank?
- request.params do |params|
- xml_vars_for(params, parameters)
- end
- end
- unless session_data.blank?
- request.session do |session|
- xml_vars_for(session, session_data)
- end
- end
- unless cgi_data.blank?
- request.tag!("cgi-data") do |cgi_datum|
- xml_vars_for(cgi_datum, cgi_data)
- end
- end
- end
- end
- notice.tag!("server-environment") do |env|
- env.tag!("project-root", project_root)
- env.tag!("environment-name", environment_name)
- end
- end
- xml.to_s
- end
-
- # Determines if this notice should be ignored
- def ignore?
- ignored_class_names.include?(error_class) ||
- ignore_by_filters.any? {|filter| filter.call(self) }
- end
-
- # Allows properties to be accessed using a hash-like syntax
- #
- # @example
- # notice[:error_message]
- # @param [String] method The given key for an attribute
- # @return The attribute value, or self if given +:request+
- def [](method)
- case method
- when :request
- self
- else
- send(method)
- end
- end
-
- private
-
- attr_writer :exception, :api_key, :backtrace, :error_class, :error_message,
- :backtrace_filters, :parameters, :params_filters,
- :environment_filters, :session_data, :project_root, :url, :ignore,
- :ignore_by_filters, :notifier_name, :notifier_url, :notifier_version,
- :component, :action, :cgi_data, :environment_name
-
- # Arguments given in the initializer
- attr_accessor :args
-
- # Gets a property named +attribute+ of an exception, either from an actual
- # exception or a hash.
- #
- # If an exception is available, #from_exception will be used. Otherwise,
- # a key named +attribute+ will be used from the #args.
- #
- # If no exception or hash key is available, +default+ will be used.
- def exception_attribute(attribute, default = nil, &block)
- (exception && from_exception(attribute, &block)) || args[attribute] || default
- end
-
- # Gets a property named +attribute+ from an exception.
- #
- # If a block is given, it will be used when getting the property from an
- # exception. The block should accept and exception and return the value for
- # the property.
- #
- # If no block is given, a method with the same name as +attribute+ will be
- # invoked for the value.
- def from_exception(attribute)
- if block_given?
- yield(exception)
- else
- exception.send(attribute)
- end
- end
-
- # Removes non-serializable data from the given attribute.
- # See #clean_unserializable_data
- def clean_unserializable_data_from(attribute)
- self.send(:"#{attribute}=", clean_unserializable_data(send(attribute)))
- end
-
- # Removes non-serializable data. Allowed data types are strings, arrays,
- # and hashes. All other types are converted to strings.
- # TODO: move this onto Hash
- def clean_unserializable_data(data)
- if data.respond_to?(:to_hash)
- data.inject({}) do |result, (key, value)|
- result.merge(key => clean_unserializable_data(value))
- end
- elsif data.respond_to?(:to_ary)
- data.collect do |value|
- clean_unserializable_data(value)
- end
- else
- data.to_s
- end
- end
-
- # Replaces the contents of params that match params_filters.
- # TODO: extract this to a different class
- def clean_params
- clean_unserializable_data_from(:parameters)
- filter(parameters)
- if cgi_data
- clean_unserializable_data_from(:cgi_data)
- filter(cgi_data)
- end
- if session_data
- clean_unserializable_data_from(:session_data)
- end
- end
-
- def filter(hash)
- if params_filters
- hash.each do |key, value|
- if filter_key?(key)
- hash[key] = "[FILTERED]"
- elsif value.respond_to?(:to_hash)
- filter(hash[key])
- end
- end
- end
- end
-
- def filter_key?(key)
- params_filters.any? do |filter|
- key.to_s.include?(filter)
- end
- end
-
- def find_session_data
- self.session_data = args[:session_data] || args[:session] || {}
- self.session_data = session_data[:data] if session_data[:data]
- end
-
- # Converts the mixed class instances and class names into just names
- # TODO: move this into Configuration or another class
- def ignored_class_names
- ignore.collect do |string_or_class|
- if string_or_class.respond_to?(:name)
- string_or_class.name
- else
- string_or_class
- end
- end
- end
-
- def xml_vars_for(builder, hash)
- hash.each do |key, value|
- if value.respond_to?(:to_hash)
- builder.var(:key => key){|b| xml_vars_for(b, value.to_hash) }
- else
- builder.var(value.to_s, :key => key)
- end
- end
- end
- end
-end
View
63 vendor/plugins/hoptoad_notifier/lib/hoptoad_notifier/sender.rb
@@ -1,63 +0,0 @@
-module HoptoadNotifier
- # Sends out the notice to Hoptoad
- class Sender
-
- NOTICES_URI = '/notifier_api/v2/notices/'.freeze
-
- def initialize(options = {})
- [:proxy_host, :proxy_port, :proxy_user, :proxy_pass, :protocol,
- :host, :port, :secure, :http_open_timeout, :http_read_timeout].each do |option|
- instance_variable_set("@#{option}", options[option])
- end
- end
-
- # Sends the notice data off to Hoptoad for processing.
- #
- # @param [String] data The XML notice to be sent off
- def send_to_hoptoad(data)
- logger.debug { "Sending request to #{url.to_s}:\n#{data}" }
-
- http =
- Net::HTTP::Proxy(proxy_host, proxy_port, proxy_user, proxy_pass).
- new(url.host, url.port)
-
- http.read_timeout = http_read_timeout
- http.open_timeout = http_open_timeout
- http.use_ssl = secure
-
- response = begin
- http.post(url.path, data, HEADERS)
- rescue TimeoutError => e
- log :error, "Timeout while contacting the Hoptoad server."
- nil
- end
-
- case response
- when Net::HTTPSuccess then
- log :info, "Success: #{response.class}", response
- else
- log :error, "Failure: #{response.class}", response
- end
- end
-
- private
-
- attr_reader :proxy_host, :proxy_port, :proxy_user, :proxy_pass, :protocol,
- :host, :port, :secure, :http_open_timeout, :http_read_timeout
-
- def url
- URI.parse("#{protocol}://#{host}:#{port}").merge(NOTICES_URI)
- end
-
- def log(level, message, response = nil)
- logger.send level, LOG_PREFIX + message if logger
- HoptoadNotifier.report_environment_info
- HoptoadNotifier.report_response_body(response.body) if response && response.respond_to?(:body)
- end
-
- def logger
- HoptoadNotifier.logger
- end
-
- end
-end
View
37 vendor/plugins/hoptoad_notifier/lib/hoptoad_tasks.rb
@@ -1,37 +0,0 @@
-require 'net/http'
-require 'uri'
-require 'active_support'
-
-# Capistrano tasks for notifying Hoptoad of deploys
-module HoptoadTasks
-
- # Alerts Hoptoad of a deploy.
- #
- # @param [Hash] opts Data about the deploy that is set to Hoptoad
- #
- # @option opts [String] :rails_env Environment of the deploy (production, staging)
- # @option opts [String] :scm_revision The given revision/sha that is being deployed
- # @option opts [String] :scm_repository Address of your repository to help with code lookups
- # @option opts [String] :local_username Who is deploying
- def self.deploy(opts = {})
- if HoptoadNotifier.configuration.api_key.blank?
- puts "I don't seem to be configured with an API key. Please check your configuration."
- return false
- end
-
- if opts[:rails_env].blank?
- puts "I don't know to which Rails environment you are deploying (use the TO=production option)."
- return false
- end
-
- params = {'api_key' => opts.delete(:api_key) ||
- HoptoadNotifier.configuration.api_key}
- opts.each {|k,v| params["deploy[#{k}]"] = v }
-
- url = URI.parse("http://#{HoptoadNotifier.configuration.host || 'hoptoadapp.com'}/deploys.txt")
- response = Net::HTTP.post_form(url, params)
- puts response.body
- return Net::HTTPSuccess === response
- end
-end
-
View
91 vendor/plugins/hoptoad_notifier/lib/templates/rescue.erb
@@ -1,91 +0,0 @@
-<script type="text/javascript">
-var Hoptoad = {
- host : <%= host.to_json %>,
- api_key : <%= api_key.to_json %>,
- notice : <%= notice.to_json %>,
- message : 'This error exists in production!',
-
- initialize: function() {
- if (this.initialized) {
- return;
- } else {
- this.initialized = true;
- }
-
- var data = [];
-
- for (var key in this.notice) {
- data[data.length] = 'notice[' + key + ']=' + this.notice[key];
- }
-
- data[data.length] = 'notice[api_key]=' + this.api_key;
- data[data.length] = 'callback=Hoptoad.onSuccess';
- data[data.length] = '_=' + (new Date()).getTime();
-
- var head = document.getElementsByTagName('head')[0];
- var done = false;
-
- var
- script = document.createElement('script');
- script.src = 'http://' + this.host + '/notices_api/v1/notices/exist?' +
- data.join('&');
- script.type = 'text/javascript';
- script.onload = script.onreadystatechange = function(){
- if (!done && (!this.readyState ||
- this.readyState == 'loaded' || this.readyState == 'complete')) {
-
- done = true;
-
- // Handle memory leak in IE. (via jQuery)
- script.onload = script.onreadystatechange = null;
- head.removeChild(script);
- }
- };
-
- head.appendChild(script);
- },
-
- onSuccess: function(error) {
- var body = document.getElementsByTagName('body')[0];
- var text = document.createTextNode(this.message);
- var element = document.createElement('a');
-
- element.id = 'hoptoad';
- element.href = 'http://' + error.subdomain + '.' + this.host +
- '/projects/' + error.project_id + '/errors/' + error.id;
- element.appendChild(text);
-
- body.insertBefore(element, body.firstChild);
-
- var h1 = document.getElementsByTagName('h1')[0];
- var pre = document.getElementsByTagName('pre')[0];
- var wrapper = document.createElement('div');
-
- wrapper.id = 'wrapper';
- wrapper.appendChild(h1);
- wrapper.appendChild(pre);
-
- body.insertBefore(wrapper, body.children[1]);
- }
-};
-
-window.onload = function() {
- Hoptoad.initialize.apply(Hoptoad);
-};
-</script>
-
-<style type="text/css">
-#hoptoad {
- background: #FFF url(http://hoptoadapp.com/images/fell-off-the-toad.gif) no-repeat top right;
- color: #F00;
- padding: 45px 101px 45px 12px;
- font-size: 14px;
- font-weight: bold;
- display: block;
- float: right;
-}
-
-#wrapper {
- padding-right: 360px;
-}
-</style>
View
8 vendor/plugins/hoptoad_notifier/rails/init.rb
@@ -1,8 +0,0 @@
-if defined?(ActionController::Base) && !ActionController::Base.include?(HoptoadNotifier::Catcher)
- ActionController::Base.send(:include, HoptoadNotifier::Catcher)
-end
-
-HoptoadNotifier.configure(true) do |config|
- config.environment_name = RAILS_ENV
- config.project_root = RAILS_ROOT
-end
View
24 vendor/plugins/hoptoad_notifier/recipes/hoptoad.rb
@@ -1,24 +0,0 @@
-# When Hoptoad is installed as a plugin this is loaded automatically.
-#
-# When Hoptoad installed as a gem, you need to add
-# require 'hoptoad_notifier/recipes/hoptoad'
-# to your deploy.rb
-#
-# Defines deploy:notify_hoptoad which will send information about the deploy to Hoptoad.
-#
-after "deploy", "deploy:notify_hoptoad"
-after "deploy:migrations", "deploy:notify_hoptoad"
-
-namespace :deploy do
- desc "Notify Hoptoad of the deployment"
- task :notify_hoptoad, :except => { :no_release => true } do
- rails_env = fetch(:hoptoad_env, fetch(:rails_env, "production"))
- local_user = ENV['USER'] || ENV['USERNAME']
- executable = RUBY_PLATFORM.downcase.include?('mswin') ? 'rake.bat' : 'rake'
- notify_command = "#{executable} hoptoad:deploy TO=#{rails_env} REVISION=#{current_revision} REPO=#{repository} USER=#{local_user}"
- notify_command << " API_KEY=#{ENV['API_KEY']}" if ENV['API_KEY']
- puts "Notifying Hoptoad of Deploy (#{notify_command})"
- `#{notify_command}`
- puts "Hoptoad Notification Complete."
- end
-end
View
38 vendor/plugins/hoptoad_notifier/script/integration_test.rb
@@ -1,38 +0,0 @@
-#!/usr/bin/env ruby
-
-require 'logger'
-require 'fileutils'
-
-RAILS_ENV = "production"
-RAILS_ROOT = FileUtils.pwd
-RAILS_DEFAULT_LOGGER = Logger.new(STDOUT)
-
-$: << File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
-require 'hoptoad_notifier'
-require 'rails/init'
-
-fail "Please supply an API Key as the first argument" if ARGV.empty?
-
-host = ARGV[1]
-host ||= "hoptoadapp.com"
-
-secure = (ARGV[2] == "secure")
-
-exception = begin
- raise "Testing hoptoad notifier with secure = #{secure}. If you can see this, it works."
- rescue => foo
- foo
- end
-
-HoptoadNotifier.configure do |config|
- config.secure = secure
- config.host = host
- config.api_key = ARGV.first
-end
-puts "Configuration:"
-HoptoadNotifier.configuration.to_hash.each do |key, value|
- puts sprintf("%25s: %s", key.to_s, value.inspect.slice(0, 55))
-end
-puts "Sending #{secure ? "" : "in"}secure notification to project with key #{ARGV.first}"
-HoptoadNotifier.notify(exception)
-
View
89 vendor/plugins/hoptoad_notifier/tasks/hoptoad_notifier_tasks.rake
@@ -1,89 +0,0 @@
-namespace :hoptoad do
- desc "Notify Hoptoad of a new deploy."
- task :deploy => :environment do
- require 'hoptoad_tasks'
- HoptoadTasks.deploy(:rails_env => ENV['TO'],
- :scm_revision => ENV['REVISION'],
- :scm_repository => ENV['REPO'],
- :local_username => ENV['USER'],
- :api_key => ENV['API_KEY'])
- end
-
- task :log_stdout do
- require 'logger'
- RAILS_DEFAULT_LOGGER = Logger.new(STDOUT)
- end
-
- desc "Verify your plugin installation by sending a test exception to the hoptoad service"
- task :test => ['hoptoad:log_stdout', :environment] do
- RAILS_DEFAULT_LOGGER.level = Logger::DEBUG
-
- require 'action_controller/test_process'
- require 'app/controllers/application' if File.exists?('app/controllers/application.rb')
-
- request = ActionController::TestRequest.new
- response = ActionController::TestResponse.new
-
- class HoptoadTestingException < RuntimeError; end
-
- unless HoptoadNotifier.configuration.api_key
- puts "Hoptoad needs an API key configured! Check the README to see how to add it."
- exit
- end
-
- HoptoadNotifier.configuration.development_environments = []
-
- in_controller = ApplicationController.included_modules.include? HoptoadNotifier::Catcher
- in_base = ActionController::Base.included_modules.include? HoptoadNotifier::Catcher
- if !in_controller || !in_base
- puts "HoptoadNotifier::Catcher must be included inside your ApplicationController class."
- exit
- end
-
- puts "Configuration:"
- HoptoadNotifier.configuration.to_hash.each do |key, value|
- puts sprintf("%25s: %s", key.to_s, value.inspect.slice(0, 55))
- end
-
- puts 'Setting up the Controller.'
- class ApplicationController
- # This is to bypass any filters that may prevent access to the action.
- prepend_before_filter :test_hoptoad
- def test_hoptoad
- puts "Raising '#{exception_class.name}' to simulate application failure."
- raise exception_class.new, 'Testing hoptoad via "rake hoptoad:test". If you can see this, it works.'
- end
-
- def rescue_action exception
- rescue_action_in_public exception
- end
-
- # Ensure we actually have an action to go to.
- def verify; end
-
- def consider_all_requests_local
- false
- end
-
- def local_request?
- false
- end
-
- def exception_class
- exception_name = ENV['EXCEPTION'] || "HoptoadTestingException"
- Object.const_get(exception_name)
- rescue
- Object.const_set(exception_name, Class.new(Exception))
- end
-
- def logger
- nil
- end
- end
-
- puts 'Processing request.'
- class HoptoadVerificationController < ApplicationController; end
- HoptoadVerificationController.new.process(request, response)
- end
-end
-
View
94 vendor/plugins/hoptoad_notifier/test/backtrace_test.rb
@@ -1,94 +0,0 @@
-require File.dirname(__FILE__) + '/helper'
-
-class BacktraceTest < Test::Unit::TestCase
-
- should "parse a backtrace into lines" do
- array = [
- "app/models/user.rb:13:in `magic'",
- "app/controllers/users_controller.rb:8:in `index'"
- ]
-
- backtrace = HoptoadNotifier::Backtrace.parse(array)
-
- line = backtrace.lines.first
- assert_equal '13', line.number
- assert_equal 'app/models/user.rb', line.file
- assert_equal 'magic', line.method
-
- line = backtrace.lines.last
- assert_equal '8', line.number
- assert_equal 'app/controllers/users_controller.rb', line.file
- assert_equal 'index', line.method
- end
-
- should "be equal with equal lines" do
- one = build_backtrace_array
- two = one.dup
- assert_equal one, two
-
- assert_equal HoptoadNotifier::Backtrace.parse(one), HoptoadNotifier::Backtrace.parse(two)
- end
-
- should "parse massive one-line exceptions into multiple lines" do
- original_backtrace = HoptoadNotifier::Backtrace.
- parse(["one:1:in `one'\n two:2:in `two'\n three:3:in `three`"])
- expected_backtrace = HoptoadNotifier::Backtrace.
- parse(["one:1:in `one'", "two:2:in `two'", "three:3:in `three`"])
-
- assert_equal expected_backtrace, original_backtrace
- end
-
- context "with a project root" do
- setup do
- @project_root = '/some/path'
- HoptoadNotifier.configure {|config| config.project_root = @project_root }
- end
-
- teardown do
- reset_config
- end
-
- should "filter out the project root" do
- backtrace_with_root = HoptoadNotifier::Backtrace.parse(
- ["#{@project_root}/app/models/user.rb:7:in `latest'",
- "#{@project_root}/app/controllers/users_controller.rb:13:in `index'",
- "/lib/something.rb:41:in `open'"],
- :filters => default_filters)
- backtrace_without_root = HoptoadNotifier::Backtrace.parse(
- ["[PROJECT_ROOT]/app/models/user.rb:7:in `latest'",
- "[PROJECT_ROOT]/app/controllers/users_controller.rb:13:in `index'",
- "/lib/something.rb:41:in `open'"])
-
- assert_equal backtrace_without_root, backtrace_with_root
- end
- end
-
- should "remove notifier trace" do
- inside_notifier = ['lib/hoptoad_notifier.rb:13:in `voodoo`']
- outside_notifier = ['users_controller:8:in `index`']
-
- without_inside = HoptoadNotifier::Backtrace.parse(outside_notifier)
- with_inside = HoptoadNotifier::Backtrace.parse(inside_notifier + outside_notifier,
- :filters => default_filters)
-
- assert_equal without_inside, with_inside
- end
-
- should "run filters on the backtrace" do
- filters = [lambda { |line| line.sub('foo', 'bar') }]
- input = HoptoadNotifier::Backtrace.parse(["foo:13:in `one'", "baz:14:in `two'"],
- :filters => filters)
- expected = HoptoadNotifier::Backtrace.parse(["bar:13:in `one'", "baz:14:in `two'"])
- assert_equal expected, input
- end
-
- def build_backtrace_array
- ["app/models/user.rb:13:in `magic'",
- "app/controllers/users_controller.rb:8:in `index'"]
- end
-
- def default_filters
- HoptoadNotifier::Configuration::DEFAULT_BACKTRACE_FILTERS
- end
-
-end
View
314 vendor/plugins/hoptoad_notifier/test/catcher_test.rb
@@ -1,314 +0,0 @@
-require File.dirname(__FILE__) + '/helper'
-
-class CatcherTest < Test::Unit::TestCase
-
- include DefinesConstants
-
- def setup
- super
- reset_config
- HoptoadNotifier.sender = CollectingSender.new
- define_constant('RAILS_ROOT', '/path/to/rails/root')
- end
-
- def ignore(exception_class)
- HoptoadNotifier.configuration.ignore << exception_class
- end
-
- def build_controller_class(&definition)
- returning Class.new(ActionController::Base) do |klass|
- klass.__send__(:include, HoptoadNotifier::Catcher)
- klass.class_eval(&definition) if definition
- define_constant('HoptoadTestController', klass)
- end
- end
-
- def assert_sent_hash(hash, xpath)
- hash.each do |key, value|
- element_xpath = "#{xpath}/var[@key = '#{key}']"
- if value.respond_to?(:to_hash)
- assert_sent_hash value.to_hash, element_xpath
- else
- assert_sent_element value.to_s, element_xpath
- end
- end
- end
-
- def assert_sent_element(value, xpath)
- assert_valid_node last_sent_notice_document, xpath, value
- end
-
- def assert_sent_request_info_for(request)
- params = request.parameters.to_hash
- assert_sent_hash params, '/notice/request/params'
- assert_sent_element params['controller'], '/notice/request/component'
- assert_sent_element params['action'], '/notice/request/action'
- assert_sent_element url_from_request(request), '/notice/request/url'
- assert_sent_hash request.env, '/notice/request/cgi-data'
- end
-
- def url_from_request(request)
- url = "#{request.protocol}#{request.host}"
-
- unless [80, 443].include?(request.port)
- url << ":#{request.port}"
- end
-
- url << request.request_uri
- url
- end
-
- def sender
- HoptoadNotifier.sender
- end
-
- def last_sent_notice_xml
- sender.collected.last
- end
-
- def last_sent_notice_document
- assert_not_nil xml = last_sent_notice_xml, "No xml was sent"
- Nokogiri::XML.parse(xml)
- end
-
- def process_action(opts = {}, &action)
- opts[:request] ||= ActionController::TestRequest.new
- opts[:response] ||= ActionController::TestResponse.new
- klass = build_controller_class do
- cattr_accessor :local
- define_method(:index, &action)
- def local_request?
- local
- end
- end
- if opts[:filters]
- klass.filter_parameter_logging *opts[:filters]
- end
- if opts[:user_agent]
- if opts[:request].respond_to?(:user_agent=)
- opts[:request].user_agent = opts[:user_agent]
- else
- opts[:request].env["HTTP_USER_AGENT"] = opts[:user_agent]
- end
- end
- if opts[:port]
- opts[:request].port = opts[:port]
- end
- klass.consider_all_requests_local = opts[:all_local]
- klass.local = opts[:local]
- controller = klass.new
- controller.stubs(:rescue_action_in_public_without_hoptoad)
- opts[:request].query_parameters = opts[:request].query_parameters.merge(opts[:params] || {})
- opts[:request].session = ActionController::TestSession.new(opts[:session] || {})
- controller.process(opts[:request], opts[:response])
- controller
- end
-
- def process_action_with_manual_notification(args = {})
- process_action(args) do
- notify_hoptoad(:error_message => 'fail')
- # Rails will raise a template error if we don't render something
- render :nothing => true
- end
- end
-
- def process_action_with_automatic_notification(args = {})
- process_action(args) { raise "Hello" }
- end
-
- should "deliver notices from exceptions raised in public requests" do
- process_action_with_automatic_notification
- assert_caught_and_sent
- end
-
- should "not deliver notices from exceptions in local requests" do
- process_action_with_automatic_notification(:local => true)
- assert_caught_and_not_sent
- end
-
- should "not deliver notices from exceptions when all requests are local" do
- process_action_with_automatic_notification(:all_local => true)
- assert_caught_and_not_sent
- end
-
- should "not deliver notices from actions that don't raise" do
- controller = process_action { render :text => 'Hello' }
- assert_caught_and_not_sent
- assert_equal 'Hello', controller.response.body
- end
-
- should "not deliver ignored exceptions raised by actions" do
- ignore(RuntimeError)
- process_action_with_automatic_notification
- assert_caught_and_not_sent
- end
-
- should "deliver ignored exception raised manually" do
- ignore(RuntimeError)
- process_action_with_manual_notification
- assert_caught_and_sent
- end
-
- should "deliver manually sent notices in public requests" do
- process_action_with_manual_notification
- assert_caught_and_sent
- end
-
- should "not deliver manually sent notices in local requests" do
- process_action_with_manual_notification(:local => true)
- assert_caught_and_not_sent
- end
-
- should "not deliver manually sent notices when all requests are local" do
- process_action_with_manual_notification(:all_local => true)
- assert_caught_and_not_sent
- end
-
- should "continue with default behavior after delivering an exception" do
- controller = process_action_with_automatic_notification(:public => true)
- # TODO: can we test this without stubbing?
- assert_received(controller, :rescue_action_in_public_without_hoptoad)
- end
-
- should "not create actions from Hoptoad methods" do
- controller = build_controller_class.new
- assert_equal [], HoptoadNotifier::Catcher.instance_methods
- end
-
- should "ignore exceptions when user agent is being ignored by regular expression" do
- HoptoadNotifier.configuration.ignore_user_agent_only = [/Ignored/]
- process_action_with_automatic_notification(:user_agent => 'ShouldBeIgnored')
- assert_caught_and_not_sent
- end
-
- should "ignore exceptions when user agent is being ignored by string" do
- HoptoadNotifier.configuration.ignore_user_agent_only = ['IgnoredUserAgent']
- process_action_with_automatic_notification(:user_agent => 'IgnoredUserAgent')
- assert_caught_and_not_sent
- end
-
- should "not ignore exceptions when user agent is not being ignored" do
- HoptoadNotifier.configuration.ignore_user_agent_only = ['IgnoredUserAgent']
- process_action_with_automatic_notification(:user_agent => 'NonIgnoredAgent')
- assert_caught_and_sent
- end
-
- should "send session data for manual notifications" do
- data = { 'one' => 'two' }
- process_action_with_manual_notification(:session => data)
- assert_sent_hash data, "/notice/request/session"
- end
-
- should "send session data for automatic notification" do
- data = { 'one' => 'two' }
- process_action_with_automatic_notification(:session => data)
- assert_sent_hash data, "/notice/request/session"
- end
-
- should "send request data for manual notification" do
- params = { 'controller' => "hoptoad_test", 'action' => "index" }
- controller = process_action_with_manual_notification(:params => params)
- assert_sent_request_info_for controller.request
- end
-
- should "send request data for manual notification with non-standard port" do
- params = { 'controller' => "hoptoad_test", 'action' => "index" }
- controller = process_action_with_manual_notification(:params => params, :port => 81)
- assert_sent_request_info_for controller.request
- end
-
- should "send request data for automatic notification" do
- params = { 'controller' => "hoptoad_test", 'action' => "index" }
- controller = process_action_with_automatic_notification(:params => params)
- assert_sent_request_info_for controller.request
- end
-
- should "send request data for automatic notification with non-standard port" do
- params = { 'controller' => "hoptoad_test", 'action' => "index" }
- controller = process_action_with_automatic_notification(:params => params, :port => 81)
- assert_sent_request_info_for controller.request
- end
-
- should "use standard rails logging filters on params and env" do
- filtered_params = { "abc" => "123",
- "def" => "456",
- "ghi" => "[FILTERED]" }
- ENV['ghi'] = 'abc'
- filtered_env = { 'ghi' => '[FILTERED]' }
- filtered_cgi = { 'REQUEST_METHOD' => '[FILTERED]' }
-
- process_action_with_automatic_notification(:filters => [:ghi, :request_method],
- :params => { "abc" => "123",
- "def" => "456",
- "ghi" => "789" })
- assert_sent_hash filtered_params, '/notice/request/params'
- assert_sent_hash filtered_cgi, '/notice/request/cgi-data'
- end
-
- context "for a local error with development lookup enabled" do
- setup do
- HoptoadNotifier.configuration.development_lookup = true
- HoptoadNotifier.stubs(:build_lookup_hash_for).returns({ :awesome => 2 })
-
- @controller = process_action_with_automatic_notification(:local => true)
- @response = @controller.response
- end
-
- should "append custom CSS and JS to response body for a local error" do
- assert_match /text\/css/, @response.body
- assert_match /text\/javascript/, @response.body
- end
-
- should "contain host, API key and notice JSON" do
- assert_match HoptoadNotifier.configuration.host.to_json, @response.body
- assert_match HoptoadNotifier.configuration.api_key.to_json, @response.body
- assert_match ({ :awesome => 2 }).to_json, @response.body
- end
- end
-
- context "for a local error with development lookup disabled" do
- setup do
- HoptoadNotifier.configuration.development_lookup = false
-
- @controller = process_action_with_automatic_notification(:local => true)
- @response = @controller.response
- end
-
- should "not append custom CSS and JS to response for a local error" do
- assert_no_match /text\/css/, @response.body
- assert_no_match /text\/javascript/, @response.body
- end
- end
-
- should "call session.to_hash if available" do
- hash_data = {:key => :value}
-
- session = ActionController::TestSession.new
- ActionController::TestSession.stubs(:new).returns(session)
- session.stubs(:to_hash).returns(hash_data)
-
- process_action_with_automatic_notification
- assert_received(session, :to_hash)
- assert_received(session, :data) { |expect| expect.never }
- assert_caught_and_sent
- end
-
- should "call session.data if session.to_hash is undefined" do
- hash_data = {:key => :value}
-
- session = ActionController::TestSession.new
- ActionController::TestSession.stubs(:new).returns(session)
- session.stubs(:data).returns(hash_data)
- if session.respond_to?(:to_hash)
- class << session
- undef to_hash
- end
- end
-
- process_action_with_automatic_notification
- assert_received(session, :to_hash) { |expect| expect.never }
- assert_received(session, :data) { |expect| expect.at_least_once }
- assert_caught_and_sent
- end
-
-end
View
199 vendor/plugins/hoptoad_notifier/test/configuration_test.rb
@@ -1,199 +0,0 @@
-require File.dirname(__FILE__) + '/helper'
-
-class ConfigurationTest < Test::Unit::TestCase
-
- include DefinesConstants
-
- should "provide default values" do
- assert_config_default :proxy_host, nil
- assert_config_default :proxy_port, nil
- assert_config_default :proxy_user, nil
- assert_config_default :proxy_pass, nil
- assert_config_default :project_root, nil
- assert_config_default :environment_name, nil
- assert_config_default :notifier_version, HoptoadNotifier::VERSION
- assert_config_default :notifier_name, 'Hoptoad Notifier'
- assert_config_default :notifier_url, 'http://hoptoadapp.com'
- assert_config_default :secure, false
- assert_config_default :host, 'hoptoadapp.com'
- assert_config_default :http_open_timeout, 2
- assert_config_default :http_read_timeout, 5
- assert_config_default :ignore_by_filters, []
- assert_config_default :ignore_user_agent, []
- assert_config_default :params_filters,
- HoptoadNotifier::Configuration::DEFAULT_PARAMS_FILTERS
- assert_config_default :backtrace_filters,
- HoptoadNotifier::Configuration::DEFAULT_BACKTRACE_FILTERS
- assert_config_default :ignore,
- HoptoadNotifier::Configuration::IGNORE_DEFAULT
- assert_config_default :development_lookup, true
- end
-
- should "provide default values for secure connections" do
- config = HoptoadNotifier::Configuration.new
- config.secure = true
- assert_equal 443, config.port
- assert_equal 'https', config.protocol
- end
-
- should "provide default values for insecure connections" do
- config = HoptoadNotifier::Configuration.new
- config.secure = false
- assert_equal 80, config.port
- assert_equal 'http', config.protocol
- end
-
- should "not cache inferred ports" do
- config = HoptoadNotifier::Configuration.new
- config.secure = false
- config.port
- config.secure = true
- assert_equal 443, config.port
- end
-
- should "allow values to be overwritten" do
- assert_config_overridable :proxy_host
- assert_config_overridable :proxy_port
- assert_config_overridable :proxy_user
- assert_config_overridable :proxy_pass
- assert_config_overridable :secure
- assert_config_overridable :host
- assert_config_overridable :port
- assert_config_overridable :http_open_timeout
- assert_config_overridable :http_read_timeout
- assert_config_overridable :project_root
- assert_config_overridable :notifier_version
- assert_config_overridable :notifier_name
- assert_config_overridable :notifier_url
- assert_config_overridable :environment_name
- assert_config_overridable :development_lookup
- end
-
- should "have an api key" do
- assert_config_overridable :api_key
- end
-
- should "act like a hash" do
- config = HoptoadNotifier::Configuration.new
- hash = config.to_hash
- [:api_key, :backtrace_filters, :development_environments,
- :environment_name, :host, :http_open_timeout,
- :http_read_timeout, :ignore, :ignore_by_filters, :ignore_user_agent,
- :notifier_name, :notifier_url, :notifier_version, :params_filters,
- :project_root, :port, :protocol, :proxy_host, :proxy_pass, :proxy_port,
- :proxy_user, :secure, :development_lookup].each do |option|
- assert_equal config[option], hash[option], "Wrong value for #{option}"
- end
- end
-
- should "be mergable" do
- config = HoptoadNotifier::Configuration.new
- hash = config.to_hash
- assert_equal hash.merge(:key => 'value'), config.merge(:key => 'value')
- end
-
- should "allow param filters to be appended" do
- assert_appends_value :params_filters
- end
-
- should "warn when attempting to read environment filters" do
- config = HoptoadNotifier::Configuration.new
- config.
- expects(:warn).
- with(regexp_matches(/deprecated/i))
- assert_equal [], config.environment_filters
- end
-
- should "allow ignored user agents to be appended" do
- assert_appends_value :ignore_user_agent
- end
-
- should "allow backtrace filters to be appended" do
- assert_appends_value(:backtrace_filters) do |config|
- new_filter = lambda {}
- config.filter_backtrace(&new_filter)
- new_filter
- end
- end
-
- should "allow ignore by filters to be appended" do
- assert_appends_value(:ignore_by_filters) do |config|
- new_filter = lambda {}
- config.ignore_by_filter(&new_filter)
- new_filter
- end
- end
-
- should "allow ignored exceptions to be appended" do
- config = HoptoadNotifier::Configuration.new
- original_filters = config.ignore.dup
- new_filter = 'hello'
- config.ignore << new_filter
- assert_same_elements original_filters + [new_filter], config.ignore
- end
-
- should "allow ignored exceptions to be replaced" do
- assert_replaces(:ignore, :ignore_only=)
- end
-
- should "allow ignored user agents to be replaced" do
- assert_replaces(:ignore_user_agent, :ignore_user_agent_only=)
- end
-
- should "use development and test as development environments by default" do
- config = HoptoadNotifier::Configuration.new
- assert_same_elements %w(development test), config.development_environments
- end
-
- should "be public in a public environment" do
- config = HoptoadNotifier::Configuration.new
- config.development_environments = %w(development)
- config.environment_name = 'production'
- assert config.public?
- end
-
- should "not be public in a development environment" do
- config = HoptoadNotifier::Configuration.new
- config.development_environments = %w(staging)
- config.environment_name = 'staging'
- assert !config.public?
- end
-
- should "be public without an environment name" do
- config = HoptoadNotifier::Configuration.new
- assert config.public?
- end
-
- def assert_config_default(option, default_value, config = nil)
- config ||= HoptoadNotifier::Configuration.new
- assert_equal default_value, config.send(option)
- end
-
- def assert_config_overridable(option, value = 'a value')
- config = HoptoadNotifier::Configuration.new
- config.send(:"#{option}=", value)
- assert_equal value, config.send(option)
- end
-
- def assert_appends_value(option, &block)
- config = HoptoadNotifier::Configuration.new
- original_values = config.send(option).dup
- block ||= lambda do |config|
- new_value = 'hello'
- config.send(option) << new_value
- new_value
- end
- new_value = block.call(config)
- assert_same_elements original_values + [new_value], config.send(option)
- end
-
- def assert_replaces(option, setter)
- config = HoptoadNotifier::Configuration.new
- new_value = 'hello'
- config.send(setter, [new_value])
- assert_equal [new_value], config.send(option)
- config.send(setter, new_value)
- assert_equal [new_value], config.send(option)
- end
-
-end
View
238 vendor/plugins/hoptoad_notifier/test/helper.rb
@@ -1,238 +0,0 @@
-require 'test/unit'
-require 'rubygems'
-
-gem 'jferris-mocha', '0.9.5.0.1241126838'
-
-require 'shoulda'
-require 'mocha'
-
-$LOAD_PATH << File.join(File.dirname(__FILE__), *%w[.. vendor ginger lib])
-require 'ginger'
-
-require 'action_controller'
-require 'action_controller/test_process'
-require 'active_record'
-require 'active_record/base'
-require 'active_support'
-require 'nokogiri'
-
-require File.join(File.dirname(__FILE__), "..", "lib", "hoptoad_notifier")
-
-begin require 'redgreen'; rescue LoadError; end
-
-module TestMethods
- def rescue_action e
- raise e
- end
-
- def do_raise
- raise "Hoptoad"
- end
-
- def do_not_raise
- render :text => "Success"
- end
-
- def do_raise_ignored
- raise ActiveRecord::RecordNotFound.new("404")
- end
-
- def do_raise_not_ignored
- raise ActiveRecord::StatementInvalid.new("Statement invalid")
- end
-
- def manual_notify
- notify_hoptoad(Exception.new)
- render :text => "Success"
- end
-
- def manual_notify_ignored
- notify_hoptoad(ActiveRecord::RecordNotFound.new("404"))
- render :text => "Success"
- end
-end
-
-class HoptoadController < ActionController::Base
- include TestMethods
-end
-
-class Test::Unit::TestCase
- def request(action = nil, method = :get, user_agent = nil, params = {})
- @request = ActionController::TestRequest.new
- @request.action = action ? action.to_s : ""
-
- if user_agent
- if @request.respond_to?(:user_agent=)
- @request.user_agent = user_agent
- else
- @request.env["HTTP_USER_AGENT"] = user_agent
- end
- end
- @request.query_parameters = @request.query_parameters.merge(params)
- @response = ActionController::TestResponse.new
- @controller.process(@request, @response)
- end
-
- # Borrowed from ActiveSupport 2.3.2
- def assert_difference(expression, difference = 1, message = nil, &block)
- b = block.send(:binding)
- exps = Array.wrap(expression)
- before = exps.map { |e| eval(e, b) }
-
- yield
-
- exps.each_with_index do |e, i|
- error = "#{e.inspect} didn't change by #{difference}"
- error = "#{message}.\n#{error}" if message
- assert_equal(before[i] + difference, eval(e, b), error)
- end
- end
-
- def assert_no_difference(expression, message = nil, &block)
- assert_difference expression, 0, message, &block
- end
-
- def stub_sender
- stub('sender', :send_to_hoptoad => nil)
- end
-
- def stub_sender!
- HoptoadNotifier.sender = stub_sender
- end
-
- def stub_notice
- stub(