airbadger 0.0.4 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/airbadger.rb +7 -23
- data/lib/airbadger/proxying_error_collector.rb +18 -0
- data/lib/airbadger/version.rb +1 -1
- data/spec/airbadger_spec.rb +13 -50
- data/spec/spec_helper.rb +0 -18
- metadata +3 -11
- data/lib/airbadger/airbrake_loader.rb +0 -52
- data/lib/airbadger/configuration.rb +0 -35
- data/lib/airbadger/warning_suppression.rb +0 -9
- data/spec/airbrake_loader_spec.rb +0 -49
- data/spec/configuration_spec.rb +0 -46
- data/spec/warning_suppression_spec.rb +0 -39
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1de42cf567b6d7ddab5665c3c13f751bd2f6b832
|
4
|
+
data.tar.gz: 3311757fd84cb7805f33f1cab39a7ad464b4e5b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c1e021b6a988b19b89279e9e01402cfd0ad59a4f6b8e9b874553c21aef91b5ebca8dd780514f3e0fbe715edea07afdc486e5ccf792d00799e2604ef77590d2e
|
7
|
+
data.tar.gz: 9ac06114fab252695124859d4b2252e149beed93b05209e8f08e704cc7eb56353b83f3ad13ae874751dc57cd171ec47f4a6e2a3969e1bd2cf98244aca23aa88a
|
data/lib/airbadger.rb
CHANGED
@@ -1,30 +1,14 @@
|
|
1
1
|
require 'airbadger/version'
|
2
2
|
|
3
|
-
require 'airbadger/
|
4
|
-
require 'airbadger/airbrake_loader'
|
5
|
-
require 'airbadger/configuration'
|
3
|
+
require 'airbadger/proxying_error_collector'
|
6
4
|
|
7
|
-
|
8
|
-
|
9
|
-
configuration.instance_eval(&block)
|
10
|
-
configuration.setup_proxy!
|
11
|
-
end
|
12
|
-
|
13
|
-
def self.method_missing(method_name, *args, &block)
|
14
|
-
if PROXIED_METHODS.include? method_name
|
15
|
-
configuration.loaded_endpoints.each do |endpoint|
|
16
|
-
endpoint.send(method_name, *args, &block)
|
17
|
-
end
|
18
|
-
return nil
|
19
|
-
end
|
20
|
-
super
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
5
|
+
require 'airbrake'
|
6
|
+
require 'honeybadger'
|
24
7
|
|
25
|
-
|
8
|
+
module Airbadger
|
9
|
+
ERROR_COLLECTORS = [Airbrake, Honeybadger]
|
26
10
|
|
27
|
-
|
28
|
-
|
11
|
+
ERROR_COLLECTORS.each do |error_collector|
|
12
|
+
error_collector.extend(ProxyingErrorCollector)
|
29
13
|
end
|
30
14
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Airbadger::ProxyingErrorCollector
|
2
|
+
PROXY_METHODS = [:notify, :notify_or_ignore]
|
3
|
+
|
4
|
+
def self.extend_object(error_collector)
|
5
|
+
class << error_collector
|
6
|
+
Airbadger::ProxyingErrorCollector::PROXY_METHODS.each do |method_name|
|
7
|
+
define_method "#{method_name}_with_proxy" do |*args|
|
8
|
+
Airbadger::ERROR_COLLECTORS.each do |proxied_collector|
|
9
|
+
proxied_collector.send("#{method_name}_without_proxy", *args)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
alias_method "#{method_name}_without_proxy", method_name
|
14
|
+
alias_method method_name, "#{method_name}_with_proxy"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/airbadger/version.rb
CHANGED
data/spec/airbadger_spec.rb
CHANGED
@@ -1,63 +1,26 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
Airbadger.configure do
|
10
|
-
endpoint :raygun do |config|
|
11
|
-
config.test_mode = true
|
12
|
-
end
|
13
|
-
endpoint :errbit do |config|
|
3
|
+
[Airbrake, Honeybadger].each do |error_api|
|
4
|
+
describe error_api do
|
5
|
+
['#notify', '#notify_or_ignore'].each do |proxied_method|
|
6
|
+
describe proxied_method do
|
7
|
+
before :all do
|
8
|
+
Airbrake.configure do |config|
|
14
9
|
config.test_mode = true
|
15
10
|
end
|
16
11
|
end
|
17
12
|
|
18
|
-
|
13
|
+
it 'proxies calls to Airbrake and Honeybadger' do
|
14
|
+
proxied_method.sub!('#', '')
|
19
15
|
|
20
|
-
|
21
|
-
Errbit.should_receive(proxied_method).with(error)
|
22
|
-
|
23
|
-
Airbadger.send(proxied_method, error)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
16
|
+
error = Exception.new('Some serious shit went down')
|
27
17
|
|
28
|
-
|
29
|
-
|
30
|
-
endpoint :raygun do |config|
|
31
|
-
config.test_mode = true
|
32
|
-
end
|
33
|
-
endpoint :airbrake do |config|
|
34
|
-
config.test_mode = true
|
35
|
-
end
|
36
|
-
end
|
18
|
+
Airbrake.should_receive("#{proxied_method}_without_proxy").with(error)
|
19
|
+
Honeybadger.should_receive("#{proxied_method}_without_proxy").with(error)
|
37
20
|
|
38
|
-
|
39
|
-
|
40
|
-
Raygun.should_receive(:notify).with(error)
|
41
|
-
AirbrakeProxied.should_receive(:notify).with(error)
|
42
|
-
|
43
|
-
Airbrake.notify(error)
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'proxies calls to Honeybadger' do
|
47
|
-
Airbadger.configure do
|
48
|
-
endpoint :raygun do |config|
|
49
|
-
config.test_mode = true
|
50
|
-
end
|
51
|
-
endpoint :honeybadger do |config|
|
52
|
-
config.ignore_only = []
|
21
|
+
error_api.send(proxied_method, error)
|
22
|
+
end
|
53
23
|
end
|
54
24
|
end
|
55
|
-
|
56
|
-
error = Exception.new('Some serious shit went down')
|
57
|
-
|
58
|
-
Raygun.should_receive(:notify).with(error)
|
59
|
-
Honeybadger.should_receive(:notify).with(error)
|
60
|
-
|
61
|
-
Airbadger.notify(error)
|
62
25
|
end
|
63
26
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -13,28 +13,10 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
13
13
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
14
14
|
require 'airbadger'
|
15
15
|
|
16
|
-
EXAMPLE_SERVICE_NAMES = [
|
17
|
-
'Airbrake',
|
18
|
-
'AirbrakeProxied',
|
19
|
-
'BasicAirbrake',
|
20
|
-
'Errbit',
|
21
|
-
'Raygun'
|
22
|
-
]
|
23
|
-
|
24
16
|
RSpec.configure do |config|
|
25
17
|
# Run specs in random order to surface order dependencies. If you find an
|
26
18
|
# order dependency and want to debug it, you can fix the order by providing
|
27
19
|
# the seed, which is printed after each run.
|
28
20
|
# --seed 1234
|
29
21
|
config.order = 'random'
|
30
|
-
|
31
|
-
config.before :each do
|
32
|
-
EXAMPLE_SERVICE_NAMES.each do |service_name|
|
33
|
-
Object.send(:remove_const, service_name) if Object.const_defined?(service_name)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
config.before :each do
|
38
|
-
Airbadger.instance_variable_set('@configuration', nil)
|
39
|
-
end
|
40
22
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: airbadger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Jordan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: airbrake
|
@@ -112,15 +112,10 @@ files:
|
|
112
112
|
- Rakefile
|
113
113
|
- airbadger.gemspec
|
114
114
|
- lib/airbadger.rb
|
115
|
-
- lib/airbadger/
|
116
|
-
- lib/airbadger/configuration.rb
|
115
|
+
- lib/airbadger/proxying_error_collector.rb
|
117
116
|
- lib/airbadger/version.rb
|
118
|
-
- lib/airbadger/warning_suppression.rb
|
119
117
|
- spec/airbadger_spec.rb
|
120
|
-
- spec/airbrake_loader_spec.rb
|
121
|
-
- spec/configuration_spec.rb
|
122
118
|
- spec/spec_helper.rb
|
123
|
-
- spec/warning_suppression_spec.rb
|
124
119
|
homepage: http://github.com/joshjordan/airbadger
|
125
120
|
licenses:
|
126
121
|
- MIT
|
@@ -147,7 +142,4 @@ specification_version: 4
|
|
147
142
|
summary: Reports errors to multiple Airbrake-compatible endpoints
|
148
143
|
test_files:
|
149
144
|
- spec/airbadger_spec.rb
|
150
|
-
- spec/airbrake_loader_spec.rb
|
151
|
-
- spec/configuration_spec.rb
|
152
145
|
- spec/spec_helper.rb
|
153
|
-
- spec/warning_suppression_spec.rb
|
@@ -1,52 +0,0 @@
|
|
1
|
-
class Airbadger::AirbrakeLoader
|
2
|
-
def self.load_as(airbrake_alias)
|
3
|
-
new(airbrake_alias).load_aliased
|
4
|
-
end
|
5
|
-
|
6
|
-
def load_aliased
|
7
|
-
without_recording_loaded_features do
|
8
|
-
load_airbrake!
|
9
|
-
load_airbrake_rails! if defined?(::Rails)
|
10
|
-
end
|
11
|
-
aliased_module.tap do
|
12
|
-
preserve_namespaced_calls!
|
13
|
-
remove_airbrake_from_global_namespace!
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
private
|
18
|
-
|
19
|
-
attr_reader :endpoint_alias
|
20
|
-
|
21
|
-
def initialize(endpoint_alias)
|
22
|
-
@endpoint_alias = endpoint_alias.sub(/^Airbrake$/, 'AirbrakeProxied')
|
23
|
-
end
|
24
|
-
|
25
|
-
def load_airbrake!
|
26
|
-
require 'airbrake'
|
27
|
-
end
|
28
|
-
|
29
|
-
def load_airbrake_rails!
|
30
|
-
require 'airbrake/rails/controller_methods'
|
31
|
-
require 'airbrake/rails/javascript_notifier'
|
32
|
-
end
|
33
|
-
|
34
|
-
def aliased_module
|
35
|
-
@aliased_module ||= Object.const_set(endpoint_alias, Airbrake)
|
36
|
-
end
|
37
|
-
|
38
|
-
def preserve_namespaced_calls!
|
39
|
-
aliased_module.const_set('Airbrake', aliased_module)
|
40
|
-
end
|
41
|
-
|
42
|
-
def remove_airbrake_from_global_namespace!
|
43
|
-
Object.send(:remove_const, 'Airbrake')
|
44
|
-
end
|
45
|
-
|
46
|
-
def without_recording_loaded_features
|
47
|
-
feature_count = $LOADED_FEATURES.count
|
48
|
-
yield
|
49
|
-
ensure
|
50
|
-
$LOADED_FEATURES.pop while feature_count < $LOADED_FEATURES.count
|
51
|
-
end
|
52
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
class Airbadger::Configuration
|
2
|
-
include Airbadger::WarningSuppression
|
3
|
-
|
4
|
-
def endpoint(service_name, &block)
|
5
|
-
load_endpoint(service_name).configure(&block)
|
6
|
-
end
|
7
|
-
|
8
|
-
def setup_proxy!
|
9
|
-
Object.const_set('Airbrake', Airbadger)
|
10
|
-
end
|
11
|
-
|
12
|
-
def loaded_endpoints
|
13
|
-
@loaded_modules ||= []
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
ENDPOINT_LOADERS = Hash.new(::Airbadger::AirbrakeLoader.method(:load_as)).merge({
|
19
|
-
'Honeybadger' => Proc.new do
|
20
|
-
require 'honeybadger'
|
21
|
-
Honeybadger
|
22
|
-
end
|
23
|
-
})
|
24
|
-
|
25
|
-
def load_endpoint(service_name)
|
26
|
-
service_name = ghetto_classify(service_name)
|
27
|
-
without_warnings do
|
28
|
-
ENDPOINT_LOADERS[service_name].call(service_name)
|
29
|
-
end.tap(&loaded_endpoints.method(:push))
|
30
|
-
end
|
31
|
-
|
32
|
-
def ghetto_classify(snake_cased)
|
33
|
-
snake_cased.to_s.split('_').collect{ |str| str[0] = str[0].upcase; str }.join
|
34
|
-
end
|
35
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Airbadger::AirbrakeLoader do
|
4
|
-
include Airbadger::WarningSuppression
|
5
|
-
|
6
|
-
describe '.load_as' do
|
7
|
-
it 'loads a new Airbrake singleton with the given name' do
|
8
|
-
without_warnings do
|
9
|
-
described_class.load_as('Errbit')
|
10
|
-
described_class.load_as('Raygun')
|
11
|
-
end
|
12
|
-
|
13
|
-
Errbit.should respond_to :notify
|
14
|
-
Raygun.should respond_to :notify
|
15
|
-
Errbit.should_not eq Raygun
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'produces endpoints singletons capable of receiving error data' do
|
19
|
-
without_warnings do
|
20
|
-
described_class.load_as('Errbit')
|
21
|
-
end
|
22
|
-
Errbit.configure do |config|
|
23
|
-
config.test_mode = true
|
24
|
-
end
|
25
|
-
|
26
|
-
now = DateTime.now.to_s
|
27
|
-
Errbit.notify(Exception.new(now))
|
28
|
-
|
29
|
-
Errbit.sender.last_notice.should include(now)
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'eager-loads Rails extensions when Rails is running' do
|
33
|
-
Rails = Module.new
|
34
|
-
without_warnings { described_class.load_as('Errbit') }
|
35
|
-
|
36
|
-
defined?(Errbit::Rails::ControllerMethods).should be_true
|
37
|
-
defined?(Errbit::Rails::JavascriptNotifier).should be_true
|
38
|
-
|
39
|
-
Object.send(:remove_const, 'Rails')
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'does not load Rails extensions when Rails is not running' do
|
43
|
-
without_warnings { described_class.load_as('Errbit') }
|
44
|
-
|
45
|
-
defined?(Errbit::Rails::ControllerMethods).should be_false
|
46
|
-
defined?(Errbit::Rails::JavascriptNotifier).should be_false
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
data/spec/configuration_spec.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Airbadger::Configuration do
|
4
|
-
describe '#endpoint' do
|
5
|
-
it 'proxies the configuration block to a named Airbrake singleton' do
|
6
|
-
subject.endpoint :BasicAirbrake do |config|
|
7
|
-
config.test_mode = true
|
8
|
-
end
|
9
|
-
|
10
|
-
subject.endpoint :Errbit do |config|
|
11
|
-
config.test_mode = true
|
12
|
-
config.host = 'errbit.example.com'
|
13
|
-
end
|
14
|
-
|
15
|
-
BasicAirbrake.configuration.host.should eq 'api.airbrake.io'
|
16
|
-
Errbit.configuration.host.should eq 'errbit.example.com'
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'accepts snake-cased service names and produces constants with proper class names' do
|
20
|
-
subject.endpoint :basic_airbrake do |config|
|
21
|
-
config.test_mode = true
|
22
|
-
end
|
23
|
-
|
24
|
-
defined?(BasicAirbrake).should be_true
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'rewrites the name "Airbrake" to "AirbrakeProxied" to avoid collisions' do
|
28
|
-
subject.endpoint :airbrake do |config|
|
29
|
-
config.test_mode = true
|
30
|
-
end
|
31
|
-
|
32
|
-
defined?(Airbrake).should be_false
|
33
|
-
defined?(AirbrakeProxied).should be_true
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'supports Honeybadger configuration from the Honeybadger gem rather than the Airbrake gem' do
|
37
|
-
Airbadger::AirbrakeLoader.should_receive(:load_as).never
|
38
|
-
|
39
|
-
subject.endpoint :honeybadger do |config|
|
40
|
-
config.ignore_only = []
|
41
|
-
end
|
42
|
-
|
43
|
-
defined?(Honeybadger).should be_true
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Airbadger::WarningSuppression do
|
4
|
-
include Airbadger::WarningSuppression
|
5
|
-
|
6
|
-
describe '#without_warnings' do
|
7
|
-
before :each do
|
8
|
-
@old_version = Airbadger::VERSION
|
9
|
-
end
|
10
|
-
|
11
|
-
let! :error_stream do
|
12
|
-
$stderr = StringIO.new
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'executes the block and does not emit warnings into the stderr stream' do
|
16
|
-
without_warnings do
|
17
|
-
Airbadger::VERSION = 42
|
18
|
-
end
|
19
|
-
|
20
|
-
Airbadger::VERSION.should eq 42
|
21
|
-
error_stream.string.should be_empty
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'resumes emitting warnings into the stderr stream after the block' do
|
25
|
-
without_warnings do
|
26
|
-
Airbadger::VERSION = 42
|
27
|
-
end
|
28
|
-
|
29
|
-
Airbadger::VERSION = 43
|
30
|
-
|
31
|
-
error_stream.string.should_not be_empty
|
32
|
-
end
|
33
|
-
|
34
|
-
after :each do
|
35
|
-
Airbadger::VERSION = @old_version
|
36
|
-
$stderr = STDERR
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|