give_back_my_traces 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/main.yml +24 -2
- data/Gemfile +2 -0
- data/Gemfile.lock +8 -1
- data/README.md +13 -2
- data/lib/give_back_my_traces/tracker.rb +31 -0
- data/lib/give_back_my_traces/version.rb +1 -1
- data/lib/give_back_my_traces.rb +13 -5
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a33c10a1184b7bda92c8132962fb79bc59a6f1f04680d80d7603d54b9d10014
|
4
|
+
data.tar.gz: 1968735c7bc44474504fe808e1fae4f5ba274daac0c112395bc8353022708dc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df1b8338dfbccad012766c72ab18b4df0a64b42d8961214bec128b01a2b601d124fe75cb703f51be3c2963ef9fb8d6179f636774983539ecc8b11a815328de66
|
7
|
+
data.tar.gz: 9182cae21e229251718691ffadca6b0550aef7693160d240625db2dcac28570fac5857f43305433d7065b5b975eb447ea870d707dfdd29f06c771137433846fd
|
data/.github/workflows/main.yml
CHANGED
@@ -1,17 +1,39 @@
|
|
1
1
|
name: Ruby
|
2
2
|
|
3
|
-
on:
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ master ]
|
6
|
+
workflow_dispatch:
|
7
|
+
pull_request:
|
4
8
|
|
5
9
|
jobs:
|
6
10
|
build:
|
7
11
|
runs-on: ubuntu-latest
|
12
|
+
strategy:
|
13
|
+
matrix:
|
14
|
+
ruby-version: ['2.7', '3.0', '3.1']
|
15
|
+
|
8
16
|
steps:
|
9
17
|
- uses: actions/checkout@v2
|
10
18
|
- name: Set up Ruby
|
11
19
|
uses: ruby/setup-ruby@v1
|
12
20
|
with:
|
13
|
-
ruby-version:
|
21
|
+
ruby-version: ${{ matrix.ruby-version }}
|
14
22
|
bundler-cache: true
|
15
23
|
cache-version: 1
|
24
|
+
|
25
|
+
- name: Setup Code Climate test-reporter
|
26
|
+
if: ${{ matrix.ruby-version }} == '2.7'
|
27
|
+
run: |
|
28
|
+
curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
29
|
+
chmod +x ./cc-test-reporter
|
30
|
+
./cc-test-reporter before-build
|
31
|
+
|
16
32
|
- name: Run the default task
|
17
33
|
run: bundle exec rake
|
34
|
+
|
35
|
+
- name: Publish code coverage
|
36
|
+
if: ${{ matrix.ruby-version }} == '2.7'
|
37
|
+
run: |
|
38
|
+
export GIT_BRANCH="${GITHUB_REF/refs\/heads\//}"
|
39
|
+
./cc-test-reporter after-build -r ${{secrets.CC_TEST_REPORTER_ID}}
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
give_back_my_traces (0.1.
|
4
|
+
give_back_my_traces (0.1.3)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
@@ -10,6 +10,7 @@ GEM
|
|
10
10
|
byebug (11.1.3)
|
11
11
|
coderay (1.1.3)
|
12
12
|
diff-lcs (1.4.4)
|
13
|
+
docile (1.4.0)
|
13
14
|
json (2.6.2)
|
14
15
|
method_source (1.0.0)
|
15
16
|
parallel (1.22.1)
|
@@ -51,6 +52,11 @@ GEM
|
|
51
52
|
rubocop-ast (1.22.0)
|
52
53
|
parser (>= 3.1.1.0)
|
53
54
|
ruby-progressbar (1.11.0)
|
55
|
+
simplecov (0.17.1)
|
56
|
+
docile (~> 1.1)
|
57
|
+
json (>= 1.8, < 3)
|
58
|
+
simplecov-html (~> 0.10.0)
|
59
|
+
simplecov-html (0.10.2)
|
54
60
|
unicode-display_width (2.3.0)
|
55
61
|
|
56
62
|
PLATFORMS
|
@@ -62,6 +68,7 @@ DEPENDENCIES
|
|
62
68
|
rake (~> 13.0)
|
63
69
|
rspec (~> 3.0)
|
64
70
|
rubocop (~> 1.36)
|
71
|
+
simplecov (~> 0.17.0)
|
65
72
|
|
66
73
|
BUNDLED WITH
|
67
74
|
2.3.22
|
data/README.md
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
# GiveBackMyTraces
|
2
2
|
|
3
|
+

|
4
|
+
[](https://codeclimate.com/github/catks/give_back_my_traces/maintainability)
|
5
|
+
[](https://codeclimate.com/github/catks/give_back_my_traces/test_coverage)
|
6
|
+
|
3
7
|
GiveBackMyTraces let you discover those sneaky errors in ruby apps.
|
4
8
|
|
5
9
|
## Usage
|
@@ -48,18 +52,21 @@ require 'give_back_my_traces'
|
|
48
52
|
|
49
53
|
RSpec.configure do |config|
|
50
54
|
config.around(:each) do |example|
|
51
|
-
GBMT.init
|
55
|
+
GBMT.init(
|
56
|
+
from: ENV.fetch("GBMT_BACKTRACE_FROM", Rails.root.to_s) # By default only print errors with a backtrace from your app
|
57
|
+
)
|
52
58
|
|
53
59
|
example.call
|
54
60
|
|
55
61
|
GBMT.clear
|
62
|
+
GBMT.stop
|
56
63
|
end
|
57
64
|
```
|
58
65
|
|
59
66
|
And then you can see the errors running it with some GBMT envs:
|
60
67
|
|
61
68
|
```
|
62
|
-
GBMT_ENABLE=1 rspec spec/requests/my_action_spec.rb
|
69
|
+
GBMT_ENABLE=1 rspec spec/requests/my_action_spec.rb
|
63
70
|
----------------------------------------------------
|
64
71
|
Error: BaseError
|
65
72
|
Message: Test error
|
@@ -73,6 +80,10 @@ GBMT_ENABLE=1 rspec spec/requests/my_action_spec.rb 2>&1 | head -10
|
|
73
80
|
|
74
81
|
```
|
75
82
|
|
83
|
+
Also you can filter erros by their backtrace with `GBMT_BACKTRACE_FROM`, it could be any string/regexp that matches the first line in the backtrace, eg:
|
84
|
+
|
85
|
+
`GBMT_ENABLE=1 GBMT_BACKTRACE_FROM='controllers/my_action_controller' rspec spec/requests/my_action_spec.rb`
|
86
|
+
|
76
87
|
See more in the examples folder.
|
77
88
|
|
78
89
|
## Development
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module GiveBackMyTraces
|
4
|
+
# class responsible to handle errors that are occurring at Runtime
|
5
|
+
class Tracker
|
6
|
+
NO_OP = ->(_) {}
|
7
|
+
|
8
|
+
def initialize(filters: [], **options)
|
9
|
+
@filters = filters
|
10
|
+
@options = options
|
11
|
+
end
|
12
|
+
|
13
|
+
def call(error)
|
14
|
+
return unless valid?(error)
|
15
|
+
|
16
|
+
print_error(error)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
attr_accessor :filters, :options
|
22
|
+
|
23
|
+
def valid?(error)
|
24
|
+
filters.all? { |filter| filter.call(error) }
|
25
|
+
end
|
26
|
+
|
27
|
+
def print_error(error)
|
28
|
+
warn GiveBackMyTraces::Helpers.pretty_format(error, **options)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/give_back_my_traces.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative "give_back_my_traces/version"
|
4
4
|
require_relative "give_back_my_traces/errors_collection"
|
5
|
+
require_relative "give_back_my_traces/tracker"
|
5
6
|
require_relative "gbmt"
|
6
7
|
|
7
8
|
# Main module to handle GBMT api
|
@@ -22,18 +23,25 @@ require_relative "gbmt"
|
|
22
23
|
# GiveBackMyTraces.errors.pretty_print # Print errors
|
23
24
|
module GiveBackMyTraces
|
24
25
|
class Error < StandardError; end
|
25
|
-
|
26
26
|
DEFAULT_CONFIG = {
|
27
27
|
mode: ENV.fetch("GBMT_MODE", :normal).to_sym,
|
28
28
|
backtrace: {
|
29
29
|
max_lines: ENV.fetch("GBMT_BACKTRACE_MAX_LINES", 5).to_i
|
30
|
-
}
|
30
|
+
},
|
31
|
+
from: ENV["GBMT_BACKTRACE_FROM"] && Regexp.new(ENV["GBMT_BACKTRACE_FROM"])
|
31
32
|
}.freeze
|
32
33
|
|
34
|
+
FROM_BACKTRACE_FILTER = lambda do |error|
|
35
|
+
return true if GiveBackMyTraces.config[:from].nil?
|
36
|
+
return false unless error.backtrace
|
37
|
+
|
38
|
+
error.backtrace.first.match?(GiveBackMyTraces.config[:from])
|
39
|
+
end
|
40
|
+
|
33
41
|
TRACKERS = {
|
34
|
-
normal:
|
35
|
-
silent:
|
36
|
-
verbose:
|
42
|
+
normal: Tracker.new(filters: [FROM_BACKTRACE_FILTER]),
|
43
|
+
silent: Tracker::NO_OP,
|
44
|
+
verbose: Tracker.new(filters: [FROM_BACKTRACE_FILTER], verbose: true)
|
37
45
|
}.freeze
|
38
46
|
|
39
47
|
class << self
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: give_back_my_traces
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carlos Atkinson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|
@@ -35,6 +35,7 @@ files:
|
|
35
35
|
- lib/give_back_my_traces.rb
|
36
36
|
- lib/give_back_my_traces/errors_collection.rb
|
37
37
|
- lib/give_back_my_traces/helpers.rb
|
38
|
+
- lib/give_back_my_traces/tracker.rb
|
38
39
|
- lib/give_back_my_traces/version.rb
|
39
40
|
homepage: https://github.com/catks/give_back_my_traces
|
40
41
|
licenses:
|