airbrake-ruby 1.7.1 → 1.8.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: bbc56120094dd5ebca9b489ba613aca53d696da3
4
- data.tar.gz: d0f207390f282a459a2a80f13223b7c61de5be09
3
+ metadata.gz: bd52bfc797145037c7aa2c4ba9193b860b6a48f4
4
+ data.tar.gz: 2314e4ba463a99416df04c209c2af159e6b384c8
5
5
  SHA512:
6
- metadata.gz: a42ae86774fa693ac7678e6e4a9bc0e6014992f4d1c8ba91b08f615b40fbd36cdbaf8bae42163d7bbb574c3f25292c92fc10e3707c13b42a35706a01ca2de682
7
- data.tar.gz: 4eb63a597c488410fe44972ab6077b11e7d296788e431fda2e956b5fee9f2f58133d0e172f32667d5d1a56aac7b1478d288d5315541c0f0be37e0c87720f9a23
6
+ metadata.gz: da90297990ebb7d1b8ba092750a666ef9324cdd6149195d4d143fb9d74d0963793a9696a403bc5011b8675bab3b8ff5c0c881061d89568e225ef0575a0ad0597
7
+ data.tar.gz: e18299029cd90b600fab49d0867874a3e66f6950c3f882dc1b1c2ab3930846d9de59cb3673afb539926eb1c56c019955d1d3834b51b16d7dea366627e4836b6d
@@ -53,7 +53,7 @@ require 'airbrake-ruby/notifier'
53
53
  #
54
54
  # # Send an exception via other configured notifier.
55
55
  # params = {}
56
- # Airbrake.notify('Oops', params, :my_other_project)
56
+ # Airbrake[:my_other_project].notify('Oops', params)
57
57
  #
58
58
  # @see Airbrake::Notifier
59
59
  # @since v1.0.0
@@ -77,6 +77,18 @@ module Airbrake
77
77
  @notifiers = {}
78
78
 
79
79
  class << self
80
+ ##
81
+ # Retrieves configured notifiers.
82
+ #
83
+ # @example
84
+ # Airbrake[:my_notifier].notify('oops')
85
+ #
86
+ # @return [Airbrake::Notifier, nil]
87
+ # @since v1.8.0
88
+ def [](notifier_name)
89
+ @notifiers[notifier_name]
90
+ end
91
+
80
92
  ##
81
93
  # Configures a new +notifier+ with the given name. If the name is not given,
82
94
  # configures the default notifier.
@@ -139,7 +151,8 @@ module Airbrake
139
151
  # tab in your project's dashboard
140
152
  # @return [Airbrake::Promise]
141
153
  # @see .notify_sync
142
- def notify(exception, params = {}, notifier = :default)
154
+ def notify(exception, params = {}, notifier = (no_arg = true && :default))
155
+ deprecation_warn(__method__, notifier) unless no_arg
143
156
  call_notifier(notifier, __method__, exception, params)
144
157
  end
145
158
 
@@ -153,7 +166,8 @@ module Airbrake
153
166
  #
154
167
  # @return [Hash{String=>String}] the reponse from the server
155
168
  # @see .notify
156
- def notify_sync(exception, params = {}, notifier = :default)
169
+ def notify_sync(exception, params = {}, notifier = (no_arg = true && :default))
170
+ deprecation_warn(__method__, notifier) unless no_arg
157
171
  call_notifier(notifier, __method__, exception, params)
158
172
  end
159
173
 
@@ -184,7 +198,8 @@ module Airbrake
184
198
  # @yieldreturn [void]
185
199
  # @return [void]
186
200
  # @note Once a filter was added, there's no way to delete it
187
- def add_filter(filter = nil, notifier = :default, &block)
201
+ def add_filter(filter = nil, notifier = (no_arg = true && :default), &block)
202
+ deprecation_warn(__method__, notifier) unless no_arg
188
203
  call_notifier(notifier, __method__, filter, &block)
189
204
  end
190
205
 
@@ -204,7 +219,8 @@ module Airbrake
204
219
  # @param [Hash] params The additional params attached to the notice
205
220
  # @return [Airbrake::Notice] the notice built with help of the given
206
221
  # arguments
207
- def build_notice(exception, params = {}, notifier = :default)
222
+ def build_notice(exception, params = {}, notifier = (no_arg = true && :default))
223
+ deprecation_warn(__method__, notifier) unless no_arg
208
224
  call_notifier(notifier, __method__, exception, params)
209
225
  end
210
226
 
@@ -219,7 +235,8 @@ module Airbrake
219
235
  # Airbrake.notify('App crashed!') #=> raises Airbrake::Error
220
236
  #
221
237
  # @return [void]
222
- def close(notifier = :default)
238
+ def close(notifier = (no_arg = true && :default))
239
+ deprecation_warn(__method__, notifier) unless no_arg
223
240
  call_notifier(notifier, __method__)
224
241
  end
225
242
 
@@ -235,7 +252,8 @@ module Airbrake
235
252
  # @option deploy_params [Symbol] :revision
236
253
  # @option deploy_params [Symbol] :version
237
254
  # @return [void]
238
- def create_deploy(deploy_params, notifier = :default)
255
+ def create_deploy(deploy_params, notifier = (no_arg = true && :default))
256
+ deprecation_warn(__method__, notifier) unless no_arg
239
257
  call_notifier(notifier, __method__, deploy_params)
240
258
  end
241
259
 
@@ -252,5 +270,15 @@ module Airbrake
252
270
  def configured?(notifier)
253
271
  @notifiers.key?(notifier)
254
272
  end
273
+
274
+ def deprecation_warn(method, notifier)
275
+ warn(
276
+ "#{LOG_LABEL} `Airbrake.#{method}` method signature was changed. " \
277
+ "Passing `notifier_name` is deprecated and will be removed in the " \
278
+ "next MAJOR release.\n" \
279
+ "Use `Airbrake[:#{notifier}]` to access the :#{notifier} notifier " \
280
+ "and call same methods directly on it."
281
+ )
282
+ end
255
283
  end
256
284
  end
@@ -96,6 +96,11 @@ module Airbrake
96
96
  self.blacklist_keys = []
97
97
  self.whitelist_keys = []
98
98
 
99
+ self.root_directory = (
100
+ (defined?(Bundler) && Bundler.root) ||
101
+ File.expand_path(Dir.pwd)
102
+ )
103
+
99
104
  merge(user_config)
100
105
  end
101
106
 
@@ -4,7 +4,6 @@ module Airbrake
4
4
  # synchronous and asynchronous delivery.
5
5
  #
6
6
  # @see Airbrake::Config The list of options
7
- # @api private
8
7
  # @since v1.0.0
9
8
  class Notifier
10
9
  ##
@@ -4,5 +4,5 @@
4
4
  module Airbrake
5
5
  ##
6
6
  # @return [String] the library version
7
- AIRBRAKE_RUBY_VERSION = '1.7.1'.freeze
7
+ AIRBRAKE_RUBY_VERSION = '1.8.0'.freeze
8
8
  end
@@ -78,7 +78,7 @@ RSpec.describe Airbrake do
78
78
  # rubocop:disable Metrics/LineLength
79
79
  expected_body = %r|
80
80
  {"errors":\[{"type":"RuntimeError","message":"bingo","backtrace":\[
81
- {"file":"[\w/\-\.]+spec/airbrake_spec.rb","line":\d+,"function":"[\w/\s\(\)<>]+"},
81
+ {"file":"\[PROJECT_ROOT\]/spec/airbrake_spec.rb","line":\d+,"function":"[\w/\s\(\)<>]+"},
82
82
  {"file":"\[GEM_ROOT\]/gems/rspec-core-.+/.+","line":\d+,"function":"[\w/\s\(\)<>]+"}
83
83
  |x
84
84
  # rubocop:enable Metrics/LineLength
@@ -167,11 +167,11 @@ RSpec.describe Airbrake do
167
167
  filter_chain = notifier.instance_variable_get(:@filter_chain)
168
168
  filters = filter_chain.instance_variable_get(:@filters)
169
169
 
170
- expect(filters.size).to eq(2)
170
+ expect(filters.size).to eq(3)
171
171
 
172
172
  described_class.add_filter {}
173
173
 
174
- expect(filters.size).to eq(3)
174
+ expect(filters.size).to eq(4)
175
175
  expect(filters.last).to be_a(Proc)
176
176
  end
177
177
  end
@@ -51,8 +51,8 @@ RSpec.describe Airbrake::Config do
51
51
  expect(config.queue_size).to eq(100)
52
52
  end
53
53
 
54
- it "doesn't set the default root_directory" do
55
- expect(config.root_directory).to be_nil
54
+ it "sets the default root_directory" do
55
+ expect(config.root_directory).to eq Bundler.root
56
56
  end
57
57
 
58
58
  it "doesn't set the default environment" do
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: 1.7.1
4
+ version: 1.8.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: 2017-02-03 00:00:00.000000000 Z
11
+ date: 2017-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec