obk 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6fe6bf5e396eacad1ff25efd2523677f944ae30aa2ec965690e38c60e341eee8
4
+ data.tar.gz: 54ef6a1867d711306e44b17e7060d796ab1f587f3b734aec2f2b5ef824db977f
5
+ SHA512:
6
+ metadata.gz: c88a5fc7d4a9f6f1a232a02b35840d1c124ccad0a206e3a37d16991167b43a6fa2771b9642466eaf1eb4b3e59264de9beca3071d055d40c18950dad9362ecad0
7
+ data.tar.gz: 762ac11379b64171866566f0b003b18ea6a2b866e24505d8977c7d0f4328d555781eebe6b3fdec8b1fedd3629979d430f3434a6d17709eb43281a390a7bd8093
data/.0pdd.yml ADDED
@@ -0,0 +1,9 @@
1
+ errors:
2
+ - yegor256@gmail.com
3
+ # alerts:
4
+ # github:
5
+ # - yegor256
6
+
7
+ tags:
8
+ - pdd
9
+ - bug
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: codecov
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ jobs:
8
+ codecov:
9
+ runs-on: ubuntu-20.04
10
+ steps:
11
+ - uses: actions/checkout@v2
12
+ - uses: actions/setup-ruby@v1
13
+ with:
14
+ ruby-version: 2.7
15
+ - run: bundle update
16
+ - run: bundle exec rake
17
+ - uses: codecov/codecov-action@v1
18
+ with:
19
+ file: coverage/.resultset.json
20
+ fail_ci_if_error: true
@@ -0,0 +1,15 @@
1
+ ---
2
+ name: pdd
3
+ "on":
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+ branches:
9
+ - master
10
+ jobs:
11
+ pdd:
12
+ runs-on: ubuntu-20.04
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - uses: g4s8/pdd-action@master
@@ -0,0 +1,24 @@
1
+ ---
2
+ name: rake
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+ branches:
9
+ - master
10
+ jobs:
11
+ test:
12
+ name: test
13
+ strategy:
14
+ matrix:
15
+ os: [ubuntu-20.04]
16
+ ruby: [2.6]
17
+ runs-on: ${{ matrix.os }}
18
+ steps:
19
+ - uses: actions/checkout@v2
20
+ - uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby }}
23
+ - run: bundle update
24
+ - run: bundle exec rake
@@ -0,0 +1,17 @@
1
+ ---
2
+ name: xcop
3
+ "on":
4
+ push:
5
+ branches:
6
+ - master
7
+ pull_request:
8
+ branches:
9
+ - master
10
+ jobs:
11
+ xcop:
12
+ runs-on: ubuntu-20.04
13
+ steps:
14
+ - uses: actions/checkout@v2
15
+ - uses: g4s8/xcop-action@master
16
+ with:
17
+ files: '**/*.xml'
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ Gemfile.lock
2
+ *.gem
3
+ .bundle/
4
+ .DS_Store
5
+ rdoc/
6
+ .idea/
data/.pdd ADDED
@@ -0,0 +1,5 @@
1
+ --source=.
2
+ --verbose
3
+ --rule min-words:20
4
+ --rule min-estimate:15
5
+ --rule max-estimate:90
data/.rubocop.yml ADDED
@@ -0,0 +1,20 @@
1
+ AllCops:
2
+ DisplayCopNames: true
3
+ TargetRubyVersion: 2.3
4
+ NewCops: enable
5
+ SuggestExtensions: false
6
+
7
+ Layout/EndOfLine:
8
+ EnforcedStyle: lf
9
+ Style/OptionalBooleanParameter:
10
+ Enabled: false
11
+ Lint/MissingSuper:
12
+ Enabled: false
13
+ Metrics/MethodLength:
14
+ Max: 50
15
+ Layout/EndAlignment:
16
+ Enabled: false
17
+ Layout/ElseAlignment:
18
+ Enabled: false
19
+ Layout/IndentationWidth:
20
+ Enabled: false
data/.rultor.yml ADDED
@@ -0,0 +1,16 @@
1
+ docker:
2
+ image: yegor256/rultor-image:1.9.1
3
+ assets:
4
+ rubygems.yml: yegor256/home#assets/rubygems.yml
5
+ install: |
6
+ pdd -f /dev/null
7
+ sudo bundle install --no-color "--gemfile=$(pwd)/Gemfile"
8
+ release:
9
+ script: |-
10
+ bundle exec rake clean test rubocop copyright
11
+ gem build obk.gemspec
12
+ chmod 0600 ../rubygems.yml
13
+ gem push *.gem --config-file ../rubygems.yml
14
+ merge:
15
+ script: |-
16
+ bundle exec rake clean test rubocop copyright
data/Gemfile ADDED
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
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.
22
+
23
+ source 'https://rubygems.org'
24
+ ruby '~>2.3'
25
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 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 ADDED
@@ -0,0 +1,47 @@
1
+ <img src="/logo.svg" width="64px" height="64px"/>
2
+
3
+ [![EO principles respected here](https://www.elegantobjects.org/badge.svg)](https://www.elegantobjects.org)
4
+ [![DevOps By Rultor.com](http://www.rultor.com/b/yegor256/obk)](http://www.rultor.com/p/yegor256/obk)
5
+ [![We recommend RubyMine](https://www.elegantobjects.org/rubymine.svg)](https://www.jetbrains.com/ruby/)
6
+
7
+ [![rake](https://github.com/yegor256/obk/actions/workflows/rake.yml/badge.svg)](https://github.com/yegor256/obk/actions/workflows/rake.yml)
8
+ [![Test Coverage](https://img.shields.io/codecov/c/github/obk/cobench.svg)](https://codecov.io/github/yegor256/obk?branch=master)
9
+ [![Gem Version](https://badge.fury.io/rb/obk.svg)](http://badge.fury.io/rb/obk)
10
+ [![Maintainability](https://api.codeclimate.com/v1/badges/e1be4e43e125fdc1e454/maintainability)](https://codeclimate.com/github/yegor256/obk/maintainability)
11
+ [![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/github/yegor256/obk/master/frames)
12
+ [![Hits-of-Code](https://hitsofcode.com/github/yegor256/obk)](https://hitsofcode.com/view/github/yegor256/obk)
13
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/obk/blob/master/LICENSE.txt)
14
+
15
+ First, install it:
16
+
17
+ ```bash
18
+ $ gem install obk
19
+ ```
20
+
21
+ Then, use it like this:
22
+
23
+ ```ruby
24
+ require 'obk'
25
+ obj = Obk.new(obj, pause: 500)
26
+ obj.foo
27
+ # Forced 500ms delay here
28
+ obj.bar
29
+ ```
30
+
31
+ There will be a forced delay of 500 milliseconds between `.foo` and `.bar` calls.
32
+
33
+ Keep in mind that `Obk` is _not_ thread-safe.
34
+
35
+ ## How to contribute
36
+
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
40
+ [Bundler](https://bundler.io/) installed. Then:
41
+
42
+ ```
43
+ $ bundle update
44
+ $ bundle exec rake
45
+ ```
46
+
47
+ If it's clean and you don't see any error messages, submit your pull request.
data/Rakefile ADDED
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
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.
22
+
23
+ require 'rubygems'
24
+ require 'rake'
25
+ require 'rake/clean'
26
+
27
+ def name
28
+ @name ||= File.basename(Dir['*.gemspec'].first, '.*')
29
+ end
30
+
31
+ def version
32
+ Gem::Specification.load(Dir['*.gemspec'].first).version
33
+ end
34
+
35
+ task default: %i[clean test rubocop]
36
+
37
+ require 'rake/testtask'
38
+ desc 'Run all unit tests'
39
+ Rake::TestTask.new(:test) do |test|
40
+ test.libs << 'lib' << 'test'
41
+ test.pattern = 'test/**/test_*.rb'
42
+ test.verbose = false
43
+ end
44
+
45
+ require 'rdoc/task'
46
+ RDoc::Task.new do |rdoc|
47
+ rdoc.main = 'README.md'
48
+ rdoc.rdoc_dir = 'rdoc'
49
+ rdoc.rdoc_files.include('README.md', 'lib/**/*.rb')
50
+ end
51
+
52
+ require 'rubocop/rake_task'
53
+ desc 'Run RuboCop on all directories'
54
+ RuboCop::RakeTask.new(:rubocop) do |task|
55
+ 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
+ end
data/lib/obk.rb ADDED
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
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.
24
+
25
+ # Obk is a decorator that adds delays between object method calls.
26
+ #
27
+ # For more information read
28
+ # {README}[https://github.com/yegor256/obk/blob/master/README.md] file.
29
+ #
30
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
31
+ # Copyright:: Copyright (c) 2021-2022 Yegor Bugayenko
32
+ # License:: MIT
33
+ class Obk
34
+ def initialize(origin, pause: 1000)
35
+ @origin = origin
36
+ @pause = pause / 1000.0
37
+ @latest = Time.now
38
+ end
39
+
40
+ def method_missing(*args)
41
+ left = @pause - (Time.now - @latest)
42
+ sleep left if left.positive?
43
+ result = if block_given?
44
+ @origin.__send__(*args) do |*a|
45
+ yield(*a)
46
+ end
47
+ else
48
+ @origin.__send__(*args)
49
+ end
50
+ @latest = Time.now
51
+ result
52
+ end
53
+
54
+ def respond_to?(method, include_private = false)
55
+ @origin.respond_to?(method, include_private)
56
+ end
57
+
58
+ def respond_to_missing?(_method, _include_private = false)
59
+ true
60
+ end
61
+ end
data/logo.svg ADDED
@@ -0,0 +1,19 @@
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>
data/obk.gemspec ADDED
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
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.
24
+
25
+ require 'English'
26
+ Gem::Specification.new do |s|
27
+ s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
28
+ s.required_ruby_version = '>=2.3'
29
+ s.name = 'obk'
30
+ s.version = '0.0.0'
31
+ s.license = 'MIT'
32
+ s.summary = 'Ruby decorator to throttle object method calls'
33
+ s.description = 'Ruby decorator to throttle object method calls'
34
+ s.authors = ['Yegor Bugayenko']
35
+ s.email = 'yegor256@gmail.com'
36
+ s.homepage = 'http://github.com/yegor256/obk'
37
+ s.files = `git ls-files`.split($RS)
38
+ s.rdoc_options = ['--charset=UTF-8']
39
+ 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
+ s.metadata['rubygems_mfa_required'] = 'true'
46
+ end
data/test/test_obk.rb ADDED
@@ -0,0 +1,46 @@
1
+ # frozen_string_literal: true
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.
24
+
25
+ require 'minitest/autorun'
26
+ require 'json'
27
+ require_relative '../lib/obk'
28
+
29
+ # Obk test.
30
+ # Author:: Yegor Bugayenko (yegor256@gmail.com)
31
+ # Copyright:: Copyright (c) 2021-2022 Yegor Bugayenko
32
+ # License:: MIT
33
+ class ObkTest < Minitest::Test
34
+ def test_simple
35
+ obj = Object.new
36
+ def obj.read(foo)
37
+ foo
38
+ end
39
+ obj = Obk.new(obj, pause: 1000)
40
+ start = Time.now
41
+ assert_equal(42, obj.read(42))
42
+ assert_equal(42, obj.read(42))
43
+ stop = Time.now
44
+ assert(stop - start > 1)
45
+ end
46
+ end
metadata ADDED
@@ -0,0 +1,132 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: obk
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Yegor Bugayenko
8
+ autorequire:
9
+ bindir: bin
10
+ 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
83
+ description: Ruby decorator to throttle object method calls
84
+ email: yegor256@gmail.com
85
+ executables: []
86
+ extensions: []
87
+ extra_rdoc_files:
88
+ - README.md
89
+ files:
90
+ - ".0pdd.yml"
91
+ - ".github/workflows/codecov.yml"
92
+ - ".github/workflows/pdd.yml"
93
+ - ".github/workflows/rake.yml"
94
+ - ".github/workflows/xcop.yml"
95
+ - ".gitignore"
96
+ - ".pdd"
97
+ - ".rubocop.yml"
98
+ - ".rultor.yml"
99
+ - Gemfile
100
+ - LICENSE.txt
101
+ - README.md
102
+ - Rakefile
103
+ - lib/obk.rb
104
+ - logo.svg
105
+ - obk.gemspec
106
+ - test/test_obk.rb
107
+ homepage: http://github.com/yegor256/obk
108
+ licenses:
109
+ - MIT
110
+ metadata:
111
+ rubygems_mfa_required: 'true'
112
+ post_install_message:
113
+ rdoc_options:
114
+ - "--charset=UTF-8"
115
+ require_paths:
116
+ - lib
117
+ required_ruby_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ version: '2.3'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ requirements: []
128
+ rubygems_version: 3.1.2
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: Ruby decorator to throttle object method calls
132
+ test_files: []