backtrace 0.4.0 → 0.4.1
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/.0pdd.yml +3 -0
- data/.github/workflows/actionlint.yml +25 -0
- data/.github/workflows/copyrights.yml +19 -0
- data/.github/workflows/markdown-lint.yml +19 -0
- data/.github/workflows/pdd.yml +12 -4
- data/.github/workflows/rake.yml +10 -5
- data/.github/workflows/reuse.yml +19 -0
- data/.github/workflows/typos.yml +19 -0
- data/.github/workflows/xcop.yml +7 -3
- data/.github/workflows/yamllint.yml +19 -0
- data/.gitignore +7 -2
- data/.rubocop.yml +11 -1
- data/.rultor.yml +7 -3
- data/Gemfile +11 -23
- data/Gemfile.lock +101 -0
- data/LICENSE.txt +1 -1
- data/LICENSES/MIT.txt +21 -0
- data/README.md +19 -17
- data/REUSE.toml +36 -0
- data/Rakefile +2 -20
- data/backtrace.gemspec +3 -22
- data/lib/backtrace.rb +87 -24
- data/logo.svg +1 -1
- data/screenshot.png +0 -0
- data/test/test__helper.rb +31 -0
- data/test/test_backtrace.rb +12 -26
- metadata +13 -7
- data/.travis.yml +0 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ec6af7564f6d3071102d9fe68dbd8fbd0b96c8df924bbf06ad4b4571706fba8
|
4
|
+
data.tar.gz: 584bcdee252d22e0f1b0f5bbc38693c061ff5ba2f351a827e3769667c2f123ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4de01dce920474679fcd9f57ddd91199720b8f8fd5373dac2d18415726eab229ddcd56519cd4a5fa2ebe96a914e47b29ecd8bbc58505608a0798f9c77e7f379
|
7
|
+
data.tar.gz: 25311582c3827f3e27555dd31fe1378dd46666d7cb63ebd162622c5e220cca6e31564d3463f536e4dac333e45bbfc323dfe147687210dd0f33c2a4181d3700be
|
data/.0pdd.yml
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
|
2
|
+
# SPDX-License-Identifier: MIT
|
3
|
+
---
|
4
|
+
# yamllint disable rule:line-length
|
5
|
+
name: actionlint
|
6
|
+
'on':
|
7
|
+
push:
|
8
|
+
branches:
|
9
|
+
- master
|
10
|
+
pull_request:
|
11
|
+
branches:
|
12
|
+
- master
|
13
|
+
jobs:
|
14
|
+
actionlint:
|
15
|
+
timeout-minutes: 15
|
16
|
+
runs-on: ubuntu-24.04
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v4
|
19
|
+
- name: Download actionlint
|
20
|
+
id: get_actionlint
|
21
|
+
run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
|
22
|
+
shell: bash
|
23
|
+
- name: Check workflow files
|
24
|
+
run: ${{ steps.get_actionlint.outputs.executable }} -color
|
25
|
+
shell: bash
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
|
2
|
+
# SPDX-License-Identifier: MIT
|
3
|
+
---
|
4
|
+
# yamllint disable rule:line-length
|
5
|
+
name: copyrights
|
6
|
+
'on':
|
7
|
+
push:
|
8
|
+
branches:
|
9
|
+
- master
|
10
|
+
pull_request:
|
11
|
+
branches:
|
12
|
+
- master
|
13
|
+
jobs:
|
14
|
+
copyrights:
|
15
|
+
timeout-minutes: 15
|
16
|
+
runs-on: ubuntu-24.04
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v4
|
19
|
+
- uses: yegor256/copyrights-action@0.0.12
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
|
2
|
+
# SPDX-License-Identifier: MIT
|
3
|
+
---
|
4
|
+
# yamllint disable rule:line-length
|
5
|
+
name: markdown-lint
|
6
|
+
'on':
|
7
|
+
push:
|
8
|
+
branches:
|
9
|
+
- master
|
10
|
+
pull_request:
|
11
|
+
branches:
|
12
|
+
- master
|
13
|
+
jobs:
|
14
|
+
markdown-lint:
|
15
|
+
timeout-minutes: 15
|
16
|
+
runs-on: ubuntu-24.04
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v4
|
19
|
+
- uses: DavidAnson/markdownlint-cli2-action@v20.0.0
|
data/.github/workflows/pdd.yml
CHANGED
@@ -1,11 +1,19 @@
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
|
2
|
+
# SPDX-License-Identifier: MIT
|
1
3
|
---
|
4
|
+
# yamllint disable rule:line-length
|
2
5
|
name: pdd
|
3
|
-
on:
|
6
|
+
'on':
|
4
7
|
push:
|
8
|
+
branches:
|
9
|
+
- master
|
5
10
|
pull_request:
|
11
|
+
branches:
|
12
|
+
- master
|
6
13
|
jobs:
|
7
14
|
pdd:
|
8
|
-
|
15
|
+
timeout-minutes: 15
|
16
|
+
runs-on: ubuntu-24.04
|
9
17
|
steps:
|
10
|
-
- uses: actions/checkout@
|
11
|
-
- uses:
|
18
|
+
- uses: actions/checkout@v4
|
19
|
+
- uses: volodya-lombrozo/pdd-action@master
|
data/.github/workflows/rake.yml
CHANGED
@@ -1,6 +1,9 @@
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
|
2
|
+
# SPDX-License-Identifier: MIT
|
1
3
|
---
|
4
|
+
# yamllint disable rule:line-length
|
2
5
|
name: rake
|
3
|
-
on:
|
6
|
+
'on':
|
4
7
|
push:
|
5
8
|
branches:
|
6
9
|
- master
|
@@ -11,13 +14,15 @@ jobs:
|
|
11
14
|
test:
|
12
15
|
strategy:
|
13
16
|
matrix:
|
14
|
-
os: [ubuntu-
|
15
|
-
ruby: [
|
17
|
+
os: [ubuntu-24.04]
|
18
|
+
ruby: [3.3]
|
16
19
|
runs-on: ${{ matrix.os }}
|
17
20
|
steps:
|
18
|
-
- uses: actions/checkout@
|
21
|
+
- uses: actions/checkout@v4
|
19
22
|
- uses: ruby/setup-ruby@v1
|
20
23
|
with:
|
21
24
|
ruby-version: ${{ matrix.ruby }}
|
22
|
-
|
25
|
+
bundler-cache: true
|
26
|
+
- run: bundle config set --global path "$(pwd)/vendor/bundle"
|
27
|
+
- run: bundle install --no-color
|
23
28
|
- run: bundle exec rake
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
|
2
|
+
# SPDX-License-Identifier: MIT
|
3
|
+
---
|
4
|
+
# yamllint disable rule:line-length
|
5
|
+
name: reuse
|
6
|
+
'on':
|
7
|
+
push:
|
8
|
+
branches:
|
9
|
+
- master
|
10
|
+
pull_request:
|
11
|
+
branches:
|
12
|
+
- master
|
13
|
+
jobs:
|
14
|
+
reuse:
|
15
|
+
timeout-minutes: 15
|
16
|
+
runs-on: ubuntu-24.04
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v4
|
19
|
+
- uses: fsfe/reuse-action@v5
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
|
2
|
+
# SPDX-License-Identifier: MIT
|
3
|
+
---
|
4
|
+
# yamllint disable rule:line-length
|
5
|
+
name: typos
|
6
|
+
'on':
|
7
|
+
push:
|
8
|
+
branches:
|
9
|
+
- master
|
10
|
+
pull_request:
|
11
|
+
branches:
|
12
|
+
- master
|
13
|
+
jobs:
|
14
|
+
typos:
|
15
|
+
timeout-minutes: 15
|
16
|
+
runs-on: ubuntu-24.04
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v4
|
19
|
+
- uses: crate-ci/typos@v1.33.1
|
data/.github/workflows/xcop.yml
CHANGED
@@ -1,11 +1,15 @@
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
|
2
|
+
# SPDX-License-Identifier: MIT
|
1
3
|
---
|
4
|
+
# yamllint disable rule:line-length
|
2
5
|
name: xcop
|
3
|
-
on:
|
6
|
+
'on':
|
4
7
|
push:
|
5
8
|
pull_request:
|
6
9
|
jobs:
|
7
10
|
xcop:
|
8
|
-
|
11
|
+
timeout-minutes: 15
|
12
|
+
runs-on: ubuntu-24.04
|
9
13
|
steps:
|
10
|
-
- uses: actions/checkout@
|
14
|
+
- uses: actions/checkout@v4
|
11
15
|
- uses: g4s8/xcop-action@master
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
|
2
|
+
# SPDX-License-Identifier: MIT
|
3
|
+
---
|
4
|
+
# yamllint disable rule:line-length
|
5
|
+
name: yamllint
|
6
|
+
'on':
|
7
|
+
push:
|
8
|
+
branches:
|
9
|
+
- master
|
10
|
+
pull_request:
|
11
|
+
branches:
|
12
|
+
- master
|
13
|
+
jobs:
|
14
|
+
yamllint:
|
15
|
+
timeout-minutes: 15
|
16
|
+
runs-on: ubuntu-24.04
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v4
|
19
|
+
- uses: ibiqlik/action-yamllint@v3
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
@@ -1,8 +1,18 @@
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
|
2
|
+
# SPDX-License-Identifier: MIT
|
3
|
+
---
|
1
4
|
AllCops:
|
2
5
|
DisplayCopNames: true
|
3
6
|
TargetRubyVersion: 2.3.3
|
4
7
|
SuggestExtensions: false
|
5
8
|
NewCops: enable
|
6
|
-
|
7
9
|
Layout/MultilineMethodCallIndentation:
|
8
10
|
Enabled: false
|
11
|
+
Minitest/EmptyLineBeforeAssertionMethods:
|
12
|
+
Enabled: false
|
13
|
+
Metrics/MethodLength:
|
14
|
+
Max: 40
|
15
|
+
plugins:
|
16
|
+
- rubocop-rake
|
17
|
+
- rubocop-minitest
|
18
|
+
- rubocop-performance
|
data/.rultor.yml
CHANGED
@@ -1,12 +1,16 @@
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
|
2
|
+
# SPDX-License-Identifier: MIT
|
3
|
+
---
|
4
|
+
# yamllint disable rule:line-length
|
1
5
|
docker:
|
2
|
-
image: yegor256/
|
6
|
+
image: yegor256/ruby
|
3
7
|
assets:
|
4
8
|
rubygems.yml: yegor256/home#assets/rubygems.yml
|
5
9
|
install: |-
|
6
|
-
sudo gem install openssl -- --with-openssl-dir=/usr/local/rvm/rubies/ruby-3.0.1/lib/ruby/3.0.0/openssl
|
7
10
|
pdd -f /dev/null
|
8
|
-
|
11
|
+
bundle install --no-color
|
9
12
|
release:
|
13
|
+
pre: false
|
10
14
|
script: |-
|
11
15
|
bundle exec rake
|
12
16
|
rm -rf *.gem
|
data/Gemfile
CHANGED
@@ -1,30 +1,18 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
13
|
-
# copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
# SOFTWARE.
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
|
4
|
+
# SPDX-License-Identifier: MIT
|
22
5
|
|
23
6
|
source 'https://rubygems.org'
|
24
7
|
gemspec
|
25
8
|
|
26
9
|
gem 'minitest', '~>5.11', require: false
|
27
|
-
gem '
|
28
|
-
gem '
|
29
|
-
gem '
|
30
|
-
gem 'rubocop
|
10
|
+
gem 'minitest-reporters', '~>1.7', require: false
|
11
|
+
gem 'rake', '~>13.2', require: false
|
12
|
+
gem 'rdoc', '~>6.11', require: false
|
13
|
+
gem 'rubocop', '~>1.71', require: false
|
14
|
+
gem 'rubocop-minitest', '~>0.38', require: false
|
15
|
+
gem 'rubocop-performance', '~>1.0', require: false
|
16
|
+
gem 'rubocop-rake', '~>0.7', require: false
|
17
|
+
gem 'simplecov', '~>0.22', require: false
|
18
|
+
gem 'simplecov-cobertura', '~>2.1', require: false
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
backtrace (0.0.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ansi (1.5.0)
|
10
|
+
ast (2.4.3)
|
11
|
+
builder (3.3.0)
|
12
|
+
date (3.4.1)
|
13
|
+
docile (1.4.1)
|
14
|
+
erb (5.0.1)
|
15
|
+
json (2.12.2)
|
16
|
+
language_server-protocol (3.17.0.5)
|
17
|
+
lint_roller (1.1.0)
|
18
|
+
minitest (5.25.5)
|
19
|
+
minitest-reporters (1.7.1)
|
20
|
+
ansi
|
21
|
+
builder
|
22
|
+
minitest (>= 5.0)
|
23
|
+
ruby-progressbar
|
24
|
+
parallel (1.27.0)
|
25
|
+
parser (3.3.8.0)
|
26
|
+
ast (~> 2.4.1)
|
27
|
+
racc
|
28
|
+
prism (1.4.0)
|
29
|
+
psych (5.2.6)
|
30
|
+
date
|
31
|
+
stringio
|
32
|
+
racc (1.8.1)
|
33
|
+
rainbow (3.1.1)
|
34
|
+
rake (13.3.0)
|
35
|
+
rdoc (6.14.0)
|
36
|
+
erb
|
37
|
+
psych (>= 4.0.0)
|
38
|
+
regexp_parser (2.10.0)
|
39
|
+
rexml (3.4.1)
|
40
|
+
rubocop (1.76.0)
|
41
|
+
json (~> 2.3)
|
42
|
+
language_server-protocol (~> 3.17.0.2)
|
43
|
+
lint_roller (~> 1.1.0)
|
44
|
+
parallel (~> 1.10)
|
45
|
+
parser (>= 3.3.0.2)
|
46
|
+
rainbow (>= 2.2.2, < 4.0)
|
47
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
48
|
+
rubocop-ast (>= 1.45.0, < 2.0)
|
49
|
+
ruby-progressbar (~> 1.7)
|
50
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
51
|
+
rubocop-ast (1.45.0)
|
52
|
+
parser (>= 3.3.7.2)
|
53
|
+
prism (~> 1.4)
|
54
|
+
rubocop-minitest (0.38.1)
|
55
|
+
lint_roller (~> 1.1)
|
56
|
+
rubocop (>= 1.75.0, < 2.0)
|
57
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
58
|
+
rubocop-performance (1.25.0)
|
59
|
+
lint_roller (~> 1.1)
|
60
|
+
rubocop (>= 1.75.0, < 2.0)
|
61
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
62
|
+
rubocop-rake (0.7.1)
|
63
|
+
lint_roller (~> 1.1)
|
64
|
+
rubocop (>= 1.72.1)
|
65
|
+
ruby-progressbar (1.13.0)
|
66
|
+
simplecov (0.22.0)
|
67
|
+
docile (~> 1.1)
|
68
|
+
simplecov-html (~> 0.11)
|
69
|
+
simplecov_json_formatter (~> 0.1)
|
70
|
+
simplecov-cobertura (2.1.0)
|
71
|
+
rexml
|
72
|
+
simplecov (~> 0.19)
|
73
|
+
simplecov-html (0.13.1)
|
74
|
+
simplecov_json_formatter (0.1.4)
|
75
|
+
stringio (3.1.7)
|
76
|
+
unicode-display_width (3.1.4)
|
77
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
78
|
+
unicode-emoji (4.0.4)
|
79
|
+
|
80
|
+
PLATFORMS
|
81
|
+
arm64-darwin-22
|
82
|
+
arm64-darwin-23
|
83
|
+
arm64-darwin-24
|
84
|
+
x64-mingw-ucrt
|
85
|
+
x86_64-linux
|
86
|
+
|
87
|
+
DEPENDENCIES
|
88
|
+
backtrace!
|
89
|
+
minitest (~> 5.11)
|
90
|
+
minitest-reporters (~> 1.7)
|
91
|
+
rake (~> 13.2)
|
92
|
+
rdoc (~> 6.11)
|
93
|
+
rubocop (~> 1.71)
|
94
|
+
rubocop-minitest (~> 0.38)
|
95
|
+
rubocop-performance (~> 1.0)
|
96
|
+
rubocop-rake (~> 0.7)
|
97
|
+
simplecov (~> 0.22)
|
98
|
+
simplecov-cobertura (~> 2.1)
|
99
|
+
|
100
|
+
BUNDLED WITH
|
101
|
+
2.5.16
|
data/LICENSE.txt
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
The MIT License (MIT)
|
2
2
|
|
3
|
-
Copyright (c) 2018-
|
3
|
+
Copyright (c) 2018-2025 Yegor Bugayenko
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/LICENSES/MIT.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018-2025 Yegor Bugayenko
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included
|
13
|
+
in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
|
1
|
+
# Converts Ruby Backtrace to a String
|
2
2
|
|
3
|
-
[](https://www.rultor.com/p/yegor256/backtrace)
|
4
4
|
[](https://www.jetbrains.com/ruby/)
|
5
5
|
|
6
6
|
[](https://github.com/yegor256/backtrace/actions/workflows/rake.yml)
|
7
|
-
[](
|
7
|
+
[](https://badge.fury.io/rb/backtrace)
|
8
8
|
[](https://codeclimate.com/github/yegor256/backtrace/maintainability)
|
9
|
-
[](https://rubydoc.info/github/yegor256/backtrace/master/frames)
|
10
10
|
[](https://hitsofcode.com/view/github/yegor256/backtrace)
|
11
11
|
[](https://github.com/yegor256/backtrace/blob/master/LICENSE.txt)
|
12
12
|
|
@@ -15,10 +15,10 @@ A Ruby backtrace nicely printed.
|
|
15
15
|
First, install it:
|
16
16
|
|
17
17
|
```bash
|
18
|
-
|
18
|
+
gem install backtrace
|
19
19
|
```
|
20
20
|
|
21
|
-
Then, use it like this
|
21
|
+
Then, use it like this to print a backtrace:
|
22
22
|
|
23
23
|
```ruby
|
24
24
|
require 'backtrace'
|
@@ -40,19 +40,19 @@ Backtrace.exec(swallow: true) do
|
|
40
40
|
end
|
41
41
|
```
|
42
42
|
|
43
|
-
You can also provide a logging facility
|
43
|
+
You can also provide a logging facility to log the backtrace:
|
44
44
|
|
45
45
|
```ruby
|
46
46
|
require 'backtrace'
|
47
|
-
log = Log.new # it must implement method error(msg)
|
47
|
+
log = Log.new # it must implement the method error(msg)
|
48
48
|
Backtrace.exec(swallow: true, log: log) do
|
49
49
|
# do something dangerous
|
50
50
|
end
|
51
51
|
```
|
52
52
|
|
53
|
-
Sometimes you may need to hide unimportant lines of the backtrace
|
54
|
-
|
55
|
-
of the constructor, which is a regular expression or a string. When it's
|
53
|
+
Sometimes you may need to hide unimportant lines of the backtrace
|
54
|
+
that are not related to your codebase. You can use the `mine` argument
|
55
|
+
of the constructor, which is a regular expression or a string. When it's encountered
|
56
56
|
in the backtrace, the printing will stop:
|
57
57
|
|
58
58
|
```ruby
|
@@ -68,14 +68,16 @@ That's it.
|
|
68
68
|
|
69
69
|
## How to contribute
|
70
70
|
|
71
|
-
Read
|
72
|
-
|
73
|
-
|
71
|
+
Read
|
72
|
+
[these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
|
73
|
+
Make sure your build is green before you contribute
|
74
|
+
your pull request.
|
75
|
+
You will need to have [Ruby](https://www.ruby-lang.org/en/) 2.3+ and
|
74
76
|
[Bundler](https://bundler.io/) installed. Then:
|
75
77
|
|
76
|
-
```
|
77
|
-
|
78
|
-
|
78
|
+
```bash
|
79
|
+
bundle update
|
80
|
+
bundle exec rake
|
79
81
|
```
|
80
82
|
|
81
83
|
If it's clean and you don't see any error messages, submit your pull request.
|
data/REUSE.toml
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
|
2
|
+
# SPDX-License-Identifier: MIT
|
3
|
+
|
4
|
+
version = 1
|
5
|
+
[[annotations]]
|
6
|
+
path = [
|
7
|
+
".DS_Store",
|
8
|
+
".gitattributes",
|
9
|
+
".gitignore",
|
10
|
+
".pdd",
|
11
|
+
"**.json",
|
12
|
+
"**.md",
|
13
|
+
"**.png",
|
14
|
+
"**.svg",
|
15
|
+
"**.txt",
|
16
|
+
"**/.DS_Store",
|
17
|
+
"**/.gitignore",
|
18
|
+
"**/.pdd",
|
19
|
+
"**/*.csv",
|
20
|
+
"**/*.jpg",
|
21
|
+
"**/*.json",
|
22
|
+
"**/*.md",
|
23
|
+
"**/*.pdf",
|
24
|
+
"**/*.png",
|
25
|
+
"**/*.svg",
|
26
|
+
"**/*.txt",
|
27
|
+
"**/*.vm",
|
28
|
+
"**/CNAME",
|
29
|
+
"**/Gemfile.lock",
|
30
|
+
"Gemfile.lock",
|
31
|
+
"README.md",
|
32
|
+
"renovate.json",
|
33
|
+
]
|
34
|
+
precedence = "override"
|
35
|
+
SPDX-FileCopyrightText = "Copyright (c) 2025 Yegor Bugayenko"
|
36
|
+
SPDX-License-Identifier = "MIT"
|
data/Rakefile
CHANGED
@@ -1,24 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2018-
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in all
|
13
|
-
# copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
-
# SOFTWARE.
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
|
4
|
+
# SPDX-License-Identifier: MIT
|
22
5
|
|
23
6
|
require 'rubygems'
|
24
7
|
require 'rake'
|
@@ -48,5 +31,4 @@ require 'rubocop/rake_task'
|
|
48
31
|
desc 'Run RuboCop on all directories'
|
49
32
|
RuboCop::RakeTask.new(:rubocop) do |task|
|
50
33
|
task.fail_on_error = true
|
51
|
-
task.requires << 'rubocop-rspec'
|
52
34
|
end
|
data/backtrace.gemspec
CHANGED
@@ -1,33 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# (
|
4
|
-
#
|
5
|
-
# Copyright (c) 2018-2023 Yegor Bugayenko
|
6
|
-
#
|
7
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
9
|
-
# in the Software without restriction, including without limitation the rights
|
10
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
-
# copies of the Software, and to permit persons to whom the Software is
|
12
|
-
# furnished to do so, subject to the following conditions:
|
13
|
-
#
|
14
|
-
# The above copyright notice and this permission notice shall be included in all
|
15
|
-
# copies or substantial portions of the Software.
|
16
|
-
#
|
17
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23
|
-
# SOFTWARE.
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
|
4
|
+
# SPDX-License-Identifier: MIT
|
24
5
|
|
25
6
|
require 'English'
|
26
7
|
Gem::Specification.new do |s|
|
27
8
|
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
28
9
|
s.required_ruby_version = '>=2.3'
|
29
10
|
s.name = 'backtrace'
|
30
|
-
s.version = '0.4.
|
11
|
+
s.version = '0.4.1'
|
31
12
|
s.license = 'MIT'
|
32
13
|
s.summary = 'Backtrace printer'
|
33
14
|
s.description = 'Nicely prints Ruby backtrace to the console'
|
data/lib/backtrace.rb
CHANGED
@@ -1,49 +1,112 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# (
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
|
4
|
+
# SPDX-License-Identifier: MIT
|
5
|
+
|
6
|
+
# Backtrace as a string.
|
4
7
|
#
|
5
|
-
#
|
8
|
+
# This class helps format Ruby exceptions with their backtraces
|
9
|
+
# in a clean, readable format. It can also filter backtrace lines
|
10
|
+
# to show only relevant information.
|
6
11
|
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
12
|
+
# @example Basic usage
|
13
|
+
# begin
|
14
|
+
# raise "Something went wrong"
|
15
|
+
# rescue => e
|
16
|
+
# puts Backtrace.new(e)
|
17
|
+
# end
|
13
18
|
#
|
14
|
-
#
|
15
|
-
#
|
19
|
+
# @example Using with a filter
|
20
|
+
# begin
|
21
|
+
# raise "Error in my code"
|
22
|
+
# rescue => e
|
23
|
+
# puts Backtrace.new(e, mine: 'myapp')
|
24
|
+
# end
|
16
25
|
#
|
17
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23
|
-
# SOFTWARE.
|
24
|
-
|
25
|
-
# Backtrace as a string.
|
26
26
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
27
|
-
# Copyright:: Copyright (c) 2018-
|
27
|
+
# Copyright:: Copyright (c) 2018-2025 Yegor Bugayenko
|
28
28
|
# License:: MIT
|
29
29
|
class Backtrace
|
30
|
+
# Creates a new Backtrace instance.
|
31
|
+
#
|
32
|
+
# @param exp [Exception] The exception to format
|
33
|
+
# @param mine [String, Regexp] Pattern to match against backtrace lines.
|
34
|
+
# When matched, backtrace will stop printing at that line.
|
35
|
+
#
|
36
|
+
# @example With a string pattern
|
37
|
+
# Backtrace.new(exception, mine: 'myapp')
|
38
|
+
#
|
39
|
+
# @example With a regular expression
|
40
|
+
# Backtrace.new(exception, mine: /lib\/myapp/)
|
30
41
|
def initialize(exp, mine: '')
|
31
42
|
@exp = exp
|
32
43
|
@mine = (mine.is_a?(Regexp) ? mine : Regexp.new(Regexp.quote(mine)))
|
33
44
|
end
|
34
45
|
|
46
|
+
# Converts the backtrace to a formatted string.
|
47
|
+
#
|
48
|
+
# The output includes the exception class name, message, and a filtered
|
49
|
+
# backtrace. Lines are indented with tabs for readability.
|
50
|
+
#
|
51
|
+
# @return [String] Formatted backtrace string
|
52
|
+
#
|
53
|
+
# @example
|
54
|
+
# begin
|
55
|
+
# 1 / 0
|
56
|
+
# rescue => e
|
57
|
+
# bt = Backtrace.new(e)
|
58
|
+
# puts bt.to_s
|
59
|
+
# # => "ZeroDivisionError: divided by 0
|
60
|
+
# # \t/path/to/file.rb:10:in `/'
|
61
|
+
# # \t/path/to/file.rb:20:in `calculate'"
|
62
|
+
# end
|
35
63
|
def to_s
|
64
|
+
bt = @exp.backtrace
|
65
|
+
&.reverse
|
66
|
+
&.drop_while { |t| @mine.match(t).nil? }
|
67
|
+
&.reverse
|
68
|
+
&.join("\n\t")
|
36
69
|
[
|
37
70
|
@exp.class.name,
|
38
71
|
': ',
|
39
72
|
@exp.message,
|
40
|
-
"\n\t"
|
41
|
-
@exp.backtrace.reverse
|
42
|
-
.drop_while { |t| @mine.match(t).nil? }
|
43
|
-
.reverse.join("\n\t")
|
73
|
+
("\n\t#{bt}" if bt)
|
44
74
|
].join
|
45
75
|
end
|
46
76
|
|
77
|
+
# Executes a block and handles exceptions with formatted backtrace.
|
78
|
+
#
|
79
|
+
# This method provides a convenient way to wrap code that might raise
|
80
|
+
# exceptions. It will format and display (or log) any exceptions that occur.
|
81
|
+
#
|
82
|
+
# @param swallow [Boolean] Whether to swallow the exception (default: false)
|
83
|
+
# @param log [Object] Logger object that responds to #error (optional)
|
84
|
+
# @param mine [String, Regexp] Pattern to filter backtrace lines
|
85
|
+
#
|
86
|
+
# @yield The block of code to execute
|
87
|
+
#
|
88
|
+
# @raise [StandardError] Re-raises the exception unless swallow is true
|
89
|
+
#
|
90
|
+
# @example Basic usage
|
91
|
+
# Backtrace.exec do
|
92
|
+
# risky_operation
|
93
|
+
# end
|
94
|
+
#
|
95
|
+
# @example Swallow exceptions
|
96
|
+
# Backtrace.exec(swallow: true) do
|
97
|
+
# optional_operation
|
98
|
+
# end
|
99
|
+
#
|
100
|
+
# @example With logging
|
101
|
+
# logger = Logger.new(STDOUT)
|
102
|
+
# Backtrace.exec(log: logger) do
|
103
|
+
# database_operation
|
104
|
+
# end
|
105
|
+
#
|
106
|
+
# @example With filtering
|
107
|
+
# Backtrace.exec(mine: 'myapp', swallow: true) do
|
108
|
+
# complex_operation
|
109
|
+
# end
|
47
110
|
def self.exec(swallow: false, log: nil, mine: '')
|
48
111
|
yield
|
49
112
|
rescue StandardError => e
|
data/logo.svg
CHANGED
data/screenshot.png
CHANGED
Binary file
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
|
4
|
+
# SPDX-License-Identifier: MIT
|
5
|
+
|
6
|
+
$stdout.sync = true
|
7
|
+
|
8
|
+
require 'simplecov'
|
9
|
+
require 'simplecov-cobertura'
|
10
|
+
unless SimpleCov.running || ENV['PICKS']
|
11
|
+
SimpleCov.command_name('test')
|
12
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
|
13
|
+
[
|
14
|
+
SimpleCov::Formatter::HTMLFormatter,
|
15
|
+
SimpleCov::Formatter::CoberturaFormatter
|
16
|
+
]
|
17
|
+
)
|
18
|
+
SimpleCov.minimum_coverage 95
|
19
|
+
SimpleCov.minimum_coverage_by_file 90
|
20
|
+
SimpleCov.start do
|
21
|
+
add_filter 'test/'
|
22
|
+
add_filter 'vendor/'
|
23
|
+
add_filter 'target/'
|
24
|
+
track_files 'lib/**/*.rb'
|
25
|
+
track_files '*.rb'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
require 'minitest/autorun'
|
30
|
+
require 'minitest/reporters'
|
31
|
+
Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new]
|
data/test/test_backtrace.rb
CHANGED
@@ -1,41 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# (
|
4
|
-
#
|
5
|
-
# Copyright (c) 2018-2023 Yegor Bugayenko
|
6
|
-
#
|
7
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
-
# of this software and associated documentation files (the 'Software'), to deal
|
9
|
-
# in the Software without restriction, including without limitation the rights
|
10
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
-
# copies of the Software, and to permit persons to whom the Software is
|
12
|
-
# furnished to do so, subject to the following conditions:
|
13
|
-
#
|
14
|
-
# The above copyright notice and this permission notice shall be included in all
|
15
|
-
# copies or substantial portions of the Software.
|
16
|
-
#
|
17
|
-
# THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23
|
-
# SOFTWARE.
|
3
|
+
# SPDX-FileCopyrightText: Copyright (c) 2018-2025 Yegor Bugayenko
|
4
|
+
# SPDX-License-Identifier: MIT
|
24
5
|
|
25
|
-
require 'minitest/autorun'
|
26
6
|
require_relative '../lib/backtrace'
|
7
|
+
require_relative 'test__helper'
|
27
8
|
|
28
9
|
# Backtract test.
|
29
10
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
30
|
-
# Copyright:: Copyright (c) 2018-
|
11
|
+
# Copyright:: Copyright (c) 2018-2025 Yegor Bugayenko
|
31
12
|
# License:: MIT
|
32
13
|
class BacktraceTest < Minitest::Test
|
33
14
|
def test_prints_exception
|
34
15
|
raise 'Just a test'
|
35
16
|
rescue StandardError => e
|
36
17
|
text = Backtrace.new(e).to_s
|
37
|
-
|
38
|
-
|
18
|
+
assert_includes(text, "RuntimeError: Just a test\n", text)
|
19
|
+
assert_includes(text, 'test/test_backtrace.rb', text)
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_prints_synthetic_exception
|
23
|
+
text = Backtrace.new(StandardError.new('boom!')).to_s
|
24
|
+
assert_includes(text, 'StandardError: boom!', text)
|
39
25
|
end
|
40
26
|
|
41
27
|
def test_runs_a_block
|
@@ -43,7 +29,7 @@ class BacktraceTest < Minitest::Test
|
|
43
29
|
Backtrace.exec(swallow: true, log: log) do
|
44
30
|
raise 'It is intended'
|
45
31
|
end
|
46
|
-
|
32
|
+
assert_includes(log.sent, 'intended')
|
47
33
|
end
|
48
34
|
|
49
35
|
def test_runs_a_block_to_console
|
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: backtrace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies: []
|
13
12
|
description: Nicely prints Ruby backtrace to the console
|
14
13
|
email: yegor256@gmail.com
|
@@ -18,30 +17,38 @@ extra_rdoc_files:
|
|
18
17
|
- README.md
|
19
18
|
files:
|
20
19
|
- ".0pdd.yml"
|
20
|
+
- ".github/workflows/actionlint.yml"
|
21
|
+
- ".github/workflows/copyrights.yml"
|
22
|
+
- ".github/workflows/markdown-lint.yml"
|
21
23
|
- ".github/workflows/pdd.yml"
|
22
24
|
- ".github/workflows/rake.yml"
|
25
|
+
- ".github/workflows/reuse.yml"
|
26
|
+
- ".github/workflows/typos.yml"
|
23
27
|
- ".github/workflows/xcop.yml"
|
28
|
+
- ".github/workflows/yamllint.yml"
|
24
29
|
- ".gitignore"
|
25
30
|
- ".pdd"
|
26
31
|
- ".rubocop.yml"
|
27
32
|
- ".rultor.yml"
|
28
|
-
- ".travis.yml"
|
29
33
|
- Gemfile
|
34
|
+
- Gemfile.lock
|
30
35
|
- LICENSE.txt
|
36
|
+
- LICENSES/MIT.txt
|
31
37
|
- README.md
|
38
|
+
- REUSE.toml
|
32
39
|
- Rakefile
|
33
40
|
- backtrace.gemspec
|
34
41
|
- lib/backtrace.rb
|
35
42
|
- logo.svg
|
36
43
|
- renovate.json
|
37
44
|
- screenshot.png
|
45
|
+
- test/test__helper.rb
|
38
46
|
- test/test_backtrace.rb
|
39
47
|
homepage: https://github.com/yegor256/backtrace
|
40
48
|
licenses:
|
41
49
|
- MIT
|
42
50
|
metadata:
|
43
51
|
rubygems_mfa_required: 'true'
|
44
|
-
post_install_message:
|
45
52
|
rdoc_options:
|
46
53
|
- "--charset=UTF-8"
|
47
54
|
require_paths:
|
@@ -57,8 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
64
|
- !ruby/object:Gem::Version
|
58
65
|
version: '0'
|
59
66
|
requirements: []
|
60
|
-
rubygems_version: 3.
|
61
|
-
signing_key:
|
67
|
+
rubygems_version: 3.6.7
|
62
68
|
specification_version: 4
|
63
69
|
summary: Backtrace printer
|
64
70
|
test_files: []
|