airbrake-ruby 4.13.4 → 4.14.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
  SHA256:
3
- metadata.gz: da4c29476df09886ee5e0d9b1b4738cb77a93d9f415c284c57266a64334cf8be
4
- data.tar.gz: c12fad300807903f28b3d3dcdc472e729d6e27e74fca597467774c9ea8ab347a
3
+ metadata.gz: 6b246c5d84c2bc6ff22b535260b416d37bbc2fca17fff01ae3705156ce68a74b
4
+ data.tar.gz: 743b3190115223bf043cf8ecf7e9b5a8bb32b40206c146967d86489514247d99
5
5
  SHA512:
6
- metadata.gz: '059b5f84a0ef2c158ead7d0026ff9529c03bdcb8e67d5fb95c8a36465af0bd7510ef8426d7ab644e7d3be9d7884f569d130397ca65854ddd03d34f2c332b30f2'
7
- data.tar.gz: 683a8c9d90db59353e70c2f4474825ce583cb8a8d68ff01d895794bd4d6def0daa3ae7898f2ef10398ca24a8361c5fa3d53ae21b270182653431469955b9c578
6
+ metadata.gz: c798358c9215c8ba703fd81163378bcd828200a71cc2ad026f9569684ca654ac094d01f38548c2fe5919ad744456c7a42bd58304d961b5c1997b00e4a4df0f8f
7
+ data.tar.gz: b7ed80303a34c3b0f58b51037063428384b4680273729f88062fd22146fcccfc55989a0f77ddc88a502859d234661a1243853d98fc1abc05f951a703962ec6af
@@ -570,6 +570,7 @@ module Airbrake
570
570
 
571
571
  private
572
572
 
573
+ # rubocop:disable Metrics/AbcSize
573
574
  def process_config_options(config)
574
575
  if config.blacklist_keys.any?
575
576
  blacklist = Airbrake::Filters::KeysBlacklist.new(config.blacklist_keys)
@@ -581,7 +582,6 @@ module Airbrake
581
582
  notice_notifier.add_filter(whitelist)
582
583
  end
583
584
 
584
- return if configured?
585
585
  return unless config.root_directory
586
586
 
587
587
  [
@@ -590,9 +590,12 @@ module Airbrake
590
590
  Airbrake::Filters::GitRepositoryFilter,
591
591
  Airbrake::Filters::GitLastCheckoutFilter,
592
592
  ].each do |filter|
593
+ next if notice_notifier.has_filter?(filter)
594
+
593
595
  notice_notifier.add_filter(filter.new(config.root_directory))
594
596
  end
595
597
  end
598
+ # rubocop:enable Metrics/AbcSize
596
599
  end
597
600
  end
598
601
  # rubocop:enable Metrics/ModuleLength
@@ -76,7 +76,7 @@ module Airbrake
76
76
 
77
77
  # @return [String] customized inspect to lessen the amount of clutter
78
78
  def inspect
79
- @filters.map(&:class).to_s
79
+ filter_classes.to_s
80
80
  end
81
81
 
82
82
  # @return [String] {#inspect} for PrettyPrint
@@ -91,5 +91,19 @@ module Airbrake
91
91
  end
92
92
  q.text(']')
93
93
  end
94
+
95
+ # @param [Class] filter_class
96
+ # @return [Boolean] true if the current chain has an instance of the given
97
+ # class, false otherwise
98
+ # @since v4.14.0
99
+ def includes?(filter_class)
100
+ filter_classes.include?(filter_class)
101
+ end
102
+
103
+ private
104
+
105
+ def filter_classes
106
+ @filters.map(&:class)
107
+ end
94
108
  end
95
109
  end
@@ -82,6 +82,12 @@ module Airbrake
82
82
  @context.merge!(context)
83
83
  end
84
84
 
85
+ # @return [Boolean]
86
+ # @since v4.14.0
87
+ def has_filter?(filter_class) # rubocop:disable Naming/PredicateName
88
+ @filter_chain.includes?(filter_class)
89
+ end
90
+
85
91
  private
86
92
 
87
93
  def convert_to_exception(ex)
@@ -2,5 +2,5 @@
2
2
  # More information: http://semver.org/
3
3
  module Airbrake
4
4
  # @return [String] the library version
5
- AIRBRAKE_RUBY_VERSION = '4.13.4'.freeze
5
+ AIRBRAKE_RUBY_VERSION = '4.14.0'.freeze
6
6
  end
@@ -85,6 +85,18 @@ RSpec.describe Airbrake do
85
85
  expect(described_class.notice_notifier).not_to receive(:add_filter)
86
86
  10.times { described_class.configure {} }
87
87
  end
88
+
89
+ it "appends some default filters" do
90
+ allow(described_class.notice_notifier).to receive(:add_filter)
91
+ expect(described_class.notice_notifier).to receive(:add_filter).with(
92
+ an_instance_of(Airbrake::Filters::RootDirectoryFilter),
93
+ )
94
+
95
+ described_class.configure do |c|
96
+ c.project_id = 1
97
+ c.project_key = '2'
98
+ end
99
+ end
88
100
  end
89
101
 
90
102
  context "when blacklist_keys gets configured" do
@@ -89,4 +89,31 @@ RSpec.describe Airbrake::FilterChain do
89
89
  expect(subject.inspect).to eq('[Proc]')
90
90
  end
91
91
  end
92
+
93
+ describe "#includes?" do
94
+ context "when a custom filter class is included in the filter chain" do
95
+ it "returns true" do
96
+ klass = Class.new {}
97
+
98
+ subject.add_filter(klass.new)
99
+ expect(subject.includes?(klass)).to eq(true)
100
+ end
101
+ end
102
+
103
+ context "when Proc filter class is included in the filter chain" do
104
+ it "returns true" do
105
+ subject.add_filter(proc {})
106
+ expect(subject.includes?(Proc)).to eq(true)
107
+ end
108
+ end
109
+
110
+ context "when filter class is NOT included in the filter chain" do
111
+ it "returns false" do
112
+ klass = Class.new {}
113
+
114
+ subject.add_filter(proc {})
115
+ expect(subject.includes?(klass)).to eq(false)
116
+ end
117
+ end
118
+ end
92
119
  end
@@ -389,7 +389,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
389
389
  subject.close
390
390
 
391
391
  expect(promise).to be_an(Airbrake::Promise)
392
- expect(promise.value).to eq('' => nil)
392
+ expect(promise.value).to eq('' => '')
393
393
  end
394
394
 
395
395
  it "checks performance stat configuration" do
@@ -601,7 +601,7 @@ RSpec.describe Airbrake::PerformanceNotifier do
601
601
  body: %r|\A{"queries":\[{"method":"POST","route":"/foo"|,
602
602
  ),
603
603
  ).to have_been_made
604
- expect(retval).to eq('' => nil)
604
+ expect(retval).to eq('' => '')
605
605
  end
606
606
  end
607
607
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: airbrake-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.13.4
4
+ version: 4.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Airbrake Technologies, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-09 00:00:00.000000000 Z
11
+ date: 2020-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbtree3