intercepted 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2e389fb3fb65d7b7ee9b5ad6cf418e1cbe1cf16269b3233435c3d21fc2503e17
4
+ data.tar.gz: 9452cd4c9f2c78a8f1e8c7330640b0cd1fbac248c5617f8d6f646ef295b5e0a5
5
+ SHA512:
6
+ metadata.gz: a460d3297e64d92cdd9dcdb1eeae77b2d17827c09e2f22b393bf5490617d7bf18935199c8489028b34dac02e3b4f5a39419f275c0fb573eb4e461f3985507e45
7
+ data.tar.gz: cb33a093e41a3a568f129c5dfd3627cf6df9c0348451b5c80ae6e20beb0a7a7093fa7e402f0dd1ff47e02e3b54eff289199fdd907ece3dce0588b2b3bc50de28
data/.0pdd.yml ADDED
@@ -0,0 +1,5 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+ ---
4
+ errors:
5
+ - yegor256@gmail.com
data/.gitattributes ADDED
@@ -0,0 +1,7 @@
1
+ # Check out all text files in UNIX format, with LF as end of line
2
+ # Don't change this file. If you have any ideas about it, please
3
+ # submit a separate issue about it and we'll discuss.
4
+
5
+ * text=auto eol=lf
6
+ *.java ident
7
+ *.xml ident
@@ -0,0 +1,25 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 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,25 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+ ---
4
+ # yamllint disable rule:line-length
5
+ name: codecov
6
+ 'on':
7
+ push:
8
+ branches:
9
+ - master
10
+ jobs:
11
+ codecov:
12
+ timeout-minutes: 15
13
+ runs-on: ubuntu-24.04
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - uses: ruby/setup-ruby@v1
17
+ with:
18
+ ruby-version: 3.3
19
+ bundler-cache: true
20
+ - run: bundle config set --global path "$(pwd)/vendor/bundle"
21
+ - run: bundle install --no-color
22
+ - run: bundle exec rake
23
+ - uses: codecov/codecov-action@v5
24
+ with:
25
+ token: ${{ secrets.CODECOV_TOKEN }}
@@ -0,0 +1,19 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 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,42 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+ ---
4
+ # yamllint disable rule:line-length
5
+ name: license
6
+ 'on':
7
+ push:
8
+ branches:
9
+ - master
10
+ pull_request:
11
+ branches:
12
+ - master
13
+ jobs:
14
+ license:
15
+ timeout-minutes: 15
16
+ runs-on: ubuntu-24.04
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - shell: bash
20
+ run: |
21
+ header="Copyright (c) $(date +%Y) Yegor Bugayenko"
22
+ failed="false"
23
+ while IFS= read -r file; do
24
+ if ! grep -q "${header}" "${file}"; then
25
+ failed="true"
26
+ echo "⚠️ Copyright header is not found in: ${file}"
27
+ else
28
+ echo "File looks good: ${file}"
29
+ fi
30
+ done < <(find . -type f \( \
31
+ -name "Dockerfile" -o \
32
+ -name "LICENSE.txt" -o \
33
+ -name "Makefile" -o \
34
+ -name "Rakefile" -o \
35
+ -name "*.sh" -o \
36
+ -name "*.rb" -o \
37
+ -name "*.fe" -o \
38
+ -name "*.yml" \
39
+ \) -print)
40
+ if [ "${failed}" = "true" ]; then
41
+ exit 1
42
+ fi
@@ -0,0 +1,23 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 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
+ paths-ignore: ['paper/**', 'sandbox/**']
14
+ concurrency:
15
+ group: markdown-lint-${{ github.ref }}
16
+ cancel-in-progress: true
17
+ jobs:
18
+ markdown-lint:
19
+ timeout-minutes: 15
20
+ runs-on: ubuntu-24.04
21
+ steps:
22
+ - uses: actions/checkout@v4
23
+ - uses: DavidAnson/markdownlint-cli2-action@v20.0.0
@@ -0,0 +1,19 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+ ---
4
+ # yamllint disable rule:line-length
5
+ name: pdd
6
+ 'on':
7
+ push:
8
+ branches:
9
+ - master
10
+ pull_request:
11
+ branches:
12
+ - master
13
+ jobs:
14
+ pdd:
15
+ timeout-minutes: 15
16
+ runs-on: ubuntu-24.04
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+ - uses: volodya-lombrozo/pdd-action@master
@@ -0,0 +1,28 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+ ---
4
+ # yamllint disable rule:line-length
5
+ name: rake
6
+ 'on':
7
+ push:
8
+ branches:
9
+ - master
10
+ pull_request:
11
+ branches:
12
+ - master
13
+ jobs:
14
+ rake:
15
+ strategy:
16
+ matrix:
17
+ os: [ubuntu-24.04, macos-15, windows-2022]
18
+ ruby: [3.3]
19
+ runs-on: ${{ matrix.os }}
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+ - uses: ruby/setup-ruby@v1
23
+ with:
24
+ ruby-version: ${{ matrix.ruby }}
25
+ bundler-cache: true
26
+ - run: bundle config set --global path "$(pwd)/vendor/bundle"
27
+ - run: bundle install --no-color
28
+ - run: bundle exec rake
@@ -0,0 +1,19 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 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) 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
@@ -0,0 +1,15 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+ ---
4
+ # yamllint disable rule:line-length
5
+ name: xcop
6
+ 'on':
7
+ push:
8
+ pull_request:
9
+ jobs:
10
+ xcop:
11
+ timeout-minutes: 15
12
+ runs-on: ubuntu-24.04
13
+ steps:
14
+ - uses: actions/checkout@v4
15
+ - uses: g4s8/xcop-action@master
@@ -0,0 +1,19 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 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 ADDED
@@ -0,0 +1,13 @@
1
+ .bundle/
2
+ .DS_Store
3
+ .idea/
4
+ .yardoc/
5
+ *.gem
6
+ .ruby-*
7
+ coverage/
8
+ doc/
9
+ node_modules/
10
+ rdoc/
11
+ temp/
12
+ vendor/
13
+ .claude/
data/.pdd ADDED
@@ -0,0 +1,7 @@
1
+ --source=.
2
+ --verbose
3
+ --exclude target/**/*
4
+ --exclude coverage/**/*
5
+ --rule min-words:20
6
+ --rule min-estimate:15
7
+ --rule max-estimate:90
data/.rubocop.yml ADDED
@@ -0,0 +1,30 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+ ---
4
+ AllCops:
5
+ Exclude:
6
+ - 'bin/**/*'
7
+ - 'assets/**/*'
8
+ - 'vendor/**/*'
9
+ DisplayCopNames: true
10
+ TargetRubyVersion: 3.2
11
+ SuggestExtensions: false
12
+ NewCops: enable
13
+ plugins:
14
+ - rubocop-rake
15
+ - rubocop-minitest
16
+ - rubocop-performance
17
+ Layout/EndOfLine:
18
+ EnforcedStyle: lf
19
+ Style/EvalWithLocation:
20
+ Enabled: false
21
+ Metrics/AbcSize:
22
+ Max: 50
23
+ Metrics/ClassLength:
24
+ Max: 112
25
+ Metrics/CyclomaticComplexity:
26
+ Max: 22
27
+ Metrics/PerceivedComplexity:
28
+ Max: 18
29
+ Metrics/MethodLength:
30
+ Max: 38
data/.rultor.yml ADDED
@@ -0,0 +1,28 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+ ---
4
+ # yamllint disable rule:line-length
5
+ docker:
6
+ image: yegor256/ruby
7
+ assets:
8
+ rubygems.yml: yegor256/home#assets/rubygems.yml
9
+ install: |
10
+ pdd -f /dev/null
11
+ bundle install --no-color
12
+ release:
13
+ pre: false
14
+ script: |-
15
+ [[ "${tag}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || exit -1
16
+ bundle exec rake
17
+ rm -rf *.gem
18
+ sed -i "s/0\.0\.0/${tag}/g" intercepted.gemspec
19
+ git add intercepted.gemspec
20
+ sed -i "s/0\.0\.0/${tag}/g" lib/intercepted.rb
21
+ git add lib/intercepted.rb
22
+ git commit -m "version set to ${tag}"
23
+ gem build intercepted.gemspec
24
+ chmod 0600 ../rubygems.yml
25
+ gem push *.gem --config-file ../rubygems.yml
26
+ merge:
27
+ script: |-
28
+ bundle exec rake
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
5
+
6
+ source 'https://rubygems.org'
7
+ gemspec
8
+
9
+ gem 'minitest', '~>5.25', require: false
10
+ gem 'minitest-reporters', '~>1.7', require: false
11
+ gem 'rake', '~>13.2', require: false
12
+ gem 'rubocop', '~>1.64', require: false
13
+ gem 'rubocop-minitest', '~>0.38', require: false
14
+ gem 'rubocop-performance', '~>1.25', require: false
15
+ gem 'rubocop-rake', '~>0.7', require: false
16
+ gem 'simplecov', '~>0.22', require: false
17
+ gem 'simplecov-cobertura', '~>2.1', require: false
18
+ gem 'yard', '~>0.9', require: false
data/Gemfile.lock ADDED
@@ -0,0 +1,96 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ intercepted (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
+ docile (1.4.1)
13
+ json (2.12.2)
14
+ language_server-protocol (3.17.0.5)
15
+ lint_roller (1.1.0)
16
+ minitest (5.25.5)
17
+ minitest-reporters (1.7.1)
18
+ ansi
19
+ builder
20
+ minitest (>= 5.0)
21
+ ruby-progressbar
22
+ parallel (1.27.0)
23
+ parser (3.3.8.0)
24
+ ast (~> 2.4.1)
25
+ racc
26
+ prism (1.4.0)
27
+ racc (1.8.1)
28
+ rainbow (3.1.1)
29
+ rake (13.3.0)
30
+ regexp_parser (2.10.0)
31
+ rexml (3.4.1)
32
+ rubocop (1.77.0)
33
+ json (~> 2.3)
34
+ language_server-protocol (~> 3.17.0.2)
35
+ lint_roller (~> 1.1.0)
36
+ parallel (~> 1.10)
37
+ parser (>= 3.3.0.2)
38
+ rainbow (>= 2.2.2, < 4.0)
39
+ regexp_parser (>= 2.9.3, < 3.0)
40
+ rubocop-ast (>= 1.45.1, < 2.0)
41
+ ruby-progressbar (~> 1.7)
42
+ unicode-display_width (>= 2.4.0, < 4.0)
43
+ rubocop-ast (1.45.1)
44
+ parser (>= 3.3.7.2)
45
+ prism (~> 1.4)
46
+ rubocop-minitest (0.38.1)
47
+ lint_roller (~> 1.1)
48
+ rubocop (>= 1.75.0, < 2.0)
49
+ rubocop-ast (>= 1.38.0, < 2.0)
50
+ rubocop-performance (1.25.0)
51
+ lint_roller (~> 1.1)
52
+ rubocop (>= 1.75.0, < 2.0)
53
+ rubocop-ast (>= 1.38.0, < 2.0)
54
+ rubocop-rake (0.7.1)
55
+ lint_roller (~> 1.1)
56
+ rubocop (>= 1.72.1)
57
+ ruby-progressbar (1.13.0)
58
+ simplecov (0.22.0)
59
+ docile (~> 1.1)
60
+ simplecov-html (~> 0.11)
61
+ simplecov_json_formatter (~> 0.1)
62
+ simplecov-cobertura (2.1.0)
63
+ rexml
64
+ simplecov (~> 0.19)
65
+ simplecov-html (0.13.1)
66
+ simplecov_json_formatter (0.1.4)
67
+ unicode-display_width (3.1.4)
68
+ unicode-emoji (~> 4.0, >= 4.0.4)
69
+ unicode-emoji (4.0.4)
70
+ yard (0.9.37)
71
+
72
+ PLATFORMS
73
+ aarch64-linux
74
+ arm-linux
75
+ arm64-darwin
76
+ arm64-darwin-23
77
+ x64-mingw-ucrt
78
+ x86-linux
79
+ x86_64-darwin
80
+ x86_64-linux
81
+
82
+ DEPENDENCIES
83
+ intercepted!
84
+ minitest (~> 5.25)
85
+ minitest-reporters (~> 1.7)
86
+ rake (~> 13.2)
87
+ rubocop (~> 1.64)
88
+ rubocop-minitest (~> 0.38)
89
+ rubocop-performance (~> 1.25)
90
+ rubocop-rake (~> 0.7)
91
+ simplecov (~> 0.22)
92
+ simplecov-cobertura (~> 2.1)
93
+ yard (~> 0.9)
94
+
95
+ BUNDLED WITH
96
+ 2.5.16
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 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 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.
data/LICENSES/MIT.txt ADDED
@@ -0,0 +1,21 @@
1
+ (The MIT License)
2
+
3
+ Copyright (c) 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 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.
data/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # Intercepts All Method Calls to a Ruby Object
2
+
3
+ [![DevOps By Rultor.com](https://www.rultor.com/b/yegor256/intercepted)](https://www.rultor.com/p/yegor256/intercepted)
4
+ [![We recommend RubyMine](https://www.elegantobjects.org/rubymine.svg)](https://www.jetbrains.com/ruby/)
5
+
6
+ [![rake](https://github.com/yegor256/intercepted/actions/workflows/rake.yml/badge.svg)](https://github.com/yegor256/intercepted/actions/workflows/rake.yml)
7
+ [![PDD status](https://www.0pdd.com/svg?name=yegor256/intercepted)](https://www.0pdd.com/p?name=yegor256/intercepted)
8
+ [![Gem Version](https://badge.fury.io/rb/intercepted.svg)](https://badge.fury.io/rb/intercepted)
9
+ [![Test Coverage](https://img.shields.io/codecov/c/github/yegor256/intercepted.svg)](https://codecov.io/github/yegor256/intercepted?branch=master)
10
+ [![Yard Docs](https://img.shields.io/badge/yard-docs-blue.svg)](https://rubydoc.info/github/yegor256/intercepted/master/frames)
11
+ [![Hits-of-Code](https://hitsofcode.com/github/yegor256/intercepted)](https://hitsofcode.com/view/github/yegor256/intercepted)
12
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/intercepted/blob/master/LICENSE.txt)
13
+
14
+ It decorates an existing Ruby object and intercepts all calls
15
+ to all its methods:
16
+
17
+ ```ruby
18
+ require 'intercepted'
19
+ i = intercepted(42) do |o, name, *args, &block|
20
+ r = o.__send__(name, *args, &block)
21
+ puts "#{name}(#{args.join(', ')}) -> #{r}"
22
+ r
23
+ end
24
+ puts i + 4
25
+ ```
26
+
27
+ Prints:
28
+
29
+ ```text
30
+
31
+ ```
32
+
33
+ That's it.
34
+
35
+ ## How to contribute
36
+
37
+ Read
38
+ [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
39
+ Make sure your build is green before you contribute
40
+ your pull request. You will need to have
41
+ [Ruby](https://www.ruby-lang.org/en/) 3.0+ and
42
+ [Bundler](https://bundler.io/) installed. Then run:
43
+
44
+ ```bash
45
+ bundle update
46
+ bundle exec rake
47
+ ```
48
+
49
+ If it's clean and you don't see any error messages, submit your pull request.
data/REUSE.toml ADDED
@@ -0,0 +1,35 @@
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
+ "**.txt",
15
+ "**/.DS_Store",
16
+ "**/.gitignore",
17
+ "**/.pdd",
18
+ "**/*.csv",
19
+ "**/*.jpg",
20
+ "**/*.json",
21
+ "**/*.md",
22
+ "**/*.pdf",
23
+ "**/*.png",
24
+ "**/*.svg",
25
+ "**/*.txt",
26
+ "**/*.vm",
27
+ "**/CNAME",
28
+ "**/Gemfile.lock",
29
+ "Gemfile.lock",
30
+ "README.md",
31
+ "renovate.json",
32
+ ]
33
+ precedence = "override"
34
+ SPDX-FileCopyrightText = "Copyright (c) 2025 Yegor Bugayenko"
35
+ SPDX-License-Identifier = "MIT"
data/Rakefile ADDED
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
5
+
6
+ require 'rubygems'
7
+ require 'rake'
8
+ require 'rake/clean'
9
+
10
+ def name
11
+ @name ||= File.basename(Dir['*.gemspec'].first, '.*')
12
+ end
13
+
14
+ def version
15
+ Gem::Specification.load(Dir['*.gemspec'].first).version
16
+ end
17
+
18
+ task default: %i[clean test rubocop yard]
19
+
20
+ require 'rake/testtask'
21
+ desc 'Run all unit tests'
22
+ Rake::TestTask.new(:test) do |test|
23
+ Rake::Cleaner.cleanup_files(['coverage'])
24
+ test.libs << 'lib' << 'test'
25
+ test.pattern = 'test/**/test_*.rb'
26
+ test.warning = true
27
+ test.verbose = false
28
+ end
29
+
30
+ require 'yard'
31
+ desc 'Build Yard documentation'
32
+ YARD::Rake::YardocTask.new do |t|
33
+ t.files = ['lib/**/*.rb']
34
+ end
35
+
36
+ require 'rubocop/rake_task'
37
+ desc 'Run RuboCop on all directories'
38
+ RuboCop::RakeTask.new(:rubocop) do |task|
39
+ task.fail_on_error = true
40
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
5
+
6
+ require 'English'
7
+
8
+ Gem::Specification.new do |s|
9
+ s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
10
+ s.required_ruby_version = '>=3.2'
11
+ s.name = 'intercepted'
12
+ s.version = '0.1.0'
13
+ s.license = 'MIT'
14
+ s.summary = 'Intercepts All Method Calls to a Ruby Object'
15
+ s.description =
16
+ 'It takes an existing Ruby object and creates a new one, ' \
17
+ 'that accepts all method calls and passes them to the provided block, ' \
18
+ 'which can pass them further to the original object.'
19
+ s.authors = ['Yegor Bugayenko']
20
+ s.email = 'yegor256@gmail.com'
21
+ s.homepage = 'https://github.com/yegor256/intercepted'
22
+ s.files = `git ls-files`.split($RS)
23
+ s.executables = s.files.grep(%r{^bin/}) { |f| File.basename(f) }
24
+ s.rdoc_options = ['--charset=UTF-8']
25
+ s.extra_rdoc_files = ['README.md', 'LICENSE.txt']
26
+ s.metadata['rubygems_mfa_required'] = 'true'
27
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
5
+
6
+ # System module.
7
+ module Kernel
8
+ def intercepted(origin = nil, &pipe)
9
+ raise 'Block is expected by intercepted()' unless block_given?
10
+
11
+ Class.new(BasicObject) do
12
+ define_method(:initialize) { @o = origin }
13
+ define_method(:method_missing) do |name, *args, &block|
14
+ pipe.call(@o, name, *args, &block)
15
+ end
16
+ define_method(:respond_to?) do |name, include_private = false|
17
+ @o.respond_to?(name, include_private)
18
+ end
19
+ end.new
20
+ end
21
+ end
data/renovate.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "extends": [
4
+ "config:base"
5
+ ]
6
+ }
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ # SPDX-FileCopyrightText: Copyright (c) 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 100
19
+ SimpleCov.minimum_coverage_by_file 100
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]
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ # SPDX-FileCopyrightText: Copyright (c) 2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
5
+
6
+ require_relative '../lib/intercepted'
7
+
8
+ # Test.
9
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
10
+ # Copyright:: Copyright (c) 2025 Yegor Bugayenko
11
+ # License:: MIT
12
+ class Testintercepted < Minitest::Test
13
+ def test_simple
14
+ i = intercepted(42) do |o, name, *args, &block|
15
+ r = o.__send__(name, *args, &block)
16
+ puts "#{name}(#{args.join(', ')}) -> #{r}"
17
+ r
18
+ end
19
+
20
+ assert_equal(46, i + 4)
21
+ assert_respond_to(i, :+)
22
+ end
23
+ end
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: intercepted
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Yegor Bugayenko
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies: []
12
+ description: It takes an existing Ruby object and creates a new one, that accepts
13
+ all method calls and passes them to the provided block, which can pass them further
14
+ to the original object.
15
+ email: yegor256@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files:
19
+ - LICENSE.txt
20
+ - README.md
21
+ files:
22
+ - ".0pdd.yml"
23
+ - ".gitattributes"
24
+ - ".github/workflows/actionlint.yml"
25
+ - ".github/workflows/codecov.yml"
26
+ - ".github/workflows/copyrights.yml"
27
+ - ".github/workflows/license.yml"
28
+ - ".github/workflows/markdown-lint.yml"
29
+ - ".github/workflows/pdd.yml"
30
+ - ".github/workflows/rake.yml"
31
+ - ".github/workflows/reuse.yml"
32
+ - ".github/workflows/typos.yml"
33
+ - ".github/workflows/xcop.yml"
34
+ - ".github/workflows/yamllint.yml"
35
+ - ".gitignore"
36
+ - ".pdd"
37
+ - ".rubocop.yml"
38
+ - ".rultor.yml"
39
+ - Gemfile
40
+ - Gemfile.lock
41
+ - LICENSE.txt
42
+ - LICENSES/MIT.txt
43
+ - README.md
44
+ - REUSE.toml
45
+ - Rakefile
46
+ - intercepted.gemspec
47
+ - lib/intercepted.rb
48
+ - renovate.json
49
+ - test/test__helper.rb
50
+ - test/test_intercepted.rb
51
+ homepage: https://github.com/yegor256/intercepted
52
+ licenses:
53
+ - MIT
54
+ metadata:
55
+ rubygems_mfa_required: 'true'
56
+ rdoc_options:
57
+ - "--charset=UTF-8"
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: '3.2'
65
+ required_rubygems_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ requirements: []
71
+ rubygems_version: 3.6.7
72
+ specification_version: 4
73
+ summary: Intercepts All Method Calls to a Ruby Object
74
+ test_files: []