yeller_ruby 0.1.4 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1bc4dfe4cdd8c6603b2d69c726871777fd36f993
4
- data.tar.gz: d20de3a957643e0104836a088b06114db1bcbfaf
3
+ metadata.gz: 5853d9f2c5962d8699ee7fed01219c03b80cd630
4
+ data.tar.gz: 7fb9baee25cf724a77c8f009204226987e99d1cc
5
5
  SHA512:
6
- metadata.gz: 4b2a330661919869d5aea4b0087623972efb09d0633fa614e835b60edcb54c2a5cfd5770d019b248afa916481b9ce4ad4727509be2c5d3cd80788979852d9863
7
- data.tar.gz: e1c9d17782072e4e273b89614ae130e60ea28c8b8f373b99c891fb02ea4d9bcfb5ae1c5c7c8acb730763559ece461f05052892ac3387bdeaafb0fade10aa9537
6
+ metadata.gz: f6f42956eeb821511c14cb9b505011a0e2792870e7f642005e15016e3ab1e5508524b8751029ff712d7569b0e2cb362e906fa089808b96d851a096ddb39c2c1a
7
+ data.tar.gz: 5b3e9c26c3e0a9ab9f56605ce254c52bded934e80bd4efe7c0c72353ff2df15520ed55de49d46c3acdc615f9b0016284a55bd08b3852c6af7d7358a2d38b6a7e
@@ -20,6 +20,7 @@ module Yeller
20
20
  end
21
21
 
22
22
  def filter_method(method)
23
+ return '' if method.nil?
23
24
  method_filters.each do |filter|
24
25
  method.gsub!(filter[0], filter[1])
25
26
  end
@@ -1,4 +1,4 @@
1
- require_relative 'server'
1
+ require File.expand_path('../server', __FILE__)
2
2
 
3
3
  module Yeller
4
4
  class Configuration
@@ -41,9 +41,9 @@ module Yeller
41
41
 
42
42
  def to_hash
43
43
  result = {
44
- message: message,
45
- stacktrace: formatted_backtrace,
46
- type: type,
44
+ :message => message,
45
+ :stacktrace => formatted_backtrace,
46
+ :type => type,
47
47
  :"custom-data" => options.fetch(:custom_data, {})
48
48
  }
49
49
  result[:url] = options[:url] if options.key?(:url)
data/lib/yeller/rack.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  require 'rack/request'
2
- require_relative '../yeller'
2
+ require File.expand_path('../../yeller', __FILE__)
3
3
 
4
4
  module Yeller
5
5
  class Rack
data/lib/yeller/rails.rb CHANGED
@@ -1,13 +1,16 @@
1
- require 'rails'
2
- require 'yeller'
3
- require 'yeller/rack'
1
+ require File.expand_path('../../yeller', __FILE__)
2
+ require File.expand_path('../../yeller/rack', __FILE__)
4
3
 
5
4
  module Yeller
6
5
  class Rails
7
6
  def self.configure(&block)
8
7
  Yeller::Rack.configure do |config|
9
- config.error_handler = Yeller::LogErrorHandler.new(::Rails.logger)
10
- config.environment = ::Rails.env.to_s
8
+ if defined?(::Rails)
9
+ config.error_handler = Yeller::LogErrorHandler.new(::Rails.logger)
10
+ config.environment = ::Rails.env.to_s
11
+ elsif ENV['RAILS_ENV']
12
+ config.environment = ENV['RAILS_ENV']
13
+ end
11
14
  block.call(config)
12
15
  end
13
16
  end
@@ -24,7 +27,7 @@ module Yeller
24
27
  def _yeller_custom_data
25
28
  out = {
26
29
  :params => params,
27
- :session => env.fetch('rack.session', {})
30
+ :session => request.env.fetch('rack.session', {})
28
31
  }
29
32
  out.merge!(yeller_user_data || {})
30
33
  if respond_to?(:yeller_custom_data)
@@ -42,13 +45,12 @@ module Yeller
42
45
  end
43
46
  end
44
47
 
45
- module ActionControllerCatchingHooks
48
+ module Rails3AndFourCatchingHooks
46
49
  def self.included(base)
47
50
  base.send(:alias_method, :render_exception_without_yeller, :render_exception)
48
51
  base.send(:alias_method, :render_exception, :render_exception_with_yeller)
49
52
  end
50
53
 
51
- protected
52
54
  def render_exception_with_yeller(env, exception)
53
55
  Yeller::VerifyLog.render_exception_with_yeller!
54
56
  begin
@@ -65,35 +67,75 @@ module Yeller
65
67
  )
66
68
  else
67
69
  Yeller::VerifyLog.action_controller_instance_not_in_env!
68
- Yeller::Rack.report(
69
- exception,
70
- :url => request.url
71
- )
70
+ Yeller::Rack.rescue_rack_exception(exception, env)
72
71
  end
73
72
  rescue => e
74
73
  Yeller::VerifyLog.error_reporting_rails_error!(e)
75
74
  end
76
-
77
75
  render_exception_without_yeller(env, exception)
78
76
  end
79
77
  end
80
78
 
81
- class Railtie < ::Rails::Railtie
82
- initializer "yeller.use_rack_middleware" do |app|
83
- app.config.middleware.insert 0, "Yeller::Rack"
79
+ module Rails2CatchingHooks
80
+ def self.included(base)
81
+ Yeller::VerifyLog.monkey_patching_rails!("ActionController::Base.rescue_action_in_public")
82
+ base.send(:alias_method, :rescue_action_in_public_without_yeller, :rescue_action_in_public)
83
+ base.send(:alias_method, :rescue_action_in_public, :rescue_public_exception_with_yeller)
84
+
85
+ Yeller::VerifyLog.monkey_patching_rails!("ActionController::Base.rescue_action_locally")
86
+ base.send(:alias_method, :rescue_action_locally_without_yeller, :rescue_action_locally)
87
+ base.send(:alias_method, :rescue_action_locally, :rescue_local_exception_with_yeller)
84
88
  end
85
89
 
86
- config.after_initialize do
87
- if defined?(::ActionDispatch::DebugExceptions)
88
- Yeller::VerifyLog.monkey_patching_rails!("ActionDispatch::DebugExceptions")
89
- ::ActionDispatch::DebugExceptions.send(:include, Yeller::Rails::ActionControllerCatchingHooks)
90
- end
91
- if defined?(::ActionDispatch::ShowExceptions)
92
- Yeller::VerifyLog.monkey_patching_rails!("ActionDispatch::ShowExceptions")
93
- ::ActionDispatch::ShowExceptions.send(:include, Yeller::Rails::ActionControllerCatchingHooks)
90
+ protected
91
+ def rescue_public_exception_with_yeller(exception)
92
+ _send_to_yeller(exception)
93
+ rescue_action_in_public_without_yeller(exception)
94
+ end
95
+
96
+ def rescue_local_exception_with_yeller(exception)
97
+ _send_to_yeller(exception)
98
+ rescue_action_locally_without_yeller(exception)
99
+ end
100
+
101
+ def _send_to_yeller(exception)
102
+ Yeller::VerifyLog.render_exception_with_yeller!
103
+ controller = self
104
+ params = controller.send(:params)
105
+ Yeller::Rack.report(
106
+ exception,
107
+ :url => request.url,
108
+ :location => "#{controller.class.to_s}##{params[:action]}",
109
+ :custom_data => controller._yeller_custom_data
110
+ )
111
+ end
112
+ end
113
+
114
+ def self.monkeypatch_rails3!
115
+ if defined?(::ActionDispatch::DebugExceptions)
116
+ ::ActionDispatch::DebugExceptions.send(:include, Yeller::Rails::Rails3AndFourCatchingHooks)
117
+ elsif defined?(::ActionDispatch::ShowExceptions)
118
+ ::ActionDispatch::ShowExceptions.send(:include, Yeller::Rails::Rails3AndFourCatchingHooks)
119
+ end
120
+
121
+ if defined?(::ActionController)
122
+ ::ActionController::Base.send(:include, Yeller::Rails::ControllerMethods)
123
+ end
124
+ end
125
+
126
+ if defined?(::Rails) && defined?(::Rails::Railtie)
127
+ class Railtie < ::Rails::Railtie
128
+ initializer "yeller.use_rack_middleware" do |app|
129
+ app.config.middleware.insert 0, "Yeller::Rack"
94
130
  end
95
- ActionController::Base.send(:include, Yeller::Rails::ControllerMethods)
131
+
132
+ config.after_initialize do
133
+ Yeller::Rails.monkeypatch_rails3!
134
+ end
96
135
  end
136
+ elsif defined?(ActionController::Base)
137
+ ActionController::Base.send(:include, Yeller::Rails::Rails2CatchingHooks)
138
+ ActionController::Base.send(:include, Yeller::Rails::ControllerMethods)
97
139
  end
98
140
  end
99
141
  end
data/lib/yeller/server.rb CHANGED
@@ -15,7 +15,9 @@ module Yeller
15
15
  http = Net::HTTP.new(host, port)
16
16
  http.use_ssl = true
17
17
  http.verify_mode = OpenSSL::SSL::VERIFY_PEER
18
- http.ciphers = "DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2"
18
+ if http.respond_to?(:ciphers=)
19
+ http.ciphers = "DEFAULT:!aNULL:!eNULL:!LOW:!EXPORT:!SSLv2"
20
+ end
19
21
  http
20
22
  end
21
23
  end
@@ -1,4 +1,4 @@
1
- require_relative 'version'
1
+ require File.expand_path('../version', __FILE__)
2
2
 
3
3
  module Yeller
4
4
  class StartupParams
@@ -1,3 +1,3 @@
1
1
  module Yeller
2
- VERSION = "0.1.4"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/yeller.rb CHANGED
@@ -1,24 +1,16 @@
1
1
  require 'net/http'
2
2
  require 'yajl/json_gem'
3
3
 
4
- require_relative 'yeller/backtrace_filter'
5
- require_relative 'yeller/client'
6
- require_relative 'yeller/ignoring_client'
7
- require_relative 'yeller/configuration'
8
- require_relative 'yeller/exception_formatter'
9
- require_relative 'yeller/server'
10
- require_relative 'yeller/version'
11
- require_relative 'yeller/startup_params'
12
- require_relative 'yeller/log_error_handler'
13
- require_relative 'yeller/verify_log'
14
-
15
- if defined?(::Rails)
16
- require 'yeller/rails'
17
- end
18
-
19
- if defined?(::Rails) && defined?(::Rake)
20
- require 'yeller/rails/tasks'
21
- end
4
+ require File.expand_path('../yeller/backtrace_filter', __FILE__)
5
+ require File.expand_path('../yeller/client', __FILE__)
6
+ require File.expand_path('../yeller/ignoring_client', __FILE__)
7
+ require File.expand_path('../yeller/configuration', __FILE__)
8
+ require File.expand_path('../yeller/exception_formatter', __FILE__)
9
+ require File.expand_path('../yeller/server', __FILE__)
10
+ require File.expand_path('../yeller/version', __FILE__)
11
+ require File.expand_path('../yeller/startup_params', __FILE__)
12
+ require File.expand_path('../yeller/log_error_handler', __FILE__)
13
+ require File.expand_path('../yeller/verify_log', __FILE__)
22
14
 
23
15
  module Yeller
24
16
  def self.client(*blocks, &block)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yeller_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Crayford
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-29 00:00:00.000000000 Z
11
+ date: 2014-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler