diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 8ddf138..3484bd0 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,6 +1,4 @@ class ApplicationController < ActionController::Base - include HoptoadNotifier::Catcher - protect_from_forgery filter_parameter_logging :password, :password_confirmation diff --git a/config/deploy.rb b/config/deploy.rb index 22a9072..8fa9dd4 100644 --- a/config/deploy.rb +++ b/config/deploy.rb @@ -85,10 +85,4 @@ run "ln -s #{shared_path}/database.yml #{release_path}/config/database.yml" end -end - -Dir[File.join(File.dirname(__FILE__), '..', 'vendor', 'gems', 'hoptoad_notifier-*')].each do |vendored_notifier| - $: << File.join(vendored_notifier, 'lib') -end - -require 'hoptoad_notifier/capistrano' \ No newline at end of file +end \ No newline at end of file diff --git a/config/environment.rb b/config/environment.rb index baa0e74..dad12c4 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -23,7 +23,6 @@ config.gem 'formtastic', :version => '0.9.7' config.gem 'paperclip', :version => '2.3.1.1' config.gem 'inherited_resources', :version => '0.9.4' - config.gem 'hoptoad_notifier', :version => '2.1.3' # Only load the plugins named here, in the order given (default is alphabetical). # :all can be used as a placeholder for all plugins not explicitly named diff --git a/lib/tasks/hoptoad_notifier_tasks.rake b/lib/tasks/hoptoad_notifier_tasks.rake deleted file mode 100644 index da2f45f..0000000 --- a/lib/tasks/hoptoad_notifier_tasks.rake +++ /dev/null @@ -1,5 +0,0 @@ -Dir[File.join(RAILS_ROOT, 'vendor', 'gems', 'hoptoad_notifier-*')].each do |vendored_notifier| - $: << File.join(vendored_notifier, 'lib') -end - -require 'hoptoad_notifier/tasks' diff --git a/vendor/gems/hoptoad_notifier-2.1.3/.specification b/vendor/gems/hoptoad_notifier-2.1.3/.specification deleted file mode 100644 index e4b5d63..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/.specification +++ /dev/null @@ -1,160 +0,0 @@ ---- !ruby/object:Gem::Specification -name: hoptoad_notifier -version: !ruby/object:Gem::Version - version: 2.1.3 -platform: ruby -authors: -- thoughtbot, inc -autorequire: -bindir: bin -cert_chain: [] - -date: 2010-01-27 00:00:00 -02:00 -default_executable: -dependencies: -- !ruby/object:Gem::Dependency - name: activesupport - type: :runtime - version_requirement: - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -- !ruby/object:Gem::Dependency - name: activerecord - type: :development - version_requirement: - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -- !ruby/object:Gem::Dependency - name: actionpack - type: :development - version_requirement: - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -- !ruby/object:Gem::Dependency - name: jferris-mocha - type: :development - version_requirement: - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -- !ruby/object:Gem::Dependency - name: nokogiri - type: :development - version_requirement: - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -- !ruby/object:Gem::Dependency - name: shoulda - type: :development - version_requirement: - version_requirements: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -description: -email: support@hoptoadapp.com -executables: [] - -extensions: [] - -extra_rdoc_files: -- README.rdoc -files: -- INSTALL -- MIT-LICENSE -- Rakefile -- README.rdoc -- SUPPORTED_RAILS_VERSIONS -- TESTING.rdoc -- generators/hoptoad/hoptoad_generator.rb -- generators/hoptoad/lib/insert_commands.rb -- generators/hoptoad/lib/rake_commands.rb -- generators/hoptoad/templates/capistrano_hook.rb -- generators/hoptoad/templates/hoptoad_notifier_tasks.rake -- generators/hoptoad/templates/initializer.rb -- lib/hoptoad_notifier/backtrace.rb -- lib/hoptoad_notifier/capistrano.rb -- lib/hoptoad_notifier/catcher.rb -- lib/hoptoad_notifier/configuration.rb -- lib/hoptoad_notifier/notice.rb -- lib/hoptoad_notifier/rails.rb -- lib/hoptoad_notifier/rails_initializer.rb -- lib/hoptoad_notifier/sender.rb -- lib/hoptoad_notifier/tasks.rb -- lib/hoptoad_notifier/version.rb -- lib/hoptoad_notifier.rb -- lib/hoptoad_tasks.rb -- test/backtrace_test.rb -- test/catcher_test.rb -- test/configuration_test.rb -- test/helper.rb -- test/hoptoad_tasks_test.rb -- test/logger_test.rb -- test/notice_test.rb -- test/notifier_test.rb -- test/rails_initializer_test.rb -- test/sender_test.rb -- rails/init.rb -- script/integration_test.rb -- lib/templates/rescue.erb -has_rdoc: true -homepage: http://www.hoptoadapp.com -licenses: [] - -post_install_message: -rdoc_options: -- --line-numbers -- --main -- README.rdoc -require_paths: -- lib -required_ruby_version: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -required_rubygems_version: !ruby/object:Gem::Requirement - requirements: - - - ">=" - - !ruby/object:Gem::Version - version: "0" - version: -requirements: [] - -rubyforge_project: -rubygems_version: 1.3.5 -signing_key: -specification_version: 3 -summary: Send your application errors to our hosted service and reclaim your inbox. -test_files: -- test/backtrace_test.rb -- test/catcher_test.rb -- test/configuration_test.rb -- test/hoptoad_tasks_test.rb -- test/logger_test.rb -- test/notice_test.rb -- test/notifier_test.rb -- test/rails_initializer_test.rb -- test/sender_test.rb diff --git a/vendor/gems/hoptoad_notifier-2.1.3/INSTALL b/vendor/gems/hoptoad_notifier-2.1.3/INSTALL deleted file mode 100644 index 39f7fb2..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/INSTALL +++ /dev/null @@ -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. diff --git a/vendor/gems/hoptoad_notifier-2.1.3/MIT-LICENSE b/vendor/gems/hoptoad_notifier-2.1.3/MIT-LICENSE deleted file mode 100644 index f8e9154..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/MIT-LICENSE +++ /dev/null @@ -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. diff --git a/vendor/gems/hoptoad_notifier-2.1.3/README.rdoc b/vendor/gems/hoptoad_notifier-2.1.3/README.rdoc deleted file mode 100644 index 5a2c3eb..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/README.rdoc +++ /dev/null @@ -1,234 +0,0 @@ -= HoptoadNotifier - -This is the notifier gem 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. - -=== Remove hoptoad_notifier plugin - -Remove the vendor/plugins/hoptoad_notifier directory before installing the gem, or run: - - script/plugin remove hoptoad_notifier - -=== Rails 2.x - -Add the hoptoad_notifier gem to your app. In config/environment.rb: - - config.gem 'hoptoad_notifier' - -Then from your project's RAILS_ROOT, run: - - rake gems:install - script/generate hoptoad --api-key your_key_here - -Once installed, you should vendor the hoptoad_notifier gem. - - rake gems:unpack GEM=hoptoad_notifier - -As always, if you choose not to vendor the hoptoad_notifier gem, make sure -every server you deploy to has the gem installed or your application won't start. - -=== Rails 1.2.6 - -Install the hoptoad_notifier Gem, and then add something like this at the -bottom of your config/environment.rb: - - HoptoadNotifier.configure do |config| - config.api_key = 'your_key_here' - end - -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. - -=== Testing it out - -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. - -== 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 gem), -all errors will be rescued by the #rescue_action_in_public provided by the gem. - -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 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 - def self.notify(thing) - # do nothing. - end - end - -== Supported Rails versions - -See SUPPORTED_RAILS_VERSIONS for a list of official supported versions of -Rails. - -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. diff --git a/vendor/gems/hoptoad_notifier-2.1.3/Rakefile b/vendor/gems/hoptoad_notifier-2.1.3/Rakefile deleted file mode 100644 index 008eaba..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/Rakefile +++ /dev/null @@ -1,125 +0,0 @@ -require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' -require 'rake/gempackagetask' -require 'cucumber/rake/task' - -desc 'Default: run unit tests.' -task :default => [:test, :cucumber] - -desc 'Test the hoptoad_notifier gem.' -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 - -GEM_ROOT = File.dirname(__FILE__).freeze -VERSION_FILE = File.join(GEM_ROOT, 'lib', 'hoptoad_notifier', 'version') - -require VERSION_FILE - -gemspec = Gem::Specification.new do |s| - s.name = %q{hoptoad_notifier} - s.version = HoptoadNotifier::VERSION - s.summary = %q{Send your application errors to our hosted service and reclaim your inbox.} - - s.files = FileList['[A-Z]*', 'generators/**/*.*', 'lib/**/*.rb', - 'test/**/*.rb', 'rails/**/*.rb', 'script/*', - 'lib/templates/*.erb'] - s.require_path = 'lib' - s.test_files = Dir[*['test/**/*_test.rb']] - - s.has_rdoc = true - s.extra_rdoc_files = ["README.rdoc"] - s.rdoc_options = ['--line-numbers', "--main", "README.rdoc"] - - s.add_runtime_dependency("activesupport") - s.add_development_dependency("activerecord") - s.add_development_dependency("actionpack") - s.add_development_dependency("jferris-mocha") - s.add_development_dependency("nokogiri") - s.add_development_dependency("shoulda") - - s.authors = ["thoughtbot, inc"] - s.email = %q{support@hoptoadapp.com} - s.homepage = "http://www.hoptoadapp.com" - - s.platform = Gem::Platform::RUBY -end - -Rake::GemPackageTask.new gemspec do |pkg| - pkg.need_tar = true - pkg.need_zip = true -end - -desc "Clean files generated by rake tasks" -task :clobber => [:clobber_rdoc, :clobber_package] - -desc "Generate a gemspec file" -task :gemspec do - File.open("#{gemspec.name}.gemspec", 'w') do |f| - f.write gemspec.to_ruby - end -end - -LOCAL_GEM_ROOT = File.join(GEM_ROOT, 'tmp', 'local_gems').freeze -RAILS_VERSIONS = IO.read('SUPPORTED_RAILS_VERSIONS').strip.split("\n") -LOCAL_GEMS = [['sham_rack', nil], ['capistrano', nil], ['sqlite3-ruby', nil]] + - RAILS_VERSIONS.collect { |version| ['rails', version] } - -task :vendor_test_gems do - LOCAL_GEMS.each do |gem_name, version| - gem_file_pattern = [gem_name, version || '*'].compact.join('-') - version_option = version ? "-v #{version}" : '' - pattern = File.join(LOCAL_GEM_ROOT, 'gems', "#{gem_file_pattern}") - existing = Dir.glob(pattern).first - unless existing - command = "gem install -i #{LOCAL_GEM_ROOT} --no-ri --no-rdoc #{version_option} #{gem_name}" - puts "Vendoring #{gem_file_pattern}..." - unless system(command) - $stderr.puts "Command failed: #{command}" - end - end - end -end - -Cucumber::Rake::Task.new(:cucumber) do |t| - t.fork = true - t.cucumber_opts = ['--format', (ENV['CUCUMBER_FORMAT'] || 'progress')] -end - -task :cucumber => [:gemspec, :vendor_test_gems] - -OLD_RAILS_VERSIONS = RAILS_VERSIONS[0...-1] - -namespace :cucumber do - namespace :rails do - OLD_RAILS_VERSIONS.each do |version| - desc "Test integration of the gem with Rails #{version}" - task version do - ENV['RAILS_VERSION'] = version - system("cucumber --format progress features/rails.feature") - end - end - - desc "Test integration of the gem with all Rails versions" - task :all => [:cucumber, *OLD_RAILS_VERSIONS] - end -end diff --git a/vendor/gems/hoptoad_notifier-2.1.3/SUPPORTED_RAILS_VERSIONS b/vendor/gems/hoptoad_notifier-2.1.3/SUPPORTED_RAILS_VERSIONS deleted file mode 100644 index 0ffae08..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/SUPPORTED_RAILS_VERSIONS +++ /dev/null @@ -1,8 +0,0 @@ -1.2.6 -2.0.2 -2.1.0 -2.1.2 -2.2.2 -2.3.2 -2.3.4 -2.3.5 diff --git a/vendor/gems/hoptoad_notifier-2.1.3/TESTING.rdoc b/vendor/gems/hoptoad_notifier-2.1.3/TESTING.rdoc deleted file mode 100644 index 90ff40f..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/TESTING.rdoc +++ /dev/null @@ -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 + - -+./script/integration_test.rb secure+ diff --git a/vendor/gems/hoptoad_notifier-2.1.3/generators/hoptoad/hoptoad_generator.rb b/vendor/gems/hoptoad_notifier-2.1.3/generators/hoptoad/hoptoad_generator.rb deleted file mode 100644 index 4e115af..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/generators/hoptoad/hoptoad_generator.rb +++ /dev/null @@ -1,54 +0,0 @@ -require File.expand_path(File.dirname(__FILE__) + "/lib/insert_commands.rb") -require File.expand_path(File.dirname(__FILE__) + "/lib/rake_commands.rb") - -class HoptoadGenerator < Rails::Generator::Base - def add_options!(opt) - opt.on('-k', '--api-key=key', String, "Your Hoptoad API key") {|v| options[:api_key] = v} - end - - def manifest - if !api_key_configured? && !options[:api_key] - puts "Must pass --api-key or create config/initializers/hoptoad.rb" - exit - end - if plugin_is_present? - puts "You must first remove the hoptoad_notifier plugin. Please run: script/plugin remove hoptoad_notifier" - exit - end - record do |m| - m.directory 'lib/tasks' - m.file 'hoptoad_notifier_tasks.rake', 'lib/tasks/hoptoad_notifier_tasks.rake' - if File.exists?('config/deploy.rb') - m.append_to 'config/deploy.rb', capistrano_hook - end - if options[:api_key] - if use_initializer? - m.template 'initializer.rb', 'config/initializers/hoptoad.rb', - :assigns => {:api_key => options[:api_key]} - else - m.template 'initializer.rb', 'config/hoptoad.rb', - :assigns => {:api_key => options[:api_key]} - m.append_to 'config/environment.rb', "require 'config/hoptoad'" - end - end - m.rake "hoptoad:test", :generate_only => true - end - end - - def use_initializer? - Rails::VERSION::MAJOR > 1 - end - - def api_key_configured? - File.exists?('config/initializers/hoptoad.rb') || - system("grep HoptoadNotifier config/environment.rb") - end - - def capistrano_hook - IO.read(source_path('capistrano_hook.rb')) - end - - def plugin_is_present? - File.exists?('vendor/plugins/hoptoad_notifier') - end -end diff --git a/vendor/gems/hoptoad_notifier-2.1.3/generators/hoptoad/lib/insert_commands.rb b/vendor/gems/hoptoad_notifier-2.1.3/generators/hoptoad/lib/insert_commands.rb deleted file mode 100644 index 9136fb0..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/generators/hoptoad/lib/insert_commands.rb +++ /dev/null @@ -1,34 +0,0 @@ -# Mostly pinched from http://github.com/ryanb/nifty-generators/tree/master - -Rails::Generator::Commands::Base.class_eval do - def file_contains?(relative_destination, line) - File.read(destination_path(relative_destination)).include?(line) - end -end - -Rails::Generator::Commands::Create.class_eval do - def append_to(file, line) - logger.insert "#{line} appended to #{file}" - unless options[:pretend] || file_contains?(file, line) - File.open(file, "a") do |file| - file.puts - file.puts line - end - end - end -end - -Rails::Generator::Commands::Destroy.class_eval do - def append_to(file, line) - logger.remove "#{line} removed from #{file}" - unless options[:pretend] - gsub_file file, "\n#{line}", '' - end - end -end - -Rails::Generator::Commands::List.class_eval do - def append_to(file, line) - logger.insert "#{line} appended to #{file}" - end -end diff --git a/vendor/gems/hoptoad_notifier-2.1.3/generators/hoptoad/lib/rake_commands.rb b/vendor/gems/hoptoad_notifier-2.1.3/generators/hoptoad/lib/rake_commands.rb deleted file mode 100644 index 3a80616..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/generators/hoptoad/lib/rake_commands.rb +++ /dev/null @@ -1,24 +0,0 @@ -Rails::Generator::Commands::Create.class_eval do - def rake(cmd, opts = {}) - logger.rake "rake #{cmd}" - unless system("rake #{cmd}") - logger.rake "#{cmd} failed. Rolling back" - command(:destroy).invoke! - end - end -end - -Rails::Generator::Commands::Destroy.class_eval do - def rake(cmd, opts = {}) - unless opts[:generate_only] - logger.rake "rake #{cmd}" - system "rake #{cmd}" - end - end -end - -Rails::Generator::Commands::List.class_eval do - def rake(cmd, opts = {}) - logger.rake "rake #{cmd}" - end -end diff --git a/vendor/gems/hoptoad_notifier-2.1.3/generators/hoptoad/templates/capistrano_hook.rb b/vendor/gems/hoptoad_notifier-2.1.3/generators/hoptoad/templates/capistrano_hook.rb deleted file mode 100644 index 04afa7d..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/generators/hoptoad/templates/capistrano_hook.rb +++ /dev/null @@ -1,6 +0,0 @@ - -Dir[File.join(File.dirname(__FILE__), '..', 'vendor', 'gems', 'hoptoad_notifier-*')].each do |vendored_notifier| - $: << File.join(vendored_notifier, 'lib') -end - -require 'hoptoad_notifier/capistrano' diff --git a/vendor/gems/hoptoad_notifier-2.1.3/generators/hoptoad/templates/hoptoad_notifier_tasks.rake b/vendor/gems/hoptoad_notifier-2.1.3/generators/hoptoad/templates/hoptoad_notifier_tasks.rake deleted file mode 100644 index da2f45f..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/generators/hoptoad/templates/hoptoad_notifier_tasks.rake +++ /dev/null @@ -1,5 +0,0 @@ -Dir[File.join(RAILS_ROOT, 'vendor', 'gems', 'hoptoad_notifier-*')].each do |vendored_notifier| - $: << File.join(vendored_notifier, 'lib') -end - -require 'hoptoad_notifier/tasks' diff --git a/vendor/gems/hoptoad_notifier-2.1.3/generators/hoptoad/templates/initializer.rb b/vendor/gems/hoptoad_notifier-2.1.3/generators/hoptoad/templates/initializer.rb deleted file mode 100644 index 14b39cd..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/generators/hoptoad/templates/initializer.rb +++ /dev/null @@ -1,6 +0,0 @@ -<% if Rails::VERSION::MINOR < 2 -%> -require 'hoptoad_notifier/rails' -<% end -%> -HoptoadNotifier.configure do |config| - config.api_key = '<%= api_key %>' -end diff --git a/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier.rb b/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier.rb deleted file mode 100644 index 62bdb22..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier.rb +++ /dev/null @@ -1,146 +0,0 @@ -require 'net/http' -require 'net/https' -require 'rubygems' -require 'active_support' -require 'hoptoad_notifier/version' -require 'hoptoad_notifier/configuration' -require 'hoptoad_notifier/notice' -require 'hoptoad_notifier/sender' -require 'hoptoad_notifier/catcher' -require 'hoptoad_notifier/backtrace' - -# Gem for applications to automatically post errors to the Hoptoad of their choice. -module HoptoadNotifier - - 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 - self.configuration.logger - 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 - diff --git a/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier/backtrace.rb b/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier/backtrace.rb deleted file mode 100644 index 617fd3c..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier/backtrace.rb +++ /dev/null @@ -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 - "" - 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 - "" - 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 diff --git a/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier/capistrano.rb b/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier/capistrano.rb deleted file mode 100644 index 538419e..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier/capistrano.rb +++ /dev/null @@ -1,20 +0,0 @@ -# Defines deploy:notify_hoptoad which will send information about the deploy to Hoptoad. - -Capistrano::Configuration.instance(:must_exist).load do - 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 -end diff --git a/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier/catcher.rb b/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier/catcher.rb deleted file mode 100644 index 3e7c66c..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier/catcher.rb +++ /dev/null @@ -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 diff --git a/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier/configuration.rb b/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier/configuration.rb deleted file mode 100644 index 46b02c0..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier/configuration.rb +++ /dev/null @@ -1,228 +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 - - # The logger used by HoptoadNotifier - attr_accessor :logger - - DEFAULT_PARAMS_FILTERS = %w(password password_confirmation).freeze - - DEFAULT_BACKTRACE_FILTERS = [ - lambda { |line| - if defined?(HoptoadNotifier.configuration.project_root) && HoptoadNotifier.configuration.project_root.to_s != '' - 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'] - - 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 cucumber) - @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] 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] 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 diff --git a/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier/notice.rb b/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier/notice.rb deleted file mode 100644 index eea5d92..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier/notice.rb +++ /dev/null @@ -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), :filters => self.backtrace_filters) - 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.to_hash.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 diff --git a/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier/rails.rb b/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier/rails.rb deleted file mode 100644 index 1e6ff74..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier/rails.rb +++ /dev/null @@ -1,11 +0,0 @@ -if defined?(ActionController::Base) && !ActionController::Base.include?(HoptoadNotifier::Catcher) - ActionController::Base.send(:include, HoptoadNotifier::Catcher) -end - -require 'hoptoad_notifier/rails_initializer' -HoptoadNotifier::RailsInitializer.initialize - -HoptoadNotifier.configure(true) do |config| - config.environment_name = RAILS_ENV - config.project_root = RAILS_ROOT -end diff --git a/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier/rails_initializer.rb b/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier/rails_initializer.rb deleted file mode 100644 index 188ef1e..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier/rails_initializer.rb +++ /dev/null @@ -1,16 +0,0 @@ -module HoptoadNotifier - # used to initialize Rails-specific code - class RailsInitializer - def self.initialize - rails_logger = if defined?(Rails.logger) - Rails.logger - elsif defined?(RAILS_DEFAULT_LOGGER) - RAILS_DEFAULT_LOGGER - end - - HoptoadNotifier.configure(true) do |config| - config.logger = rails_logger if config.respond_to? :logger - end - end - end -end diff --git a/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier/sender.rb b/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier/sender.rb deleted file mode 100644 index d17eb92..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier/sender.rb +++ /dev/null @@ -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}" } if logger - - 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 diff --git a/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier/tasks.rb b/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier/tasks.rb deleted file mode 100644 index b0de688..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier/tasks.rb +++ /dev/null @@ -1,91 +0,0 @@ -require 'hoptoad_notifier' - -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 gem 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 - diff --git a/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier/version.rb b/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier/version.rb deleted file mode 100644 index cdc795d..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_notifier/version.rb +++ /dev/null @@ -1,3 +0,0 @@ -module HoptoadNotifier - VERSION = "2.1.3".freeze -end diff --git a/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_tasks.rb b/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_tasks.rb deleted file mode 100644 index 0cb7213..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/lib/hoptoad_tasks.rb +++ /dev/null @@ -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 - diff --git a/vendor/gems/hoptoad_notifier-2.1.3/lib/templates/rescue.erb b/vendor/gems/hoptoad_notifier-2.1.3/lib/templates/rescue.erb deleted file mode 100644 index fe5919e..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/lib/templates/rescue.erb +++ /dev/null @@ -1,91 +0,0 @@ - - - diff --git a/vendor/gems/hoptoad_notifier-2.1.3/rails/init.rb b/vendor/gems/hoptoad_notifier-2.1.3/rails/init.rb deleted file mode 100644 index bdf59f9..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/rails/init.rb +++ /dev/null @@ -1 +0,0 @@ -require 'hoptoad_notifier/rails' diff --git a/vendor/gems/hoptoad_notifier-2.1.3/script/integration_test.rb b/vendor/gems/hoptoad_notifier-2.1.3/script/integration_test.rb deleted file mode 100755 index b5f76bc..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/script/integration_test.rb +++ /dev/null @@ -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) - diff --git a/vendor/gems/hoptoad_notifier-2.1.3/test/backtrace_test.rb b/vendor/gems/hoptoad_notifier-2.1.3/test/backtrace_test.rb deleted file mode 100644 index 5b6a029..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/test/backtrace_test.rb +++ /dev/null @@ -1,118 +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 - - context "with a blank project root" do - setup do - HoptoadNotifier.configure {|config| config.project_root = '' } - end - - teardown do - reset_config - end - - should "not filter line numbers with respect to any project root" do - backtrace = ["/app/models/user.rb:7:in `latest'", - "/app/controllers/users_controller.rb:13:in `index'", - "/lib/something.rb:41:in `open'"] - - backtrace_with_root = - HoptoadNotifier::Backtrace.parse(backtrace, :filters => default_filters) - - backtrace_without_root = - HoptoadNotifier::Backtrace.parse(backtrace) - - 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 diff --git a/vendor/gems/hoptoad_notifier-2.1.3/test/catcher_test.rb b/vendor/gems/hoptoad_notifier-2.1.3/test/catcher_test.rb deleted file mode 100644 index 0905f27..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/test/catcher_test.rb +++ /dev/null @@ -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 diff --git a/vendor/gems/hoptoad_notifier-2.1.3/test/configuration_test.rb b/vendor/gems/hoptoad_notifier-2.1.3/test/configuration_test.rb deleted file mode 100644 index 7f77b41..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/test/configuration_test.rb +++ /dev/null @@ -1,207 +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 :logger, 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 - assert_config_overridable :logger - 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 cucumber), 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 - - should "use the assigned logger if set" do - config = HoptoadNotifier::Configuration.new - config.logger = "CUSTOM LOGGER" - assert_equal "CUSTOM LOGGER", config.logger - 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 diff --git a/vendor/gems/hoptoad_notifier-2.1.3/test/helper.rb b/vendor/gems/hoptoad_notifier-2.1.3/test/helper.rb deleted file mode 100644 index aceb902..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/test/helper.rb +++ /dev/null @@ -1,237 +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('notice', :to_xml => 'some yaml', :ignore? => false) - end - - def stub_notice! - returning stub_notice do |notice| - HoptoadNotifier::Notice.stubs(:new => notice) - end - end - - def create_dummy - HoptoadNotifier::DummySender.new - end - - def reset_config - HoptoadNotifier.configuration = nil - HoptoadNotifier.configure do |config| - config.api_key = 'abc123' - end - end - - def clear_backtrace_filters - HoptoadNotifier.configuration.backtrace_filters.clear - end - - def build_exception - raise - rescue => caught_exception - caught_exception - end - - def build_notice_data(exception = nil) - exception ||= build_exception - { - :api_key => 'abc123', - :error_class => exception.class.name, - :error_message => "#{exception.class.name}: #{exception.message}", - :backtrace => exception.backtrace, - :environment => { 'PATH' => '/bin', 'REQUEST_URI' => '/users/1' }, - :request => { - :params => { 'controller' => 'users', 'action' => 'show', 'id' => '1' }, - :rails_root => '/path/to/application', - :url => "http://test.host/users/1" - }, - :session => { - :key => '123abc', - :data => { 'user_id' => '5', 'flash' => { 'notice' => 'Logged in successfully' } } - } - } - end - - def assert_caught_and_sent - assert !HoptoadNotifier.sender.collected.empty? - end - - def assert_caught_and_not_sent - assert HoptoadNotifier.sender.collected.empty? - end - - def assert_array_starts_with(expected, actual) - assert_respond_to actual, :to_ary - array = actual.to_ary.reverse - expected.reverse.each_with_index do |value, i| - assert_equal value, array[i] - end - end - - def assert_valid_node(document, xpath, content) - nodes = document.xpath(xpath) - assert nodes.any?{|node| node.content == content }, - "Expected xpath #{xpath} to have content #{content}, " + - "but found #{nodes.map { |n| n.content }} in #{nodes.size} matching nodes." + - "Document:\n#{document.to_s}" - end -end - -module DefinesConstants - def setup - @defined_constants = [] - end - - def teardown - @defined_constants.each do |constant| - Object.__send__(:remove_const, constant) - end - end - - def define_constant(name, value) - Object.const_set(name, value) - @defined_constants << name - end -end - -# Also stolen from AS 2.3.2 -class Array - # Wraps the object in an Array unless it's an Array. Converts the - # object to an Array using #to_ary if it implements that. - def self.wrap(object) - case object - when nil - [] - when self - object - else - if object.respond_to?(:to_ary) - object.to_ary - else - [object] - end - end - end - -end - -class CollectingSender - attr_reader :collected - - def initialize - @collected = [] - end - - def send_to_hoptoad(data) - @collected << data - end -end - -class FakeLogger - def info(*args); end - def debug(*args); end - def warn(*args); end - def error(*args); end - def fatal(*args); end -end - -RAILS_DEFAULT_LOGGER = FakeLogger.new diff --git a/vendor/gems/hoptoad_notifier-2.1.3/test/hoptoad_tasks_test.rb b/vendor/gems/hoptoad_notifier-2.1.3/test/hoptoad_tasks_test.rb deleted file mode 100644 index 7d1290d..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/test/hoptoad_tasks_test.rb +++ /dev/null @@ -1,138 +0,0 @@ -require File.dirname(__FILE__) + '/helper' -require 'rubygems' - -require File.dirname(__FILE__) + '/../lib/hoptoad_tasks' -require 'fakeweb' - -FakeWeb.allow_net_connect = false - -class HoptoadTasksTest < Test::Unit::TestCase - def successful_response(body = "") - response = Net::HTTPSuccess.new('1.2', '200', 'OK') - response.stubs(:body).returns(body) - return response - end - - def unsuccessful_response(body = "") - response = Net::HTTPClientError.new('1.2', '200', 'OK') - response.stubs(:body).returns(body) - return response - end - - context "being quiet" do - setup { HoptoadTasks.stubs(:puts) } - - context "in a configured project" do - setup { HoptoadNotifier.configure { |config| config.api_key = "1234123412341234" } } - - context "on deploy({})" do - setup { @output = HoptoadTasks.deploy({}) } - - before_should "complain about missing rails env" do - HoptoadTasks.expects(:puts).with(regexp_matches(/rails environment/i)) - end - - should "return false" do - assert !@output - end - end - - context "given valid options" do - setup { @options = {:rails_env => "staging"} } - - context "on deploy(options)" do - setup { @output = HoptoadTasks.deploy(@options) } - - before_should "post to http://hoptoadapp.com/deploys.txt" do - URI.stubs(:parse).with('http://hoptoadapp.com/deploys.txt').returns(:uri) - Net::HTTP.expects(:post_form).with(:uri, kind_of(Hash)).returns(successful_response) - end - - before_should "use the project api key" do - Net::HTTP.expects(:post_form). - with(kind_of(URI), has_entries('api_key' => "1234123412341234")). - returns(successful_response) - end - - before_should "use send the rails_env param" do - Net::HTTP.expects(:post_form). - with(kind_of(URI), has_entries("deploy[rails_env]" => "staging")). - returns(successful_response) - end - - [:local_username, :scm_repository, :scm_revision].each do |key| - before_should "use send the #{key} param if it's passed in." do - @options[key] = "value" - Net::HTTP.expects(:post_form). - with(kind_of(URI), has_entries("deploy[#{key}]" => "value")). - returns(successful_response) - end - end - - before_should "use the :api_key param if it's passed in." do - @options[:api_key] = "value" - Net::HTTP.expects(:post_form). - with(kind_of(URI), has_entries("api_key" => "value")). - returns(successful_response) - end - - before_should "puts the response body on success" do - HoptoadTasks.expects(:puts).with("body") - Net::HTTP.expects(:post_form).with(any_parameters).returns(successful_response('body')) - end - - before_should "puts the response body on failure" do - HoptoadTasks.expects(:puts).with("body") - Net::HTTP.expects(:post_form).with(any_parameters).returns(unsuccessful_response('body')) - end - - should "return false on failure", :before => lambda { - Net::HTTP.expects(:post_form).with(any_parameters).returns(unsuccessful_response('body')) - } do - assert !@output - end - - should "return true on success", :before => lambda { - Net::HTTP.expects(:post_form).with(any_parameters).returns(successful_response('body')) - } do - assert @output - end - end - end - end - - context "in a configured project with custom host" do - setup do - HoptoadNotifier.configure do |config| - config.api_key = "1234123412341234" - config.host = "custom.host" - end - end - - context "on deploy(:rails_env => 'staging')" do - setup { @output = HoptoadTasks.deploy(:rails_env => "staging") } - - before_should "post to the custom host" do - URI.stubs(:parse).with('http://custom.host/deploys.txt').returns(:uri) - Net::HTTP.expects(:post_form).with(:uri, kind_of(Hash)).returns(successful_response) - end - end - end - - context "when not configured" do - setup { HoptoadNotifier.configure { |config| config.api_key = "" } } - - context "on deploy(:rails_env => 'staging')" do - setup { @output = HoptoadTasks.deploy(:rails_env => "staging") } - - before_should "complain about missing api key" do - HoptoadTasks.expects(:puts).with(regexp_matches(/api key/i)) - end - - should "return false" do - assert !@output - end - end - end - end -end diff --git a/vendor/gems/hoptoad_notifier-2.1.3/test/logger_test.rb b/vendor/gems/hoptoad_notifier-2.1.3/test/logger_test.rb deleted file mode 100644 index d7eee1b..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/test/logger_test.rb +++ /dev/null @@ -1,85 +0,0 @@ -require File.dirname(__FILE__) + '/helper' - -class LoggerTest < Test::Unit::TestCase - def stub_http(response, body = nil) - response.stubs(:body => body) if body - @http = stub(:post => response, - :read_timeout= => nil, - :open_timeout= => nil, - :use_ssl= => nil) - Net::HTTP.stubs(:new).returns(@http) - end - - def send_notice - HoptoadNotifier.sender.send_to_hoptoad('data') - end - - def stub_verbose_log - HoptoadNotifier.stubs(:write_verbose_log) - end - - def assert_logged(expected) - assert_received(HoptoadNotifier, :write_verbose_log) do |expect| - expect.with {|actual| actual =~ expected } - end - end - - def assert_not_logged(expected) - assert_received(HoptoadNotifier, :write_verbose_log) do |expect| - expect.with {|actual| actual =~ expected }.never - end - end - - def configure - HoptoadNotifier.configure { |config| } - end - - should "report that notifier is ready when configured" do - stub_verbose_log - configure - assert_logged /Notifier (.*) ready/ - end - - should "not report that notifier is ready when internally configured" do - stub_verbose_log - HoptoadNotifier.configure(true) { |config| } - assert_not_logged /.*/ - end - - should "print environment info a successful notification without a body" do - reset_config - stub_verbose_log - stub_http(Net::HTTPSuccess) - send_notice - assert_logged /Environment Info:/ - assert_not_logged /Response from Hoptoad:/ - end - - should "print environment info on a failed notification without a body" do - reset_config - stub_verbose_log - stub_http(Net::HTTPError) - send_notice - assert_logged /Environment Info:/ - assert_not_logged /Response from Hoptoad:/ - end - - should "print environment info and response on a success with a body" do - reset_config - stub_verbose_log - stub_http(Net::HTTPSuccess, 'test') - send_notice - assert_logged /Environment Info:/ - assert_logged /Response from Hoptoad:/ - end - - should "print environment info and response on a failure with a body" do - reset_config - stub_verbose_log - stub_http(Net::HTTPError, 'test') - send_notice - assert_logged /Environment Info:/ - assert_logged /Response from Hoptoad:/ - end - -end diff --git a/vendor/gems/hoptoad_notifier-2.1.3/test/notice_test.rb b/vendor/gems/hoptoad_notifier-2.1.3/test/notice_test.rb deleted file mode 100644 index de199d2..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/test/notice_test.rb +++ /dev/null @@ -1,402 +0,0 @@ -require File.dirname(__FILE__) + '/helper' - -class NoticeTest < Test::Unit::TestCase - - include DefinesConstants - - def configure - returning HoptoadNotifier::Configuration.new do |config| - config.api_key = 'abc123def456' - end - end - - def build_notice(args = {}) - configuration = args.delete(:configuration) || configure - HoptoadNotifier::Notice.new(configuration.merge(args)) - end - - def stub_request(attrs = {}) - stub('request', { :parameters => { 'one' => 'two' }, - :protocol => 'http', - :host => 'some.host', - :request_uri => '/some/uri', - :session => { :to_hash => { 'a' => 'b' } }, - :env => { 'three' => 'four' } }.update(attrs)) - end - - should "set the api key" do - api_key = 'key' - notice = build_notice(:api_key => api_key) - assert_equal api_key, notice.api_key - end - - should "accept a project root" do - project_root = '/path/to/project' - notice = build_notice(:project_root => project_root) - assert_equal project_root, notice.project_root - end - - should "accept a component" do - assert_equal 'users_controller', build_notice(:component => 'users_controller').controller - end - - should "alias the component as controller" do - assert_equal 'users_controller', build_notice(:controller => 'users_controller').component - assert_equal 'users_controller', build_notice(:component => 'users_controller').controller - end - - should "accept a action" do - assert_equal 'index', build_notice(:action => 'index').action - end - - should "accept a url" do - url = 'http://some.host/uri' - notice = build_notice(:url => url) - assert_equal url, notice.url - end - - should "accept a backtrace from an exception or hash" do - array = ["user.rb:34:in `crazy'"] - exception = build_exception - exception.set_backtrace array - backtrace = HoptoadNotifier::Backtrace.parse(array) - notice_from_exception = build_notice(:exception => exception) - - - assert_equal backtrace, - notice_from_exception.backtrace, - "backtrace was not correctly set from an exception" - - notice_from_hash = build_notice(:backtrace => array) - assert_equal backtrace, - notice_from_hash.backtrace, - "backtrace was not correctly set from a hash" - end - - should "pass its backtrace filters for parsing" do - backtrace_array = ['my/file/backtrace:3'] - exception = build_exception - exception.set_backtrace(backtrace_array) - HoptoadNotifier::Backtrace.expects(:parse).with(backtrace_array, {:filters => 'foo'}) - - notice = HoptoadNotifier::Notice.new({:exception => exception, :backtrace_filters => 'foo'}) - end - - should "set the error class from an exception or hash" do - assert_accepts_exception_attribute :error_class do |exception| - exception.class.name - end - end - - should "set the error message from an exception or hash" do - assert_accepts_exception_attribute :error_message do |exception| - "#{exception.class.name}: #{exception.message}" - end - end - - should "accept parameters from a request or hash" do - parameters = { 'one' => 'two' } - notice_from_hash = build_notice(:parameters => parameters) - assert_equal notice_from_hash.parameters, parameters - end - - should "accept session data from a session[:data] hash" do - data = { 'one' => 'two' } - notice = build_notice(:session => { :data => data }) - assert_equal data, notice.session_data - end - - should "accept session data from a session_data hash" do - data = { 'one' => 'two' } - notice = build_notice(:session_data => data) - assert_equal data, notice.session_data - end - - should "accept an environment name" do - assert_equal 'development', build_notice(:environment_name => 'development').environment_name - end - - should "accept CGI data from a hash" do - data = { 'string' => 'value' } - notice = build_notice(:cgi_data => data) - assert_equal data, notice.cgi_data, "should take CGI data from a hash" - end - - should "accept notifier information" do - params = { :notifier_name => 'a name for a notifier', - :notifier_version => '1.0.5', - :notifier_url => 'http://notifiers.r.us/download' } - notice = build_notice(params) - assert_equal params[:notifier_name], notice.notifier_name - assert_equal params[:notifier_version], notice.notifier_version - assert_equal params[:notifier_url], notice.notifier_url - end - - should "set sensible defaults without an exception" do - backtrace = HoptoadNotifier::Backtrace.parse(build_backtrace_array) - notice = build_notice(:backtrace => build_backtrace_array) - - assert_equal 'Notification', notice.error_message - assert_array_starts_with backtrace.lines, notice.backtrace.lines - assert_equal({}, notice.parameters) - assert_equal({}, notice.session_data) - end - - should "use the caller as the backtrace for an exception without a backtrace" do - filters = HoptoadNotifier.configuration.backtrace_filters - backtrace = HoptoadNotifier::Backtrace.parse(caller, :filters => filters) - notice = build_notice(:exception => StandardError.new('error'), :backtrace => nil) - - assert_array_starts_with backtrace.lines, notice.backtrace.lines - end - - should "convert unserializable objects to strings" do - assert_serializes_hash(:parameters) - assert_serializes_hash(:cgi_data) - assert_serializes_hash(:session_data) - end - - should "filter parameters" do - assert_filters_hash(:parameters) - end - - should "filter cgi data" do - assert_filters_hash(:cgi_data) - end - - context "a Notice turned into XML" do - setup do - HoptoadNotifier.configure do |config| - config.api_key = "1234567890" - end - - @exception = build_exception - - @notice = build_notice({ - :notifier_name => 'a name', - :notifier_version => '1.2.3', - :notifier_url => 'http://some.url/path', - :exception => @exception, - :controller => "controller", - :action => "action", - :url => "http://url.com", - :parameters => { "paramskey" => "paramsvalue", - "nestparentkey" => { "nestkey" => "nestvalue" } }, - :session_data => { "sessionkey" => "sessionvalue" }, - :cgi_data => { "cgikey" => "cgivalue" }, - :project_root => "RAILS_ROOT", - :environment_name => "RAILS_ENV" - }) - - @xml = @notice.to_xml - - @document = Nokogiri::XML::Document.parse(@xml) - end - - should "validate against the XML schema" do - assert_valid_notice_document @document - end - - should "serialize a Notice to XML when sent #to_xml" do - assert_valid_node(@document, "//api-key", @notice.api_key) - - assert_valid_node(@document, "//notifier/name", @notice.notifier_name) - assert_valid_node(@document, "//notifier/version", @notice.notifier_version) - assert_valid_node(@document, "//notifier/url", @notice.notifier_url) - - assert_valid_node(@document, "//error/class", @notice.error_class) - assert_valid_node(@document, "//error/message", @notice.error_message) - - assert_valid_node(@document, "//error/backtrace/line/@number", @notice.backtrace.lines.first.number) - assert_valid_node(@document, "//error/backtrace/line/@file", @notice.backtrace.lines.first.file) - assert_valid_node(@document, "//error/backtrace/line/@method", @notice.backtrace.lines.first.method) - - assert_valid_node(@document, "//request/url", @notice.url) - assert_valid_node(@document, "//request/component", @notice.controller) - assert_valid_node(@document, "//request/action", @notice.action) - - assert_valid_node(@document, "//request/params/var/@key", "paramskey") - assert_valid_node(@document, "//request/params/var", "paramsvalue") - assert_valid_node(@document, "//request/params/var/@key", "nestparentkey") - assert_valid_node(@document, "//request/params/var/var/@key", "nestkey") - assert_valid_node(@document, "//request/params/var/var", "nestvalue") - assert_valid_node(@document, "//request/session/var/@key", "sessionkey") - assert_valid_node(@document, "//request/session/var", "sessionvalue") - assert_valid_node(@document, "//request/cgi-data/var/@key", "cgikey") - assert_valid_node(@document, "//request/cgi-data/var", "cgivalue") - - assert_valid_node(@document, "//server-environment/project-root", "RAILS_ROOT") - assert_valid_node(@document, "//server-environment/environment-name", "RAILS_ENV") - end - end - - should "not send empty request data" do - notice = build_notice - assert_nil notice.url - assert_nil notice.controller - assert_nil notice.action - - xml = notice.to_xml - document = Nokogiri::XML.parse(xml) - assert_nil document.at('//request/url') - assert_nil document.at('//request/component') - assert_nil document.at('//request/action') - - assert_valid_notice_document document - end - - %w(url controller action).each do |var| - should "send a request if #{var} is present" do - notice = build_notice(var.to_sym => 'value') - xml = notice.to_xml - document = Nokogiri::XML.parse(xml) - assert_not_nil document.at('//request') - end - end - - %w(parameters cgi_data session_data).each do |var| - should "send a request if #{var} is present" do - notice = build_notice(var.to_sym => { 'key' => 'value' }) - xml = notice.to_xml - document = Nokogiri::XML.parse(xml) - assert_not_nil document.at('//request') - end - end - - should "not ignore an exception not matching ignore filters" do - notice = build_notice(:error_class => 'ArgumentError', - :ignore => ['Argument'], - :ignore_by_filters => [lambda { |notice| false }]) - assert !notice.ignore? - end - - should "ignore an exception with a matching error class" do - notice = build_notice(:error_class => 'ArgumentError', - :ignore => [ArgumentError]) - assert notice.ignore? - end - - should "ignore an exception with a matching error class name" do - notice = build_notice(:error_class => 'ArgumentError', - :ignore => ['ArgumentError']) - assert notice.ignore? - end - - should "ignore an exception with a matching filter" do - filter = lambda {|notice| notice.error_class == 'ArgumentError' } - notice = build_notice(:error_class => 'ArgumentError', - :ignore_by_filters => [filter]) - assert notice.ignore? - end - - should "not raise without an ignore list" do - notice = build_notice(:ignore => nil, :ignore_by_filters => nil) - assert_nothing_raised do - notice.ignore? - end - end - - should "ignore RecordNotFound error by default" do - notice = build_notice(:error_class => 'ActiveRecord::RecordNotFound') - assert notice.ignore? - end - - should "ignore RoutingError error by default" do - notice = build_notice(:error_class => 'ActionController::RoutingError') - assert notice.ignore? - end - - should "ignore InvalidAuthenticityToken error by default" do - notice = build_notice(:error_class => 'ActionController::InvalidAuthenticityToken') - assert notice.ignore? - end - - should "ignore TamperedWithCookie error by default" do - notice = build_notice(:error_class => 'CGI::Session::CookieStore::TamperedWithCookie') - assert notice.ignore? - end - - should "ignore UnknownAction error by default" do - notice = build_notice(:error_class => 'ActionController::UnknownAction') - assert notice.ignore? - end - - should "act like a hash" do - notice = build_notice(:error_message => 'some message') - assert_equal notice.error_message, notice[:error_message] - end - - should "return params on notice[:request][:params]" do - params = { 'one' => 'two' } - notice = build_notice(:parameters => params) - assert_equal params, notice[:request][:params] - end - - should "ensure #to_hash is called on objects that support it" do - assert_nothing_raised do - build_notice(:session => { :object => stub(:to_hash => {}) }) - end - end - - def assert_accepts_exception_attribute(attribute, args = {}, &block) - exception = build_exception - block ||= lambda { exception.send(attribute) } - value = block.call(exception) - - notice_from_exception = build_notice(args.merge(:exception => exception)) - - assert_equal notice_from_exception.send(attribute), - value, - "#{attribute} was not correctly set from an exception" - - notice_from_hash = build_notice(args.merge(attribute => value)) - assert_equal notice_from_hash.send(attribute), - value, - "#{attribute} was not correctly set from a hash" - end - - def assert_serializes_hash(attribute) - [File.open(__FILE__), Proc.new { puts "boo!" }, Module.new].each do |object| - hash = { - :strange_object => object, - :sub_hash => { - :sub_object => object - }, - :array => [object] - } - notice = build_notice(attribute => hash) - hash = notice.send(attribute) - assert_equal object.to_s, hash[:strange_object], "objects should be serialized" - assert_kind_of Hash, hash[:sub_hash], "subhashes should be kept" - assert_equal object.to_s, hash[:sub_hash][:sub_object], "subhash members should be serialized" - assert_kind_of Array, hash[:array], "arrays should be kept" - assert_equal object.to_s, hash[:array].first, "array members should be serialized" - end - end - - def assert_valid_notice_document(document) - xsd_path = File.join(File.dirname(__FILE__), "hoptoad_2_0.xsd") - schema = Nokogiri::XML::Schema.new(IO.read(xsd_path)) - errors = schema.validate(document) - assert errors.empty?, errors.collect{|e| e.message }.join - end - - def assert_filters_hash(attribute) - filters = %w(abc def) - original = { 'abc' => "123", 'def' => "456", 'ghi' => "789", 'nested' => { 'abc' => '100' } } - filtered = { 'abc' => "[FILTERED]", - 'def' => "[FILTERED]", - 'ghi' => "789", - 'nested' => { 'abc' => '[FILTERED]' } } - - notice = build_notice(:params_filters => filters, attribute => original) - - assert_equal(filtered, - notice.send(attribute)) - end - - def build_backtrace_array - ["app/models/user.rb:13:in `magic'", - "app/controllers/users_controller.rb:8:in `index'"] - end -end diff --git a/vendor/gems/hoptoad_notifier-2.1.3/test/notifier_test.rb b/vendor/gems/hoptoad_notifier-2.1.3/test/notifier_test.rb deleted file mode 100644 index d86864a..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/test/notifier_test.rb +++ /dev/null @@ -1,222 +0,0 @@ -require File.dirname(__FILE__) + '/helper' - -class NotifierTest < Test::Unit::TestCase - - class OriginalException < Exception - end - - class ContinuedException < Exception - end - - include DefinesConstants - - def setup - super - reset_config - end - - def assert_sent(notice, notice_args) - assert_received(HoptoadNotifier::Notice, :new) {|expect| expect.with(has_entries(notice_args)) } - assert_received(notice, :to_xml) - assert_received(HoptoadNotifier.sender, :send_to_hoptoad) {|expect| expect.with(notice.to_xml) } - end - - def set_public_env - HoptoadNotifier.configure { |config| config.environment_name = 'production' } - end - - def set_development_env - HoptoadNotifier.configure { |config| config.environment_name = 'development' } - end - - should "yield and save a configuration when configuring" do - yielded_configuration = nil - HoptoadNotifier.configure do |config| - yielded_configuration = config - end - - assert_kind_of HoptoadNotifier::Configuration, yielded_configuration - assert_equal yielded_configuration, HoptoadNotifier.configuration - end - - should "not remove existing config options when configuring twice" do - first_config = nil - HoptoadNotifier.configure do |config| - first_config = config - end - HoptoadNotifier.configure do |config| - assert_equal first_config, config - end - end - - should "configure the sender" do - sender = stub_sender - HoptoadNotifier::Sender.stubs(:new => sender) - configuration = nil - - HoptoadNotifier.configure { |yielded_config| configuration = yielded_config } - - assert_received(HoptoadNotifier::Sender, :new) { |expect| expect.with(configuration) } - assert_equal sender, HoptoadNotifier.sender - end - - should "create and send a notice for an exception" do - set_public_env - exception = build_exception - stub_sender! - notice = stub_notice! - - HoptoadNotifier.notify(exception) - - assert_sent notice, :exception => exception - end - - should "create and send a notice for a hash" do - set_public_env - notice = stub_notice! - notice_args = { :error_message => 'uh oh' } - stub_sender! - - HoptoadNotifier.notify(notice_args) - - assert_sent(notice, notice_args) - end - - should "create and sent a notice for an exception and hash" do - set_public_env - exception = build_exception - notice = stub_notice! - notice_args = { :error_message => 'uh oh' } - stub_sender! - - HoptoadNotifier.notify(exception, notice_args) - - assert_sent(notice, notice_args.merge(:exception => exception)) - end - - should "not create a notice in a development environment" do - set_development_env - sender = stub_sender! - - HoptoadNotifier.notify(build_exception) - HoptoadNotifier.notify_or_ignore(build_exception) - - assert_received(sender, :send_to_hoptoad) {|expect| expect.never } - end - - should "not deliver an ignored exception when notifying implicitly" do - set_public_env - exception = build_exception - sender = stub_sender! - notice = stub_notice! - notice.stubs(:ignore? => true) - - HoptoadNotifier.notify_or_ignore(exception) - - assert_received(sender, :send_to_hoptoad) {|expect| expect.never } - end - - should "deliver an ignored exception when notifying manually" do - set_public_env - exception = build_exception - sender = stub_sender! - notice = stub_notice! - notice.stubs(:ignore? => true) - - HoptoadNotifier.notify(exception) - - assert_sent(notice, :exception => exception) - end - - should "pass config to created notices" do - exception = build_exception - config_opts = { 'one' => 'two', 'three' => 'four' } - notice = stub_notice! - stub_sender! - HoptoadNotifier.configuration = stub('config', :merge => config_opts, :public? => true) - - HoptoadNotifier.notify(exception) - - assert_received(HoptoadNotifier::Notice, :new) do |expect| - expect.with(has_entries(config_opts)) - end - end - - context "building notice JSON for an exception" do - setup do - @params = { :controller => "users", :action => "create" } - @exception = build_exception - @hash = HoptoadNotifier.build_lookup_hash_for(@exception, @params) - end - - should "set action" do - assert_equal @params[:action], @hash[:action] - end - - should "set controller" do - assert_equal @params[:controller], @hash[:component] - end - - should "set line number" do - assert @hash[:line_number] =~ /\d+/ - end - - should "set file" do - assert_match /test\/helper\.rb$/, @hash[:file] - end - - should "set rails_env to production" do - assert_equal 'production', @hash[:environment_name] - end - - should "set error class" do - assert_equal 'RuntimeError', @hash[:error_class] - end - - should "not set file or line number with no backtrace" do - @exception.stubs(:backtrace).returns([]) - - @hash = HoptoadNotifier.build_lookup_hash_for(@exception) - - assert_nil @hash[:line_number] - assert_nil @hash[:file] - end - - should "not set action or controller when not provided" do - @hash = HoptoadNotifier.build_lookup_hash_for(@exception) - - assert_nil @hash[:action] - assert_nil @hash[:controller] - end - - context "when an exception that provides #original_exception is raised" do - setup do - @exception.stubs(:original_exception).returns(begin - raise NotifierTest::OriginalException.new - rescue Exception => e - e - end) - end - - should "unwrap exceptions that provide #original_exception" do - @hash = HoptoadNotifier.build_lookup_hash_for(@exception) - assert_equal "NotifierTest::OriginalException", @hash[:error_class] - end - end - - context "when an exception that provides #continued_exception is raised" do - setup do - @exception.stubs(:continued_exception).returns(begin - raise NotifierTest::ContinuedException.new - rescue Exception => e - e - end) - end - - should "unwrap exceptions that provide #continued_exception" do - @hash = HoptoadNotifier.build_lookup_hash_for(@exception) - assert_equal "NotifierTest::ContinuedException", @hash[:error_class] - end - end - end -end diff --git a/vendor/gems/hoptoad_notifier-2.1.3/test/rails_initializer_test.rb b/vendor/gems/hoptoad_notifier-2.1.3/test/rails_initializer_test.rb deleted file mode 100644 index 1d6dbae..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/test/rails_initializer_test.rb +++ /dev/null @@ -1,35 +0,0 @@ -require File.dirname(__FILE__) + '/helper' -require File.join(File.dirname(__FILE__), '..', 'lib', 'hoptoad_notifier', 'rails_initializer') - -class RailsInitializerTest < Test::Unit::TestCase - include DefinesConstants - - should "trigger use of Rails' logger if logger isn't set and Rails' logger exists" do - rails = Module.new do - def self.logger - "RAILS LOGGER" - end - end - define_constant("Rails", rails) - HoptoadNotifier::RailsInitializer.initialize - assert_equal "RAILS LOGGER", HoptoadNotifier.logger - end - - should "trigger use of Rails' default logger if logger isn't set and Rails.logger doesn't exist" do - define_constant("RAILS_DEFAULT_LOGGER", "RAILS DEFAULT LOGGER") - - HoptoadNotifier::RailsInitializer.initialize - assert_equal "RAILS DEFAULT LOGGER", HoptoadNotifier.logger - end - - should "allow overriding of the logger if already assigned" do - define_constant("RAILS_DEFAULT_LOGGER", "RAILS DEFAULT LOGGER") - HoptoadNotifier::RailsInitializer.initialize - - HoptoadNotifier.configure(true) do |config| - config.logger = "OVERRIDDEN LOGGER" - end - - assert_equal "OVERRIDDEN LOGGER", HoptoadNotifier.logger - end -end diff --git a/vendor/gems/hoptoad_notifier-2.1.3/test/sender_test.rb b/vendor/gems/hoptoad_notifier-2.1.3/test/sender_test.rb deleted file mode 100644 index e0a1a8d..0000000 --- a/vendor/gems/hoptoad_notifier-2.1.3/test/sender_test.rb +++ /dev/null @@ -1,123 +0,0 @@ -require File.dirname(__FILE__) + '/helper' - -class SenderTest < Test::Unit::TestCase - - def setup - reset_config - end - - def build_sender(opts = {}) - config = HoptoadNotifier::Configuration.new - opts.each {|opt, value| config.send(:"#{opt}=", value) } - HoptoadNotifier::Sender.new(config) - end - - def send_exception(args = {}) - notice = args.delete(:notice) || build_notice_data - sender = args.delete(:sender) || build_sender(args) - sender.send_to_hoptoad(notice) - sender - end - - def stub_http - response = stub(:body => 'body') - http = stub(:post => response, - :read_timeout= => nil, - :open_timeout= => nil, - :use_ssl= => nil) - Net::HTTP.stubs(:new => http) - http - end - - should "post to Hoptoad when using an HTTP proxy" do - response = stub(:body => 'body') - http = stub(:post => response, - :read_timeout= => nil, - :open_timeout= => nil, - :use_ssl= => nil) - proxy = stub(:new => http) - Net::HTTP.stubs(:Proxy => proxy) - - url = "http://hoptoadapp.com:80#{HoptoadNotifier::Sender::NOTICES_URI}" - uri = URI.parse(url) - - proxy_host = 'some.host' - proxy_port = 88 - proxy_user = 'login' - proxy_pass = 'passwd' - - send_exception(:proxy_host => proxy_host, - :proxy_port => proxy_port, - :proxy_user => proxy_user, - :proxy_pass => proxy_pass) - assert_received(http, :post) do |expect| - expect.with(uri.path, anything, HoptoadNotifier::HEADERS) - end - assert_received(Net::HTTP, :Proxy) do |expect| - expect.with(proxy_host, proxy_port, proxy_user, proxy_pass) - end - end - - should "post to the right url for non-ssl" do - http = stub_http - url = "http://hoptoadapp.com:80#{HoptoadNotifier::Sender::NOTICES_URI}" - uri = URI.parse(url) - send_exception(:secure => false) - assert_received(http, :post) {|expect| expect.with(uri.path, anything, HoptoadNotifier::HEADERS) } - end - - should "post to the right path for ssl" do - http = stub_http - send_exception(:secure => true) - assert_received(http, :post) {|expect| expect.with(HoptoadNotifier::Sender::NOTICES_URI, anything, HoptoadNotifier::HEADERS) } - end - - should "default the open timeout to 2 seconds" do - http = stub_http - send_exception - assert_received(http, :open_timeout=) {|expect| expect.with(2) } - end - - should "default the read timeout to 5 seconds" do - http = stub_http - send_exception - assert_received(http, :read_timeout=) {|expect| expect.with(5) } - end - - should "allow override of the open timeout" do - http = stub_http - send_exception(:http_open_timeout => 4) - assert_received(http, :open_timeout=) {|expect| expect.with(4) } - end - - should "allow override of the read timeout" do - http = stub_http - send_exception(:http_read_timeout => 10) - assert_received(http, :read_timeout=) {|expect| expect.with(10) } - end - - should "connect to the right port for ssl" do - stub_http - send_exception(:secure => true) - assert_received(Net::HTTP, :new) {|expect| expect.with("hoptoadapp.com", 443) } - end - - should "connect to the right port for non-ssl" do - stub_http - send_exception(:secure => false) - assert_received(Net::HTTP, :new) {|expect| expect.with("hoptoadapp.com", 80) } - end - - should "use ssl if secure" do - stub_http - send_exception(:secure => true, :host => 'example.org') - assert_received(Net::HTTP, :new) {|expect| expect.with('example.org', 443) } - end - - should "not use ssl if not secure" do - stub_http - send_exception(:secure => false, :host => 'example.org') - assert_received(Net::HTTP, :new) {|expect| expect.with('example.org', 80) } - end - -end