action_reporter 1.2.0 → 1.3.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: a55d0da65743cb598db1ca915e69704f6fd3871921b015193d6445eaf5f1702b
4
- data.tar.gz: 469868c0928f40fbefaabf40a797ce86d3b3aaa16c2f283faaee8dc2ee4a4ee5
3
+ metadata.gz: 6ffc0aa9e71f1bde8106a6271270158927aba409cd2d021a34b6f5a5fa50a302
4
+ data.tar.gz: 72f59c880571a2c959fd924d0600ac013b3e63a9cbd6581df689e489a515dfb5
5
5
  SHA512:
6
- metadata.gz: 9a280cc47e2b244299dd1279e480b1b65454e810f99ad675f5abfefe4b93dc8b80ed2e84816f28222c11d10977384d5c41fb5c23bcbe53f67d517c28b68dbddb
7
- data.tar.gz: b80979582abbedc6db34ba723a8f225200e37c3e2fe5bf5eddd05a4d4301aef0a442fcd97002ac94dc6f4d4fa7cdb383e591afad2108039cb8f80881eb7aeaf6
6
+ metadata.gz: dbd3f847c1cbc6f3cad4ac3dd20be9db54a6b446cc1f3dbef5c0b086e43544ca0554bed0861c08793119def4d51595286be89012b8393d09c6b180436da118af
7
+ data.tar.gz: a38c21395c31224de18f8225d15bb508b4387245563718b83ab824b6a8d34fbc625bed00f2f12a3636f8b4b10d80e162febc0791721cd9f06266284267df2de7
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 1.3.0
2
+
3
+ * Update ruby version to 3.2.2
4
+ * Update dependencies to latest
5
+
1
6
  # 1.2.0
2
7
 
3
8
  * Major fixes for class resolvers
data/README.md CHANGED
@@ -48,7 +48,8 @@ ActionReporter.enabled_reporters = [
48
48
  Then you can use it in your code:
49
49
 
50
50
  ```ruby
51
- ActionReporter.context(audited_user: current_user)
51
+ ActionReporter.audited_user = current_user
52
+ ActionReporter.context(entry_id: entry.id)
52
53
  ActionReporter.notify('Something went wrong', context: { record: record })
53
54
  ```
54
55
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "action_reporter"
3
- s.version = "1.2.0"
3
+ s.version = "1.3.0"
4
4
 
5
5
  s.license = "MIT"
6
6
 
@@ -1,6 +1,6 @@
1
1
  module ActionReporter
2
2
  class AuditedReporter < Base
3
- class_accessor "Audited"
3
+ class_accessor "Audited", gem_spec: "audited (~> 5)"
4
4
 
5
5
  def notify(*)
6
6
  end
@@ -1,11 +1,22 @@
1
+ require_relative 'error'
2
+
1
3
  module ActionReporter
2
4
  class Base
3
- def self.class_accessor(class_name)
5
+ def self.class_accessor(class_name, gem_spec: nil)
4
6
  method_name = class_name.gsub("::", "_").downcase + "_class"
5
7
  define_method(method_name) do
6
- raise Error.new("#{class_name} is not defined") unless Object.const_defined?(class_name)
8
+ raise ActionReporter::Error.new("#{class_name} is not defined") unless Object.const_defined?(class_name)
7
9
 
8
- Object.const_get(class_name)
10
+ @@class_cache ||= {}
11
+ @@class_cache[class_name] ||= begin
12
+ if gem_spec
13
+ gem_name, version = gem_spec.scan(/([^(\s]+)\s*(?:\(([^)]+)\))?/).first
14
+ latest_spec = Gem.loaded_specs[gem_name]
15
+ version_satisfied = latest_spec && Gem::Requirement.new(version).satisfied_by?(latest_spec.version)
16
+ raise ActionReporter::Error.new("#{gem_spec} is not loaded") if !version_satisfied
17
+ end
18
+ Object.const_get(class_name)
19
+ end
9
20
  end
10
21
  end
11
22
 
@@ -1,6 +1,6 @@
1
1
  module ActionReporter
2
2
  class HoneybadgerReporter < Base
3
- class_accessor "Honeybadger"
3
+ class_accessor "Honeybadger", gem_spec: "honeybadger (~> 5)"
4
4
 
5
5
  def notify(error, context: {})
6
6
  new_context = transform_context(context)
@@ -1,7 +1,7 @@
1
1
  module ActionReporter
2
2
  class ScoutApmReporter < Base
3
- class_accessor "ScoutApm::Error"
4
- class_accessor "ScoutApm::Context"
3
+ class_accessor "ScoutApm::Error", gem_spec: "scout_apm (~> 5)"
4
+ class_accessor "ScoutApm::Context", gem_spec: "scout_apm (~> 5)"
5
5
 
6
6
  def notify(error, context: {})
7
7
  self.context(context)
@@ -1,6 +1,6 @@
1
1
  module ActionReporter
2
2
  class SentryReporter < Base
3
- class_accessor "Sentry"
3
+ class_accessor "Sentry", gem_spec: "sentry-ruby (~> 5)"
4
4
 
5
5
  def notify(error, context: {})
6
6
  sentry_class.with_scope do |temp_scope|
@@ -1,3 +1,3 @@
1
1
  module ActionReporter
2
- VERSION = '1.2.0'
2
+ VERSION = '1.3.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_reporter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrei Makarov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-20 00:00:00.000000000 Z
11
+ date: 2023-08-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby wrapper for multiple reporting services
14
14
  email:
@@ -55,7 +55,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
55
55
  - !ruby/object:Gem::Version
56
56
  version: '0'
57
57
  requirements: []
58
- rubygems_version: 3.3.3
58
+ rubygems_version: 3.4.10
59
59
  signing_key:
60
60
  specification_version: 4
61
61
  summary: See description