rollbar_helper 0.3.0 → 1.1.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
- SHA256:
3
- metadata.gz: 3188f0c479f3fcc8158ef0e660b53995a8123f84c62361c373ee11eeba01c248
4
- data.tar.gz: 78e439c12122df2e3df02ad041a727aa9ca0dc49dec78e52a38a059154a92bde
2
+ SHA1:
3
+ metadata.gz: 721bf94bc8e941d9290d2f95cf9ef810b1972b0d
4
+ data.tar.gz: 1e7dac2b605c0d3f86c93732698cd9a0f1bb6171
5
5
  SHA512:
6
- metadata.gz: c187bb5ec26c61942af3318452d2fbf06b4b5cacd754382fd409c525f98c61801a6a79d0bb64764d031a74187de6740ea426f45ee8f79b0ebff5fc35e4fdb0f9
7
- data.tar.gz: 6e3fa33e29007565a9a211d5d61456799e285e2c751195147814db91a752c0cf25ed2ec1aa4b2bb578e60dd060a2cc4aed6ea71bde506e8105d0b2fbcc9c04ed
6
+ metadata.gz: 1171c969cf10eb04f5d1aca1137dfa3395f65fa010cc948ad6a65a5801885cb1508d9cf103f774e853d4c05aadaaed14c58b10f7df7cf926e9d42efb1336dbce
7
+ data.tar.gz: 9297aa3f587abc16c395260817cc0e33150b8ab521c32ca1875c3291e61c0ada592c0f498f10b3e519dd07f2e6c7f558a1194b18c7e3e1810bd581e894c007f3
@@ -1,3 +1,3 @@
1
1
  module RollbarHelper
2
- VERSION = '0.3.0'
2
+ VERSION = '1.1.0'.freeze
3
3
  end
@@ -3,55 +3,65 @@ require 'rollbar_helper/version'
3
3
 
4
4
  module RollbarHelper
5
5
  LEVELS = [
6
- :critical,
7
6
  :debug,
8
- :error,
9
7
  :info,
10
8
  :warning,
11
- ]
9
+ :error,
10
+ :critical,
11
+ ].freeze
12
12
 
13
13
  class << self
14
- def critical(obj, fingerprint: nil, **data)
15
- log(:critical, obj, :callee => caller, fingerprint: fingerprint, **data)
16
- end
17
-
18
- def debug(obj, fingerprint: nil, **data)
19
- log(:debug, obj, :callee => caller, fingerprint: fingerprint, **data)
20
- end
14
+ LEVELS.each do |level|
15
+ define_method(level) do |*args|
16
+ message, exception, extra = extract_arguments(args)
17
+ extra = { callee: caller }.merge(extra)
18
+ data, exception, callee, fingerprint = split_extra_arg(extra, exception)
21
19
 
22
- def error(obj, fingerprint: nil, **data)
23
- log(:error, obj, :callee => caller, fingerprint: fingerprint, **data)
24
- end
20
+ if !message.nil? && exception.nil?
21
+ exception = StandardError.new(message).tap do |e|
22
+ e.set_backtrace(callee)
23
+ end
24
+ message = nil
25
+ end
25
26
 
26
- def info(obj, fingerprint: nil, **data)
27
- log(:info, obj, :callee => caller, fingerprint: fingerprint, **data)
27
+ get_notifier(fingerprint).public_send(level, message, exception, data)
28
+ end
28
29
  end
29
30
 
30
- def warn(obj, fingerprint: nil, **data)
31
- log(:warning, obj, :callee => caller, fingerprint: fingerprint, **data)
31
+ def log(level, *args)
32
+ raise ArgumentError, 'Log level is not supported' unless LEVELS.include?(level.to_sym)
33
+ send(level, { callee: caller }, *args)
32
34
  end
33
35
 
34
- def warning(obj, fingerprint: nil, **data)
35
- log(:warning, obj, :callee => caller, fingerprint: fingerprint, **data)
36
- end
36
+ private
37
37
 
38
- def log(level, obj, callee: caller, fingerprint: nil, **data)
39
- level = level.to_sym
40
- raise ArgumentError, 'Log level is not supported' unless LEVELS.include?(level)
41
- e = nil
38
+ def extract_arguments(args)
39
+ message = exception = nil
40
+ extra = {}
42
41
 
43
- if obj.is_a?(Exception)
44
- e = obj
45
- else
46
- e = StandardError.new(obj.to_s)
47
- e.set_backtrace(callee)
42
+ args.each do |arg|
43
+ if arg.is_a?(String)
44
+ message = arg
45
+ elsif arg.is_a?(Exception)
46
+ exception = arg
47
+ elsif arg.is_a?(Hash)
48
+ extra = extra.merge(arg)
49
+ end
48
50
  end
49
51
 
50
- unless fingerprint.nil?
51
- ::Rollbar.scope(:fingerprint => fingerprint).send(level, e, data)
52
- else
53
- ::Rollbar.send(level, e, data)
54
- end
52
+ [message, exception, extra]
53
+ end
54
+
55
+ def split_extra_arg(extra, exception)
56
+ exception ||= extra.delete(:e) # Core legacy support
57
+ callee = extra.delete(:callee)
58
+ fingerprint = extra.delete(:fingerprint)
59
+ [extra, exception, callee, fingerprint]
60
+ end
61
+
62
+ def get_notifier(fingerprint)
63
+ return Rollbar if fingerprint.nil?
64
+ Rollbar.scope(fingerprint: fingerprint)
55
65
  end
56
66
  end
57
67
  end
@@ -31,5 +31,5 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency "rake", "~> 10.0"
32
32
  spec.add_development_dependency "rspec", "~> 3.0"
33
33
  spec.add_development_dependency "pry", "~> 0.11"
34
- spec.add_dependency "rollbar", "~> 2.13"
34
+ spec.add_dependency "rollbar", "~> 3.2"
35
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rollbar_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Santiago Herrera
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-12 00:00:00.000000000 Z
11
+ date: 2024-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '2.13'
75
+ version: '3.2'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '2.13'
82
+ version: '3.2'
83
83
  description:
84
84
  email:
85
85
  - santi.4096@gmail.com
@@ -121,7 +121,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
121
  version: '0'
122
122
  requirements: []
123
123
  rubyforge_project:
124
- rubygems_version: 2.7.7
124
+ rubygems_version: 2.5.2.3
125
125
  signing_key:
126
126
  specification_version: 4
127
127
  summary: Displays a stacktrace in rollbar