telebugs 0.8.0 → 0.9.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: ece3ebc75dc41f4d196b0c6080a970b0fd66c35b8c6ae494542a84f0989e5c4e
4
- data.tar.gz: 44c0627c1e634d1e3618843d7d2c2df9344b4e9d75cccf9b9e86c345c1e84dd2
3
+ metadata.gz: aa8891b6ca7665271200ac99930e2e44eaa4a23225996650b794ab3561e2d9c0
4
+ data.tar.gz: a1a4ff3942f1a68b544040589653ee7355e0daea98d23b114dbaea2de7150b04
5
5
  SHA512:
6
- metadata.gz: 2fe739be52b05fa197e49f2cb700dd412d30d8cba7dc1d5d5a28bd7891cd25aba11ae33d05bf5388c5aae48b757bc5064d6c462186116dd546aa14730dde4e8f
7
- data.tar.gz: 44fe0d4e8acf1adb5738b96bf1f60c7ae2fbd057326256d1ccfc55b057e0deb4e44c78f98cb4336656e549699c16f4324b03a0621f49edcc77357149d0de3923
6
+ metadata.gz: e65e6264b1bd55c51c81d43d64cb684d7ded53cb97e607a73820bf129d99f6c6c04cbb089e32af538a82490d5387c6bc32650b259b52dbe4abd79324ab9bbac0
7
+ data.tar.gz: 3cdf9ef3c6f5a3d0851124ee546fc3507648ca453684463e4d71c8c375de042b28660b645c5097dc2034ed82238a3bc3019367230a440b26f0602f8d7b0b8f8a
data/README.md CHANGED
@@ -1,8 +1,11 @@
1
1
  # Telebugs for Ruby
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/telebugs.svg)](https://badge.fury.io/rb/telebugs)
4
+
3
5
  Simple error monitoring for developers. Monitor production errors in real-time
4
6
  and get them reported to Telegram with Telebugs.
5
7
 
8
+ - [Official Documentation](https://telebugs.com/docs/integrations/ruby)
6
9
  - [FAQ](https://telebugs.com/faq)
7
10
  - [Telebugs News](https://t.me/TelebugsNews)
8
11
  - [Telebugs Community](https://t.me/TelebugsCommunity)
@@ -10,12 +13,13 @@ and get them reported to Telegram with Telebugs.
10
13
  ## Introduction
11
14
 
12
15
  Any Ruby application or script can be integrated with
13
- [Telebugs](https://telebugs.com) using the `telebugs` gem. The gem is designed
14
- to be simple and easy to use. It provides a simple API to send errors to
15
- Telebugs, which will then be reported to your Telegram project. This guide will
16
- help you get started with Telebugs for Ruby.
16
+ [Telebugs](https://telebugs.com) using the
17
+ [`telebugs`](https://rubygems.org/gems/telebugs) gem. The gem is designed to be
18
+ simple and easy to use. It provides a simple API to send errors to Telebugs,
19
+ which will then be reported to your Telegram project. This guide will help you
20
+ get started with Telebugs for Ruby.
17
21
 
18
- For full details, please refer to the [Telebugs documentation](https://telebugs.com/new/docs/integrations/ruby).
22
+ For full details, please refer to the [Telebugs documentation](https://telebugs.com/docs/integrations/ruby).
19
23
 
20
24
  ## Installation
21
25
 
@@ -8,7 +8,9 @@ module Telebugs
8
8
  :middleware
9
9
 
10
10
  attr_reader :api_url,
11
- :root_directory
11
+ :root_directory,
12
+ :ignore_environments,
13
+ :environment
12
14
 
13
15
  class << self
14
16
  attr_writer :instance
@@ -22,6 +24,18 @@ module Telebugs
22
24
  reset
23
25
  end
24
26
 
27
+ def reset
28
+ self.api_key = nil
29
+ self.api_url = ERROR_API_URL
30
+
31
+ @middleware = MiddlewareStack.new
32
+ @middleware.use Middleware::GemRootFilter.new
33
+
34
+ self.root_directory = (defined?(Bundler) && Bundler.root) || Dir.pwd
35
+ self.environment = ""
36
+ self.ignore_environments = []
37
+ end
38
+
25
39
  def api_url=(url)
26
40
  @api_url = URI(url)
27
41
  end
@@ -29,23 +43,22 @@ module Telebugs
29
43
  def root_directory=(directory)
30
44
  @root_directory = File.realpath(directory)
31
45
 
32
- if @middleware
33
- @middleware.delete(Middleware::RootDirectoryFilter)
34
- @middleware.use Middleware::RootDirectoryFilter.new(@root_directory)
35
- end
46
+ @middleware.delete(Middleware::RootDirectoryFilter)
47
+ @middleware.use Middleware::RootDirectoryFilter.new(@root_directory)
36
48
  end
37
49
 
38
- def reset
39
- self.api_key = nil
40
- self.api_url = ERROR_API_URL
41
- self.root_directory = File.realpath(
42
- (defined?(Bundler) && Bundler.root) ||
43
- Dir.pwd
44
- )
50
+ def environment=(environment)
51
+ @environment = environment
45
52
 
46
- @middleware = MiddlewareStack.new
47
- @middleware.use Middleware::GemRootFilter.new
48
- @middleware.use Middleware::RootDirectoryFilter.new(root_directory)
53
+ @middleware.delete(Middleware::IgnoreEnvironments)
54
+ @middleware.use Middleware::IgnoreEnvironments.new(@environment, @ignore_environments)
55
+ end
56
+
57
+ def ignore_environments=(ignore_environments)
58
+ @ignore_environments = ignore_environments
59
+
60
+ @middleware.delete(Middleware::IgnoreEnvironments)
61
+ @middleware.use Middleware::IgnoreEnvironments.new(@environment, @ignore_environments)
49
62
  end
50
63
  end
51
64
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telebugs
4
+ class Middleware
5
+ class IgnoreEnvironments < Telebugs::Middleware
6
+ def initialize(current_env, ignore_envs)
7
+ @current_env = current_env
8
+ @ignore_envs = ignore_envs
9
+ end
10
+
11
+ def call(report)
12
+ report.ignored = @ignore_envs.include?(@current_env)
13
+ end
14
+
15
+ def weight
16
+ -1000
17
+ end
18
+ end
19
+ end
20
+ end
@@ -18,7 +18,7 @@ module Telebugs
18
18
  end
19
19
 
20
20
  def use(new_middleware)
21
- @middlewares = (@middlewares << new_middleware).sort_by(&:weight).reverse
21
+ @middlewares = (@middlewares << new_middleware).sort_by(&:weight)
22
22
  end
23
23
 
24
24
  def delete(middleware_class)
@@ -13,14 +13,14 @@ module Telebugs
13
13
 
14
14
  def initialize
15
15
  @sender = Sender.new
16
- @middleware = Config.instance.middleware
16
+ @config = Config.instance
17
17
  end
18
18
 
19
19
  def report(error)
20
20
  Telebugs::Promise.new(error) do
21
21
  report = Report.new(error)
22
22
 
23
- @middleware.call(report)
23
+ @config.middleware.call(report)
24
24
  next if report.ignored
25
25
 
26
26
  @sender.send(report)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Telebugs
4
- VERSION = "0.8.0"
4
+ VERSION = "0.9.0"
5
5
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Telebugs
2
4
  # WrappedError unwraps an error and its causes up to a certain depth.
3
5
  class WrappedError
data/lib/telebugs.rb CHANGED
@@ -21,6 +21,7 @@ require_relative "telebugs/truncator"
21
21
 
22
22
  require_relative "telebugs/middleware/gem_root_filter"
23
23
  require_relative "telebugs/middleware/root_directory_filter"
24
+ require_relative "telebugs/middleware/ignore_environments"
24
25
 
25
26
  module Telebugs
26
27
  # The general error that this library uses when it wants to raise.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: telebugs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kyrylo Silin
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-21 00:00:00.000000000 Z
11
+ date: 2024-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -39,8 +39,8 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.23'
41
41
  description: |
42
- Telebugs Ruby is an SDK for Telebugs (https://telebugs.com/), a simple error monitoring tool for developers. With
43
- Telebugs, you can track production errors in real-time and report them to Telegram.
42
+ Telebugs for Ruby is an error reporting library for Telebugs (https://telebugs.com/), a simple error monitoring tool
43
+ for developers. With Telebugs, you can track production errors in real-time and report them to Telegram.
44
44
  email:
45
45
  - help@telebugs.com
46
46
  executables: []
@@ -59,6 +59,7 @@ files:
59
59
  - lib/telebugs/file_cache.rb
60
60
  - lib/telebugs/middleware.rb
61
61
  - lib/telebugs/middleware/gem_root_filter.rb
62
+ - lib/telebugs/middleware/ignore_environments.rb
62
63
  - lib/telebugs/middleware/root_directory_filter.rb
63
64
  - lib/telebugs/middleware_stack.rb
64
65
  - lib/telebugs/promise.rb
@@ -90,8 +91,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
91
  - !ruby/object:Gem::Version
91
92
  version: '0'
92
93
  requirements: []
93
- rubygems_version: 3.5.3
94
+ rubygems_version: 3.5.11
94
95
  signing_key:
95
96
  specification_version: 4
96
- summary: Report errors to Telebugs with the offical Ruby SDK
97
+ summary: Report errors to Telebugs with the offical library for Ruby.
97
98
  test_files: []