telebugs 0.8.0 → 0.10.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: 4ac26c242c70bb68865a22619ab11bf4a6ea87a8916419d7c23b61a8e177c6f4
4
+ data.tar.gz: '082d97785ef062ccea94556aeaa80a0611e89bf0c185064177f470e4ad9dd2f7'
5
5
  SHA512:
6
- metadata.gz: 2fe739be52b05fa197e49f2cb700dd412d30d8cba7dc1d5d5a28bd7891cd25aba11ae33d05bf5388c5aae48b757bc5064d6c462186116dd546aa14730dde4e8f
7
- data.tar.gz: 44fe0d4e8acf1adb5738b96bf1f60c7ae2fbd057326256d1ccfc55b057e0deb4e44c78f98cb4336656e549699c16f4324b03a0621f49edcc77357149d0de3923
6
+ metadata.gz: c1d605be920edfa515e901a9fbcdd30291722e789b88db3c9feff628ad221cff0954ab8b945dba3a3c678127678ee1e15193c2c1ca138e6c6bcc4a6beebd39a9
7
+ data.tar.gz: 3e36a26d7e450f141ad1f8926e1e6bf934cccce0eb8620df4c37c791a070fdb5491b56bb45d22da9e975bc665812b24cc208023abd9c5e5f3714be4b911693ec
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
 
@@ -3,7 +3,7 @@
3
3
  module Telebugs
4
4
  # Represents a middleware that can be used to filter out errors.
5
5
  # You must inherit from this class and implement the #call method.
6
- class Middleware
6
+ class BaseMiddleware
7
7
  DEFAULT_WEIGHT = 0
8
8
 
9
9
  def weight
@@ -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
@@ -4,7 +4,7 @@ module Telebugs
4
4
  class Middleware
5
5
  # GemRootFilter is a middleware that filters out the root path of the gems.
6
6
  # It replaces the root path with the gem name and version.
7
- class GemRootFilter < Telebugs::Middleware
7
+ class GemRootFilter < Telebugs::BaseMiddleware
8
8
  def initialize
9
9
  @gem_paths = Gem.path.map { |path| /\A#{Regexp.escape(path)}\/gems\// }
10
10
  end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Telebugs
4
+ class Middleware
5
+ class IgnoreEnvironments < Telebugs::BaseMiddleware
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
@@ -3,7 +3,7 @@
3
3
  module Telebugs
4
4
  class Middleware
5
5
  # Filters out the root directory from the backtrace paths.
6
- class RootDirectoryFilter < Telebugs::Middleware
6
+ class RootDirectoryFilter < Telebugs::BaseMiddleware
7
7
  def initialize(root_directory)
8
8
  @root_directory = root_directory
9
9
  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.10.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
@@ -15,12 +15,13 @@ require_relative "telebugs/error_message"
15
15
  require_relative "telebugs/backtrace"
16
16
  require_relative "telebugs/file_cache"
17
17
  require_relative "telebugs/code_hunk"
18
- require_relative "telebugs/middleware"
18
+ require_relative "telebugs/base_middleware"
19
19
  require_relative "telebugs/middleware_stack"
20
20
  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.10.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-31 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: []
@@ -53,12 +53,13 @@ files:
53
53
  - Rakefile
54
54
  - lib/telebugs.rb
55
55
  - lib/telebugs/backtrace.rb
56
+ - lib/telebugs/base_middleware.rb
56
57
  - lib/telebugs/code_hunk.rb
57
58
  - lib/telebugs/config.rb
58
59
  - lib/telebugs/error_message.rb
59
60
  - lib/telebugs/file_cache.rb
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: []