obk 0.3.0 → 0.3.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d34fd03b0e47f11f25a670c4c9c854df9898d707e996bc7435410a89bcdcb583
4
- data.tar.gz: 1fef24bde0357f0f60bdc1831346519186e068babbfc222d6d06a7ba86652ee7
3
+ metadata.gz: ebe6cd0c3d7f5613623995b0510d62feb3080edaee7c5cf7782b7a6b52f54ed0
4
+ data.tar.gz: 1389f5b5cd116d774fd7866a2cf3dcc8b6e04bd52864feaac76ef5f91798ddba
5
5
  SHA512:
6
- metadata.gz: d7a482d7277343072200ac507b7f60500e89fd49c370caa12267b7175ec0a24e1777307661a107768ce7b9e12343956891e220ea309a4d4a2454750a6c647302
7
- data.tar.gz: 72bd6de675fe5fe4bc387a88cff0081c408a9f027d1d4cc7d2f0d9ff2874ca586a7bde86eca100d70c3b0335f16902ef715ed05eccdb53d19ef38d60905284ab
6
+ metadata.gz: c1becac99d9ba6b60962317988dc3f554e635f42778505d9daeba8aae61a3c9e4ef381b1a5d0ad4508f8a2ea6432cd7c8a6bffbfe0a14ffc9bacdec2a61d99c2
7
+ data.tar.gz: 37cda76d3a5d8c95c0a9cad871fbf0a13ee48c2be269342816ed8b965ca4be01b446047dc5f20372a8eb06c5ae574fdf7d9deb3e7e81e399f5a067c3759dd275
data/.0pdd.yml CHANGED
@@ -1,9 +1,8 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2021-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+ ---
1
4
  errors:
2
5
  - yegor256@gmail.com
3
- # alerts:
4
- # github:
5
- # - yegor256
6
-
7
6
  tags:
8
7
  - pdd
9
8
  - bug
@@ -0,0 +1,25 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2021-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
@@ -1,20 +1,27 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2021-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
1
3
  ---
4
+ # yamllint disable rule:line-length
2
5
  name: codecov
3
- on:
6
+ 'on':
4
7
  push:
5
8
  branches:
6
9
  - master
7
10
  jobs:
8
11
  codecov:
9
- runs-on: ubuntu-20.04
12
+ timeout-minutes: 15
13
+ runs-on: ubuntu-24.04
10
14
  steps:
11
- - uses: actions/checkout@v2
12
- - uses: actions/setup-ruby@v1
15
+ - uses: actions/checkout@v4
16
+ - uses: ruby/setup-ruby@v1
13
17
  with:
14
- ruby-version: 2.7
15
- - run: bundle update
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
16
22
  - run: bundle exec rake
17
- - uses: codecov/codecov-action@v1
23
+ - uses: codecov/codecov-action@v5
18
24
  with:
19
- file: coverage/.resultset.json
25
+ token: ${{ secrets.CODECOV_TOKEN }}
26
+ files: coverage/.resultset.json
20
27
  fail_ci_if_error: true
@@ -0,0 +1,19 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2021-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.8
@@ -0,0 +1,19 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2021-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: articulate/actions-markdownlint@v1
@@ -1,6 +1,9 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2021-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:
5
8
  branches:
6
9
  - master
@@ -9,7 +12,8 @@ name: pdd
9
12
  - master
10
13
  jobs:
11
14
  pdd:
12
- runs-on: ubuntu-20.04
15
+ timeout-minutes: 15
16
+ runs-on: ubuntu-24.04
13
17
  steps:
14
- - uses: actions/checkout@v2
15
- - uses: g4s8/pdd-action@master
18
+ - uses: actions/checkout@v4
19
+ - uses: volodya-lombrozo/pdd-action@master
@@ -1,6 +1,9 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2021-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
@@ -8,17 +11,18 @@ on:
8
11
  branches:
9
12
  - master
10
13
  jobs:
11
- test:
12
- name: test
14
+ rake:
13
15
  strategy:
14
16
  matrix:
15
- os: [ubuntu-20.04]
16
- ruby: [2.6]
17
+ os: [ubuntu-24.04]
18
+ ruby: [3.3]
17
19
  runs-on: ${{ matrix.os }}
18
20
  steps:
19
- - uses: actions/checkout@v2
21
+ - uses: actions/checkout@v4
20
22
  - uses: ruby/setup-ruby@v1
21
23
  with:
22
24
  ruby-version: ${{ matrix.ruby }}
23
- - run: bundle update
25
+ bundler-cache: true
26
+ - run: bundle config set --global path "$(pwd)/vendor/bundle"
27
+ - run: bundle install --no-color
24
28
  - run: bundle exec rake
@@ -0,0 +1,19 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2021-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
@@ -1,4 +1,7 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2021-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
1
3
  ---
4
+ # yamllint disable rule:line-length
2
5
  name: xcop
3
6
  "on":
4
7
  push:
@@ -9,9 +12,10 @@ name: xcop
9
12
  - master
10
13
  jobs:
11
14
  xcop:
12
- runs-on: ubuntu-20.04
15
+ timeout-minutes: 15
16
+ runs-on: ubuntu-24.04
13
17
  steps:
14
- - uses: actions/checkout@v2
18
+ - uses: actions/checkout@v4
15
19
  - uses: g4s8/xcop-action@master
16
20
  with:
17
21
  files: '**/*.xml'
@@ -0,0 +1,19 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2021-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
@@ -1,6 +1,10 @@
1
- Gemfile.lock
2
1
  *.gem
3
- .bundle/
4
2
  .DS_Store
5
- rdoc/
3
+ .bundle/
6
4
  .idea/
5
+ .yardoc/
6
+ coverage/
7
+ doc/
8
+ node_modules/
9
+ rdoc/
10
+ vendor/
data/.rubocop.yml CHANGED
@@ -1,9 +1,17 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2021-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+ ---
1
4
  AllCops:
2
5
  DisplayCopNames: true
3
6
  TargetRubyVersion: 2.3
4
7
  NewCops: enable
5
8
  SuggestExtensions: false
6
-
9
+ plugins:
10
+ - rubocop-rake
11
+ - rubocop-minitest
12
+ - rubocop-performance
13
+ Minitest/EmptyLineBeforeAssertionMethods:
14
+ Enabled: false
7
15
  Layout/EndOfLine:
8
16
  EnforcedStyle: lf
9
17
  Style/OptionalBooleanParameter:
@@ -18,3 +26,9 @@ Layout/ElseAlignment:
18
26
  Enabled: false
19
27
  Layout/IndentationWidth:
20
28
  Enabled: false
29
+ Metrics/AbcSize:
30
+ Max: 30
31
+ Metrics/PerceivedComplexity:
32
+ Max: 15
33
+ Metrics/CyclomaticComplexity:
34
+ Max: 15
data/.rultor.yml CHANGED
@@ -1,13 +1,18 @@
1
+ # SPDX-FileCopyrightText: Copyright (c) 2021-2025 Yegor Bugayenko
2
+ # SPDX-License-Identifier: MIT
3
+ ---
4
+ # yamllint disable rule:line-length
1
5
  docker:
2
- image: yegor256/rultor-image:1.9.1
6
+ image: yegor256/ruby
3
7
  assets:
4
8
  rubygems.yml: yegor256/home#assets/rubygems.yml
5
9
  install: |
6
10
  pdd -f /dev/null
7
- sudo bundle install --no-color "--gemfile=$(pwd)/Gemfile"
11
+ bundle install --no-color
8
12
  release:
13
+ pre: false
9
14
  script: |-
10
- bundle exec rake clean test rubocop copyright
15
+ bundle exec rake
11
16
  sed -i "s/0\.0\.0/${tag}/g" obk.gemspec
12
17
  git add obk.gemspec
13
18
  git commit -m "version set to ${tag}"
@@ -16,4 +21,4 @@ release:
16
21
  gem push *.gem --config-file ../rubygems.yml
17
22
  merge:
18
23
  script: |-
19
- bundle exec rake clean test rubocop copyright
24
+ bundle exec rake
data/Gemfile CHANGED
@@ -1,25 +1,19 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2021-2022 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.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2021-2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
22
5
 
23
6
  source 'https://rubygems.org'
24
- ruby '~>2.3'
25
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 'rdoc', '~>6.11', require: false
13
+ gem 'rubocop', '~>1.71', require: false
14
+ gem 'rubocop-minitest', '>0', require: false
15
+ gem 'rubocop-performance', '>0', require: false
16
+ gem 'rubocop-rake', '>0', require: false
17
+ gem 'rubocop-rspec', '>0', require: false
18
+ gem 'simplecov', '~>0.22', require: false
19
+ gem 'simplecov-cobertura', '~>2.1', require: false
data/Gemfile.lock ADDED
@@ -0,0 +1,103 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ obk (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
+ json (2.10.2)
15
+ language_server-protocol (3.17.0.4)
16
+ lint_roller (1.1.0)
17
+ minitest (5.25.5)
18
+ minitest-reporters (1.7.1)
19
+ ansi
20
+ builder
21
+ minitest (>= 5.0)
22
+ ruby-progressbar
23
+ parallel (1.26.3)
24
+ parser (3.3.7.4)
25
+ ast (~> 2.4.1)
26
+ racc
27
+ prism (1.4.0)
28
+ psych (5.2.3)
29
+ date
30
+ stringio
31
+ racc (1.8.1)
32
+ rainbow (3.1.1)
33
+ rake (13.2.1)
34
+ rdoc (6.13.1)
35
+ psych (>= 4.0.0)
36
+ regexp_parser (2.10.0)
37
+ rexml (3.4.1)
38
+ rubocop (1.75.2)
39
+ json (~> 2.3)
40
+ language_server-protocol (~> 3.17.0.2)
41
+ lint_roller (~> 1.1.0)
42
+ parallel (~> 1.10)
43
+ parser (>= 3.3.0.2)
44
+ rainbow (>= 2.2.2, < 4.0)
45
+ regexp_parser (>= 2.9.3, < 3.0)
46
+ rubocop-ast (>= 1.44.0, < 2.0)
47
+ ruby-progressbar (~> 1.7)
48
+ unicode-display_width (>= 2.4.0, < 4.0)
49
+ rubocop-ast (1.44.0)
50
+ parser (>= 3.3.7.2)
51
+ prism (~> 1.4)
52
+ rubocop-minitest (0.38.0)
53
+ lint_roller (~> 1.1)
54
+ rubocop (>= 1.75.0, < 2.0)
55
+ rubocop-ast (>= 1.38.0, < 2.0)
56
+ rubocop-performance (1.25.0)
57
+ lint_roller (~> 1.1)
58
+ rubocop (>= 1.75.0, < 2.0)
59
+ rubocop-ast (>= 1.38.0, < 2.0)
60
+ rubocop-rake (0.7.1)
61
+ lint_roller (~> 1.1)
62
+ rubocop (>= 1.72.1)
63
+ rubocop-rspec (3.5.0)
64
+ lint_roller (~> 1.1)
65
+ rubocop (~> 1.72, >= 1.72.1)
66
+ ruby-progressbar (1.13.0)
67
+ simplecov (0.22.0)
68
+ docile (~> 1.1)
69
+ simplecov-html (~> 0.11)
70
+ simplecov_json_formatter (~> 0.1)
71
+ simplecov-cobertura (2.1.0)
72
+ rexml
73
+ simplecov (~> 0.19)
74
+ simplecov-html (0.13.1)
75
+ simplecov_json_formatter (0.1.4)
76
+ stringio (3.1.6)
77
+ unicode-display_width (3.1.4)
78
+ unicode-emoji (~> 4.0, >= 4.0.4)
79
+ unicode-emoji (4.0.4)
80
+
81
+ PLATFORMS
82
+ arm64-darwin-22
83
+ arm64-darwin-23
84
+ arm64-darwin-24
85
+ x64-mingw-ucrt
86
+ x86_64-linux
87
+
88
+ DEPENDENCIES
89
+ minitest (~> 5.25)
90
+ minitest-reporters (~> 1.7)
91
+ obk!
92
+ rake (~> 13.2)
93
+ rdoc (~> 6.11)
94
+ rubocop (~> 1.71)
95
+ rubocop-minitest (> 0)
96
+ rubocop-performance (> 0)
97
+ rubocop-rake (> 0)
98
+ rubocop-rspec (> 0)
99
+ simplecov (~> 0.22)
100
+ simplecov-cobertura (~> 2.1)
101
+
102
+ BUNDLED WITH
103
+ 2.5.16
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2019 Yegor Bugayenko
3
+ Copyright (c) 2021-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) 2021-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,4 +1,4 @@
1
- <img src="/logo.svg" width="64px" height="64px"/>
1
+ # Throttle Ruby Method Calls
2
2
 
3
3
  [![EO principles respected here](https://www.elegantobjects.org/badge.svg)](https://www.elegantobjects.org)
4
4
  [![DevOps By Rultor.com](http://www.rultor.com/b/yegor256/obk)](http://www.rultor.com/p/yegor256/obk)
@@ -15,7 +15,7 @@
15
15
  First, install it:
16
16
 
17
17
  ```bash
18
- $ gem install obk
18
+ gem install obk
19
19
  ```
20
20
 
21
21
  Then, use it like this:
@@ -35,13 +35,14 @@ Keep in mind that `Obk` is _not_ thread-safe.
35
35
  ## How to contribute
36
36
 
37
37
  Read [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
38
- Make sure you build is green before you contribute
39
- your pull request. You will need to have [Ruby](https://www.ruby-lang.org/en/) 2.3+ and
38
+ Make sure your build is green before you contribute
39
+ your pull request. You will need to have
40
+ [Ruby](https://www.ruby-lang.org/en/) 2.3+ and
40
41
  [Bundler](https://bundler.io/) installed. Then:
41
42
 
42
- ```
43
- $ bundle update
44
- $ bundle exec rake
43
+ ```bash
44
+ bundle update
45
+ bundle exec rake
45
46
  ```
46
47
 
47
48
  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
+ "**.json",
8
+ "**.md",
9
+ "**.png",
10
+ "**.txt",
11
+ "**/*.csv",
12
+ "**/*.jpg",
13
+ "**/*.json",
14
+ "**/*.md",
15
+ "**/*.pdf",
16
+ "**/*.png",
17
+ "**/*.svg",
18
+ "**/*.txt",
19
+ "**/*.vm",
20
+ "**/.DS_Store",
21
+ "**/.gitignore",
22
+ "**/.pdd",
23
+ "**/CNAME",
24
+ "**/Gemfile.lock",
25
+ ".DS_Store",
26
+ ".gitattributes",
27
+ ".gitignore",
28
+ ".pdd",
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 CHANGED
@@ -1,24 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Copyright (c) 2021-2022 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.
3
+ # SPDX-FileCopyrightText: Copyright (c) 2021-2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
22
5
 
23
6
  require 'rubygems'
24
7
  require 'rake'
@@ -53,13 +36,4 @@ require 'rubocop/rake_task'
53
36
  desc 'Run RuboCop on all directories'
54
37
  RuboCop::RakeTask.new(:rubocop) do |task|
55
38
  task.fail_on_error = true
56
- task.requires << 'rubocop-rspec'
57
- end
58
-
59
- task :copyright do
60
- sh "grep -q -r '2021-#{Date.today.strftime('%Y')}' \
61
- --include '*.rb' \
62
- --include '*.txt' \
63
- --include 'Rakefile' \
64
- ."
65
39
  end
data/lib/obk.rb CHANGED
@@ -1,26 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # (The MIT License)
4
- #
5
- # Copyright (c) 2021-2022 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) 2021-2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
24
5
 
25
6
  # Obk is a decorator that adds delays between object method calls.
26
7
  #
@@ -28,7 +9,7 @@
28
9
  # {README}[https://github.com/yegor256/obk/blob/master/README.md] file.
29
10
  #
30
11
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
31
- # Copyright:: Copyright (c) 2021-2022 Yegor Bugayenko
12
+ # Copyright:: Copyright (c) 2021-2025 Yegor Bugayenko
32
13
  # License:: MIT
33
14
  class Obk
34
15
  def initialize(origin, pause: 1000)
@@ -40,12 +21,21 @@ class Obk
40
21
  def method_missing(*args)
41
22
  left = @pause - (Time.now - @latest)
42
23
  sleep left if left.positive?
43
- result = if block_given?
44
- @origin.__send__(*args) do |*a|
45
- yield(*a)
24
+ mtd = args.shift
25
+ result = if @origin.respond_to?(mtd)
26
+ params = @origin.method(mtd).parameters
27
+ reqs = params.count { |p| p[0] == :req }
28
+ if params.any? { |p| p[0] == :key } && args.size > reqs
29
+ @origin.__send__(mtd, *args[0...-1], **args.last) do |*a|
30
+ yield(*a) if block_given?
31
+ end
32
+ else
33
+ @origin.__send__(mtd, *args) do |*a|
34
+ yield(*a) if block_given?
35
+ end
46
36
  end
47
37
  else
48
- @origin.__send__(*args)
38
+ super
49
39
  end
50
40
  @latest = Time.now
51
41
  result
data/obk.gemspec CHANGED
@@ -1,33 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # (The MIT License)
4
- #
5
- # Copyright (c) 2021-2022 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) 2021-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 = 'obk'
30
- s.version = '0.3.0'
11
+ s.version = '0.3.2'
31
12
  s.license = 'MIT'
32
13
  s.summary = 'Ruby decorator to throttle object method calls'
33
14
  s.description = 'Ruby decorator to throttle object method calls'
@@ -37,10 +18,5 @@ Gem::Specification.new do |s|
37
18
  s.files = `git ls-files`.split($RS)
38
19
  s.rdoc_options = ['--charset=UTF-8']
39
20
  s.extra_rdoc_files = ['README.md']
40
- s.add_development_dependency 'minitest', '5.16.2'
41
- s.add_development_dependency 'rake', '13.0.6'
42
- s.add_development_dependency 'rdoc', '6.4.0'
43
- s.add_development_dependency 'rubocop', '1.34.1'
44
- s.add_development_dependency 'rubocop-rspec', '2.12.1'
45
21
  s.metadata['rubygems_mfa_required'] = 'true'
46
22
  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,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ # SPDX-FileCopyrightText: Copyright (c) 2021-2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
5
+
6
+ $stdout.sync = true
7
+
8
+ require 'simplecov'
9
+ SimpleCov.external_at_exit = true
10
+ SimpleCov.start
11
+
12
+ require 'simplecov-cobertura'
13
+ SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter
14
+
15
+ require 'minitest/autorun'
16
+
17
+ require 'minitest/reporters'
18
+ Minitest::Reporters.use! [Minitest::Reporters::SpecReporter.new]
data/test/test_obk.rb CHANGED
@@ -1,34 +1,16 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # (The MIT License)
4
- #
5
- # Copyright (c) 2021-2022 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) 2021-2025 Yegor Bugayenko
4
+ # SPDX-License-Identifier: MIT
24
5
 
25
6
  require 'minitest/autorun'
26
7
  require 'json'
8
+ require_relative '../test/test__helper'
27
9
  require_relative '../lib/obk'
28
10
 
29
11
  # Obk test.
30
12
  # Author:: Yegor Bugayenko (yegor256@gmail.com)
31
- # Copyright:: Copyright (c) 2021-2022 Yegor Bugayenko
13
+ # Copyright:: Copyright (c) 2021-2025 Yegor Bugayenko
32
14
  # License:: MIT
33
15
  class ObkTest < Minitest::Test
34
16
  def test_simple
@@ -36,11 +18,32 @@ class ObkTest < Minitest::Test
36
18
  def obj.read(foo)
37
19
  foo
38
20
  end
39
- obj = Obk.new(obj, pause: 1000)
21
+ obj = Obk.new(obj, pause: 100)
40
22
  start = Time.now
41
23
  assert_equal(42, obj.read(42))
42
24
  assert_equal(42, obj.read(42))
43
25
  stop = Time.now
44
- assert(stop - start > 1)
26
+ assert_operator(stop - start, :>, 0.1)
27
+ end
28
+
29
+ def test_works_with_optional_arguments
30
+ obj = Object.new
31
+ def obj.foo(first, _second, ext1: 'a', ext2: 'b')
32
+ first + ext1 + ext2
33
+ end
34
+ synced = Obk.new(obj, pause: 10)
35
+ assert_equal('.xy', synced.foo('.', {}, ext1: 'x', ext2: 'y'))
36
+ assert_equal('fzb', synced.foo('f', {}, ext1: 'z'))
37
+ assert_equal('-ab', synced.foo('-', {}))
38
+ end
39
+
40
+ def test_works_with_default_value
41
+ obj = Object.new
42
+ def obj.foo(first, second = 42)
43
+ first + second
44
+ end
45
+ synced = Obk.new(obj, pause: 10)
46
+ assert_equal(15, synced.foo(7, 8))
47
+ assert_equal(43, synced.foo(1))
45
48
  end
46
49
  end
metadata CHANGED
@@ -1,85 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: obk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2022-08-10 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: minitest
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '='
18
- - !ruby/object:Gem::Version
19
- version: 5.16.2
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '='
25
- - !ruby/object:Gem::Version
26
- version: 5.16.2
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '='
32
- - !ruby/object:Gem::Version
33
- version: 13.0.6
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '='
39
- - !ruby/object:Gem::Version
40
- version: 13.0.6
41
- - !ruby/object:Gem::Dependency
42
- name: rdoc
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - '='
46
- - !ruby/object:Gem::Version
47
- version: 6.4.0
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - '='
53
- - !ruby/object:Gem::Version
54
- version: 6.4.0
55
- - !ruby/object:Gem::Dependency
56
- name: rubocop
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - '='
60
- - !ruby/object:Gem::Version
61
- version: 1.34.1
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - '='
67
- - !ruby/object:Gem::Version
68
- version: 1.34.1
69
- - !ruby/object:Gem::Dependency
70
- name: rubocop-rspec
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - '='
74
- - !ruby/object:Gem::Version
75
- version: 2.12.1
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - '='
81
- - !ruby/object:Gem::Version
82
- version: 2.12.1
10
+ date: 2025-04-05 00:00:00.000000000 Z
11
+ dependencies: []
83
12
  description: Ruby decorator to throttle object method calls
84
13
  email: yegor256@gmail.com
85
14
  executables: []
@@ -88,28 +17,36 @@ extra_rdoc_files:
88
17
  - README.md
89
18
  files:
90
19
  - ".0pdd.yml"
20
+ - ".github/workflows/actionlint.yml"
91
21
  - ".github/workflows/codecov.yml"
22
+ - ".github/workflows/copyrights.yml"
23
+ - ".github/workflows/markdown-lint.yml"
92
24
  - ".github/workflows/pdd.yml"
93
25
  - ".github/workflows/rake.yml"
26
+ - ".github/workflows/reuse.yml"
94
27
  - ".github/workflows/xcop.yml"
28
+ - ".github/workflows/yamllint.yml"
95
29
  - ".gitignore"
96
30
  - ".pdd"
97
31
  - ".rubocop.yml"
98
32
  - ".rultor.yml"
99
33
  - Gemfile
34
+ - Gemfile.lock
100
35
  - LICENSE.txt
36
+ - LICENSES/MIT.txt
101
37
  - README.md
38
+ - REUSE.toml
102
39
  - Rakefile
103
40
  - lib/obk.rb
104
- - logo.svg
105
41
  - obk.gemspec
42
+ - renovate.json
43
+ - test/test__helper.rb
106
44
  - test/test_obk.rb
107
45
  homepage: http://github.com/yegor256/obk
108
46
  licenses:
109
47
  - MIT
110
48
  metadata:
111
49
  rubygems_mfa_required: 'true'
112
- post_install_message:
113
50
  rdoc_options:
114
51
  - "--charset=UTF-8"
115
52
  require_paths:
@@ -125,8 +62,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
62
  - !ruby/object:Gem::Version
126
63
  version: '0'
127
64
  requirements: []
128
- rubygems_version: 3.1.2
129
- signing_key:
65
+ rubygems_version: 3.6.2
130
66
  specification_version: 4
131
67
  summary: Ruby decorator to throttle object method calls
132
68
  test_files: []
data/logo.svg DELETED
@@ -1,19 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <svg width="314px" height="314px" viewBox="0 0 314 314" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
3
- <!-- Generator: Sketch 43.2 (39069) - http://www.bohemiancoding.com/sketch -->
4
- <title>Group 2</title>
5
- <desc>Created with Sketch.</desc>
6
- <defs></defs>
7
- <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
8
- <g id="Group-2">
9
- <g id="Group">
10
- <circle id="Oval" fill="#053C5E" cx="157" cy="157" r="157"></circle>
11
- <rect id="Rectangle" fill="#2B2B2B" x="0" y="234" width="212" height="68"></rect>
12
- <text id="obk" font-family="CourierNewPS-BoldMT, Courier New" font-size="50" font-weight="bold" fill="#FFFFFF">
13
- <tspan x="28" y="282">obk</tspan>
14
- </text>
15
- <path d="M135.676765,111.215287 C135.211714,113.540467 132.770932,120.688823 130.252813,127.100603 C127.734621,133.512383 125.2898,140.431445 124.819828,142.476214 C123.6868,147.405663 121.517836,147.185477 119.69487,141.95608 C116.899865,133.938362 105.171362,111.043501 103.859129,111.043501 C100.420089,111.043501 101.508757,114.986149 109.1771,130.30227 C113.739327,139.414532 118.032086,147.448041 118.716515,148.15443 C120.694817,150.196115 120.172626,154.319657 117.358599,158.877992 C113.567467,165.019055 107.570942,183.721189 108.054206,187.896804 C108.804956,194.383204 112.436054,192.210274 113.355359,184.724515 C114.48376,175.535577 120.945556,159.641154 124.897459,156.333653 C127.109021,154.482778 128.268636,151.905536 128.573284,148.163978 C128.818001,145.157747 131.906711,135.560972 135.437115,126.837819 C138.96752,118.114666 141.511492,110.079835 141.090434,108.982574 C139.755727,105.504315 136.554941,106.824333 135.676765,111.215287 M174.714659,126.841564 C169.37392,129.699438 169.197653,130.049915 167.452978,141.283475 C165.577352,153.360398 165.225112,168.513913 166.548289,180.203784 L167.566817,189.202501 L161.346213,191.9541 C154.601949,194.937416 150.91195,200.302465 153.156708,203.861146 C155.104824,206.949562 157.09025,206.70198 157.571826,203.310532 C158.083734,199.706169 166.097413,193.204052 170.29418,192.987978 C172.116999,192.894116 173.522874,191.717021 173.97823,189.903529 C174.383277,188.290613 177.740353,184.944554 181.438431,182.467858 C188.546172,177.707551 194.317883,170.450278 194.317883,166.273341 C194.317883,162.684548 189.493165,158.361603 185.487795,158.361603 C180.701636,158.361603 180.027195,155.239403 183.731222,150.229385 C188.308065,144.038966 188.284856,130.867646 183.690534,127.147387 C179.896537,124.075276 179.885006,124.074836 174.714659,126.841564 M182.67318,134.240439 C184.752542,140.153164 174.808961,161.185104 171.588639,157.68562 C169.868715,155.81653 172.863122,135.012708 175.266374,132.134564 C177.872553,129.013319 181.163896,129.949075 182.67318,134.240439 M184.854262,162.269586 C190.589839,163.855621 189.673839,167.881335 181.645765,176.371155 C177.281618,180.986262 173.904933,183.573859 173.371946,182.711474 C172.876636,181.91012 172.127869,176.711937 171.707987,171.159972 L170.944531,161.065463 L176.209475,161.200234 C179.105172,161.274339 182.995308,161.755548 184.854262,162.269586 M132.642184,172.492256 C131.593837,175.224098 133.152917,177.288844 136.264027,177.288844 C139.014965,177.288844 139.431396,176.221769 138.067531,172.667568 C137.039234,169.987871 133.645289,169.878218 132.642184,172.492256 M203.781503,185.840798 C203.781503,187.657595 209.264724,193.512152 210.966361,193.512152 C212.534035,193.512152 211.991059,187.391138 210.270768,185.670847 C208.092403,183.492409 203.781503,183.605293 203.781503,185.840798" id="Fill-6" fill="#427B8A" fill-rule="nonzero"></path>
16
- </g>
17
- </g>
18
- </g>
19
- </svg>