hoptoad_notifier 2.2.2 → 2.2.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,66 @@
1
+ Version 2.2.5 - 2010-06-02
2
+ ===============================================================================
3
+
4
+ Jason Morrison (1):
5
+ Add documentation for Rails 3.x installation
6
+
7
+
8
+ Version 2.2.4 - 2010-06-02
9
+ ===============================================================================
10
+
11
+ Jason Morrison (1):
12
+ Add a note to README about removing the explicit Catcher #include in ApplicationController
13
+
14
+
15
+ Version 2.2.3 - 2010-06-02
16
+ ===============================================================================
17
+
18
+ Summary: Fixed a variety of issues for Rails 3.0.0.beta3,
19
+ Fixed a bug when using Vlad to deploy instead of Capistrano
20
+ Give better error output when gem is not installed
21
+
22
+ Chad Pytel (2):
23
+ revise gem unpack instructions step
24
+ Merge branch 'master' of github.com:thoughtbot/hoptoad_notifier
25
+
26
+ Dan Lawless (1):
27
+ don't append capistrano details to config.deploy.rb when target app uses Vlad
28
+
29
+ Jason Morrison (7):
30
+ LH-556 Clarify sending ENV environment variables
31
+ Starting to add features for Rails 3
32
+ Make rails rake tasks depend on gem-making tasks
33
+ Start to get Rails 3 features to pass
34
+ require fileutils to reflect rubygems 1.3.6 change
35
+ Support ENV['CUCUMBER_FORMAT'] in rails cucumber tasks for testing
36
+ Fix the initializer syntax in the Rails 3 Railtie
37
+
38
+ Joe Ferris (11):
39
+ Got the generator running and a request dispatched to the test endpoint
40
+ Fixed logging in hoptoad:test rake task
41
+ Separated Rails 2 and 3 entry
42
+ Support bundler
43
+ Rails 3 generator works with an existing api key
44
+ Extract request info from rack env
45
+ Detect presence of the plugin
46
+ Added a capistrano hook for Rails 3
47
+ Fixed rack/sinatra being broken without active_support
48
+ Fixes for earlier versions of Rails
49
+ Fixed Rails 3 generator not to append cap hooks for vlad deploys
50
+
51
+ Josh Kalderimis (7):
52
+ updated railtie to work with the new rails 3 middleware api
53
+ railtie_name is deprecated
54
+ updated app_middleware call to use string version as to make sure constant is loaded
55
+ moved generator using the new rails 3 convention
56
+ update path to template for Rails 3 generator
57
+ correction to referencing of the rails application in rails3_tasks
58
+ add environment_name and project_root back to rails 3 railtie
59
+
60
+ Joshua Nichols (1):
61
+ Handle gem not being installed more gracefully.
62
+
63
+
1
64
  Version 2.2.2 - 2010-03-10
2
65
  ===============================================================================
3
66
 
@@ -73,3 +136,6 @@ Nick Quaranto (3):
73
136
 
74
137
 
75
138
 
139
+
140
+
141
+
@@ -28,6 +28,19 @@ Remove the vendor/plugins/hoptoad_notifier directory before installing the gem,
28
28
 
29
29
  script/plugin remove hoptoad_notifier
30
30
 
31
+ === Rails 3.x
32
+
33
+ Add the hoptoad_notifier gem to your Gemfile. In Gemfile:
34
+
35
+ gem 'hoptoad_notifier'
36
+
37
+ Then from your project's RAILS_ROOT, run:
38
+
39
+ bundle install
40
+ script/rails generate hoptoad --api-key your_key_here
41
+
42
+ That's it!
43
+
31
44
  === Rails 2.x
32
45
 
33
46
  Add the hoptoad_notifier gem to your app. In config/environment.rb:
@@ -37,11 +50,8 @@ Add the hoptoad_notifier gem to your app. In config/environment.rb:
37
50
  Then from your project's RAILS_ROOT, run:
38
51
 
39
52
  rake gems:install
40
- script/generate hoptoad --api-key your_key_here
41
-
42
- Once installed, you should vendor the hoptoad_notifier gem.
43
-
44
53
  rake gems:unpack GEM=hoptoad_notifier
54
+ script/generate hoptoad --api-key your_key_here
45
55
 
46
56
  As always, if you choose not to vendor the hoptoad_notifier gem, make sure
47
57
  every server you deploy to has the gem installed or your application won't start.
@@ -94,6 +104,13 @@ Remove the plugin:
94
104
 
95
105
  rm -rf vendor/plugins/hoptoad_notifier
96
106
 
107
+ Make sure the following line DOES NOT appear in your ApplicationController file:
108
+
109
+ include HoptoadNotifier::Catcher
110
+
111
+ If it does, remove it. The new catcher is automatically included by the gem
112
+ version of Hoptoad.
113
+
97
114
  Before running the hoptoad generator, you need to find your project's API key.
98
115
  Log in to your account at hoptoadapp.com, and click on the "Projects" button.
99
116
  Then, find your project in the list, and click on its name. In the left-hand
@@ -257,6 +274,15 @@ Hoptoad merges the hash you pass with these default options:
257
274
 
258
275
  You can override any of those parameters.
259
276
 
277
+ === Sending shell environment variables when "Going beyond exceptions"
278
+
279
+ One common request we see is to send shell environment variables along with
280
+ manual exception notification. We recommend sending them along with CGI data
281
+ or Rack environment (:cgi_data or :rack_env keys, respectively.)
282
+
283
+ See HoptoadNotifier::Notice#initialize in lib/hoptoad_notifier/notice.rb for
284
+ more details.
285
+
260
286
  == Filtering
261
287
 
262
288
  You can specify a whitelist of errors, that Hoptoad will not report on. Use
data/Rakefile CHANGED
@@ -195,10 +195,10 @@ def define_rails_cucumber_tasks(additional_cucumber_args = '')
195
195
  namespace :rails do
196
196
  RAILS_VERSIONS.each do |version|
197
197
  desc "Test integration of the gem with Rails #{version}"
198
- task version do
198
+ task version => [:gemspec, :vendor_test_gems] do
199
199
  puts "Testing Rails #{version}"
200
200
  ENV['RAILS_VERSION'] = version
201
- system("cucumber --format progress #{additional_cucumber_args} features/rails.feature")
201
+ system("cucumber --format #{ENV['CUCUMBER_FORMAT'] || 'progress'} #{additional_cucumber_args} features/rails.feature")
202
202
  end
203
203
  end
204
204
 
@@ -6,3 +6,4 @@
6
6
  2.3.2
7
7
  2.3.4
8
8
  2.3.5
9
+ 3.0.0.beta3
@@ -18,7 +18,7 @@ class HoptoadGenerator < Rails::Generator::Base
18
18
  record do |m|
19
19
  m.directory 'lib/tasks'
20
20
  m.file 'hoptoad_notifier_tasks.rake', 'lib/tasks/hoptoad_notifier_tasks.rake'
21
- if File.exists?('config/deploy.rb')
21
+ if ['config/deploy.rb', 'Capfile'].all? { |file| File.exists?(file) }
22
22
  m.append_to 'config/deploy.rb', capistrano_hook
23
23
  end
24
24
  if options[:api_key]
@@ -47,7 +47,7 @@ class HoptoadGenerator < Rails::Generator::Base
47
47
  def capistrano_hook
48
48
  IO.read(source_path('capistrano_hook.rb'))
49
49
  end
50
-
50
+
51
51
  def plugin_is_present?
52
52
  File.exists?('vendor/plugins/hoptoad_notifier')
53
53
  end
@@ -7,6 +7,19 @@ unless ARGV.any? {|a| a =~ /^gems/}
7
7
  $: << File.join(vendored_notifier, 'lib')
8
8
  end
9
9
 
10
- require 'hoptoad_notifier/tasks'
10
+ begin
11
+ require 'hoptoad_notifier/tasks'
12
+ rescue LoadError => exception
13
+ namespace :hoptoad do
14
+ %w(deploy test log_stdout).each do |task_name|
15
+ desc "Missing dependency for hoptoad:#{task_name}"
16
+ task task_name do
17
+ $stderr.puts "Failed to run hoptoad:#{task_name} because of missing dependency."
18
+ $stderr.puts "You probably need to run `rake gems:install` to install the hoptoad_notifier gem"
19
+ abort exception.inspect
20
+ end
21
+ end
22
+ end
23
+ end
11
24
 
12
25
  end
@@ -1,4 +1,4 @@
1
- <% if Rails::VERSION::MINOR < 2 -%>
1
+ <% if Rails::VERSION::MAJOR < 3 && Rails::VERSION::MINOR < 2 -%>
2
2
  require 'hoptoad_notifier/rails'
3
3
  <% end -%>
4
4
  HoptoadNotifier.configure do |config|
@@ -9,6 +9,8 @@ require 'hoptoad_notifier/sender'
9
9
  require 'hoptoad_notifier/backtrace'
10
10
  require 'hoptoad_notifier/rack'
11
11
 
12
+ require 'hoptoad_notifier/railtie' if defined?(Rails::Railtie)
13
+
12
14
  # Gem for applications to automatically post errors to the Hoptoad of their choice.
13
15
  module HoptoadNotifier
14
16
 
@@ -1,3 +1,5 @@
1
+ require 'builder'
2
+
1
3
  module HoptoadNotifier
2
4
  class Notice
3
5
 
@@ -78,9 +80,12 @@ module HoptoadNotifier
78
80
  self.ignore_by_filters = args[:ignore_by_filters] || []
79
81
  self.backtrace_filters = args[:backtrace_filters] || []
80
82
  self.params_filters = args[:params_filters] || []
81
- self.parameters = args[:parameters] || rack_env(:params) || {}
82
- self.component = args[:component] || args[:controller]
83
- self.action = args[:action]
83
+ self.parameters = args[:parameters] ||
84
+ action_dispatch_params ||
85
+ rack_env(:params) ||
86
+ {}
87
+ self.component = args[:component] || args[:controller] || parameters['controller']
88
+ self.action = args[:action] || parameters['action']
84
89
 
85
90
  self.environment_name = args[:environment_name]
86
91
  self.cgi_data = args[:cgi_data] || args[:rack_env]
@@ -126,17 +131,17 @@ module HoptoadNotifier
126
131
  request.url(url)
127
132
  request.component(controller)
128
133
  request.action(action)
129
- unless parameters.blank?
134
+ unless parameters.nil? || parameters.empty?
130
135
  request.params do |params|
131
136
  xml_vars_for(params, parameters)
132
137
  end
133
138
  end
134
- unless session_data.blank?
139
+ unless session_data.nil? || session_data.empty?
135
140
  request.session do |session|
136
141
  xml_vars_for(session, session_data)
137
142
  end
138
143
  end
139
- unless cgi_data.blank?
144
+ unless cgi_data.nil? || cgi_data.empty?
140
145
  request.tag!("cgi-data") do |cgi_datum|
141
146
  xml_vars_for(cgi_datum, cgi_data)
142
147
  end
@@ -266,7 +271,7 @@ module HoptoadNotifier
266
271
  end
267
272
 
268
273
  def find_session_data
269
- self.session_data = args[:session_data] || args[:session] || {}
274
+ self.session_data = args[:session_data] || args[:session] || rack_session || {}
270
275
  self.session_data = session_data[:data] if session_data[:data]
271
276
  end
272
277
 
@@ -301,5 +306,13 @@ module HoptoadNotifier
301
306
  ::Rack::Request.new(args[:rack_env])
302
307
  end
303
308
  end
309
+
310
+ def action_dispatch_params
311
+ args[:rack_env]['action_dispatch.request.parameters'] if args[:rack_env]
312
+ end
313
+
314
+ def rack_session
315
+ args[:rack_env]['rack.session'] if args[:rack_env]
316
+ end
304
317
  end
305
318
  end
@@ -23,8 +23,7 @@ module HoptoadNotifier
23
23
  :controller => params[:controller],
24
24
  :action => params[:action],
25
25
  :url => hoptoad_request_url,
26
- :cgi_data => hoptoad_filter_if_filtering(request.env),
27
- :environment_vars => hoptoad_filter_if_filtering(ENV) }
26
+ :cgi_data => hoptoad_filter_if_filtering(request.env) }
28
27
  end
29
28
 
30
29
  def hoptoad_filter_if_filtering(hash)
@@ -0,0 +1,90 @@
1
+ require 'hoptoad_notifier'
2
+
3
+ namespace :hoptoad do
4
+ desc "Notify Hoptoad of a new deploy."
5
+ task :deploy => :environment do
6
+ require 'hoptoad_tasks'
7
+ HoptoadTasks.deploy(:rails_env => ENV['TO'],
8
+ :scm_revision => ENV['REVISION'],
9
+ :scm_repository => ENV['REPO'],
10
+ :local_username => ENV['USER'],
11
+ :api_key => ENV['API_KEY'])
12
+ end
13
+
14
+ desc "Verify your gem installation by sending a test exception to the hoptoad service"
15
+ task :test => [:environment] do
16
+ Rails.logger = Logger.new(STDOUT)
17
+ Rails.logger.level = Logger::DEBUG
18
+ HoptoadNotifier.configure(true) do |config|
19
+ config.logger = Rails.logger
20
+ end
21
+
22
+ require 'app/controllers/application_controller'
23
+
24
+ class HoptoadTestingException < RuntimeError; end
25
+
26
+ unless HoptoadNotifier.configuration.api_key
27
+ puts "Hoptoad needs an API key configured! Check the README to see how to add it."
28
+ exit
29
+ end
30
+
31
+ HoptoadNotifier.configuration.development_environments = []
32
+
33
+ puts "Configuration:"
34
+ HoptoadNotifier.configuration.to_hash.each do |key, value|
35
+ puts sprintf("%25s: %s", key.to_s, value.inspect.slice(0, 55))
36
+ end
37
+
38
+ unless defined?(ApplicationController)
39
+ puts "No ApplicationController found"
40
+ exit
41
+ end
42
+
43
+ puts 'Setting up the Controller.'
44
+ class ApplicationController
45
+ # This is to bypass any filters that may prevent access to the action.
46
+ prepend_before_filter :test_hoptoad
47
+ def test_hoptoad
48
+ puts "Raising '#{exception_class.name}' to simulate application failure."
49
+ raise exception_class.new, 'Testing hoptoad via "rake hoptoad:test". If you can see this, it works.'
50
+ end
51
+
52
+ # def rescue_action(exception)
53
+ # rescue_action_in_public exception
54
+ # end
55
+
56
+ # Ensure we actually have an action to go to.
57
+ def verify; end
58
+
59
+ # def consider_all_requests_local
60
+ # false
61
+ # end
62
+
63
+ # def local_request?
64
+ # false
65
+ # end
66
+
67
+ def exception_class
68
+ exception_name = ENV['EXCEPTION'] || "HoptoadTestingException"
69
+ Object.const_get(exception_name)
70
+ rescue
71
+ Object.const_set(exception_name, Class.new(Exception))
72
+ end
73
+
74
+ def logger
75
+ nil
76
+ end
77
+ end
78
+ class HoptoadVerificationController < ApplicationController; end
79
+
80
+ Rails::Application.routes_reloader.reload_if_changed
81
+ Rails::Application.routes.draw do |map|
82
+ match 'verify' => 'application#verify', :as => 'verify'
83
+ end
84
+
85
+ puts 'Processing request.'
86
+ env = Rack::MockRequest.env_for("/verify")
87
+ Rails::Application.call(env)
88
+ end
89
+ end
90
+
@@ -0,0 +1,23 @@
1
+ require 'hoptoad_notifier'
2
+ require 'rails'
3
+
4
+ module HoptoadNotifier
5
+ class Railtie < Rails::Railtie
6
+ rake_tasks do
7
+ require "hoptoad_notifier/rails3_tasks"
8
+ end
9
+
10
+ initializer "hoptoad.use_rack_middleware" do |app|
11
+ app.config.middleware.insert_after "::ActionDispatch::ShowExceptions", "HoptoadNotifier::Rack"
12
+ end
13
+
14
+ config.after_initialize do
15
+ HoptoadNotifier.configure(true) do |config|
16
+ config.logger = Rails.logger
17
+ config.environment_name = Rails.env
18
+ config.project_root = Rails.root
19
+ config.framework = "Rails: #{::Rails::VERSION::STRING}"
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,3 +1,3 @@
1
1
  module HoptoadNotifier
2
- VERSION = "2.2.2".freeze
2
+ VERSION = "2.2.5".freeze
3
3
  end
@@ -0,0 +1,64 @@
1
+ require 'rails/generators'
2
+
3
+ class HoptoadGenerator < Rails::Generators::Base
4
+
5
+ class_option :api_key, :aliases => "-k", :type => :string, :desc => "Your Hoptoad API key"
6
+
7
+ def self.source_root
8
+ @_hoptoad_source_root ||= File.expand_path("../../../../../generators/hoptoad/templates", __FILE__)
9
+ end
10
+
11
+ def install
12
+ ensure_api_key_was_configured
13
+ ensure_plugin_is_not_present
14
+ append_capistrano_hook
15
+ generate_initializer unless api_key_configured?
16
+ test_hoptoad
17
+ end
18
+
19
+ private
20
+
21
+ def ensure_api_key_was_configured
22
+ if !options[:api_key] && !api_key_configured?
23
+ puts "Must pass --api-key or create config/initializers/hoptoad.rb"
24
+ exit
25
+ end
26
+ end
27
+
28
+ def ensure_plugin_is_not_present
29
+ if plugin_is_present?
30
+ puts "You must first remove the hoptoad_notifier plugin. Please run: script/plugin remove hoptoad_notifier"
31
+ exit
32
+ end
33
+ end
34
+
35
+ def append_capistrano_hook
36
+ if File.exists?('config/deploy.rb') && File.exists?('Capfile')
37
+ append_file('config/deploy.rb', <<-HOOK)
38
+
39
+ require 'config/boot'
40
+ require 'hoptoad_notifier/capistrano'
41
+ HOOK
42
+ end
43
+ end
44
+
45
+ def api_key
46
+ options[:api_key]
47
+ end
48
+
49
+ def generate_initializer
50
+ template 'initializer.rb', 'config/initializers/hoptoad.rb'
51
+ end
52
+
53
+ def api_key_configured?
54
+ File.exists?('config/initializers/hoptoad.rb')
55
+ end
56
+
57
+ def test_hoptoad
58
+ puts run("rake hoptoad:test --trace")
59
+ end
60
+
61
+ def plugin_is_present?
62
+ File.exists?('vendor/plugins/hoptoad_notifier')
63
+ end
64
+ end
@@ -339,9 +339,6 @@ class NoticeTest < Test::Unit::TestCase
339
339
  end
340
340
 
341
341
  should "extract data from a rack environment hash" do
342
- # TODO: extract session data
343
- # TODO: extract controller
344
- # TODO: extract action
345
342
  url = "https://subdomain.happylane.com:100/test/file.rb?var=value&var2=value2"
346
343
  parameters = { 'var' => 'value', 'var2' => 'value2' }
347
344
  env = Rack::MockRequest.env_for(url)
@@ -353,6 +350,35 @@ class NoticeTest < Test::Unit::TestCase
353
350
  assert_equal 'GET', notice.cgi_data['REQUEST_METHOD']
354
351
  end
355
352
 
353
+ should "extract data from a rack environment hash with action_dispatch info" do
354
+ params = { 'controller' => 'users', 'action' => 'index', 'id' => '7' }
355
+ env = Rack::MockRequest.env_for('/', { 'action_dispatch.request.parameters' => params })
356
+
357
+ notice = build_notice(:rack_env => env)
358
+
359
+ assert_equal params, notice.parameters
360
+ assert_equal params['controller'], notice.component
361
+ assert_equal params['action'], notice.action
362
+ end
363
+
364
+ should "extract session data from a rack environment" do
365
+ session_data = { 'something' => 'some value' }
366
+ env = Rack::MockRequest.env_for('/', 'rack.session' => session_data)
367
+
368
+ notice = build_notice(:rack_env => env)
369
+
370
+ assert_equal session_data, notice.session_data
371
+ end
372
+
373
+ should "prefer passed session data to rack session data" do
374
+ session_data = { 'something' => 'some value' }
375
+ env = Rack::MockRequest.env_for('/')
376
+
377
+ notice = build_notice(:rack_env => env, :session_data => session_data)
378
+
379
+ assert_equal session_data, notice.session_data
380
+ end
381
+
356
382
  def assert_accepts_exception_attribute(attribute, args = {}, &block)
357
383
  exception = build_exception
358
384
  block ||= lambda { exception.send(attribute) }
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 2
7
7
  - 2
8
- - 2
9
- version: 2.2.2
8
+ - 5
9
+ version: 2.2.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - thoughtbot, inc
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-03-10 00:00:00 -05:00
17
+ date: 2010-06-02 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -120,11 +120,14 @@ files:
120
120
  - lib/hoptoad_notifier/rails/controller_methods.rb
121
121
  - lib/hoptoad_notifier/rails/error_lookup.rb
122
122
  - lib/hoptoad_notifier/rails.rb
123
+ - lib/hoptoad_notifier/rails3_tasks.rb
124
+ - lib/hoptoad_notifier/railtie.rb
123
125
  - lib/hoptoad_notifier/sender.rb
124
126
  - lib/hoptoad_notifier/tasks.rb
125
127
  - lib/hoptoad_notifier/version.rb
126
128
  - lib/hoptoad_notifier.rb
127
129
  - lib/hoptoad_tasks.rb
130
+ - lib/rails/generators/hoptoad/hoptoad_generator.rb
128
131
  - test/backtrace_test.rb
129
132
  - test/catcher_test.rb
130
133
  - test/configuration_test.rb