obk 0.1.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/codecov.yml +20 -0
- data/.github/workflows/pdd.yml +15 -0
- data/.github/workflows/rake.yml +24 -0
- data/.github/workflows/xcop.yml +17 -0
- data/.rubocop.yml +9 -17
- data/.rultor.yml +7 -12
- data/Gemfile +1 -1
- data/README.md +6 -7
- data/Rakefile +9 -1
- data/lib/obk.rb +9 -4
- data/obk.gemspec +11 -15
- data/test/test_obk.rb +8 -5
- metadata +23 -21
- data/.travis.yml +0 -12
- data/appveyor.yml +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d34fd03b0e47f11f25a670c4c9c854df9898d707e996bc7435410a89bcdcb583
|
4
|
+
data.tar.gz: 1fef24bde0357f0f60bdc1831346519186e068babbfc222d6d06a7ba86652ee7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7a482d7277343072200ac507b7f60500e89fd49c370caa12267b7175ec0a24e1777307661a107768ce7b9e12343956891e220ea309a4d4a2454750a6c647302
|
7
|
+
data.tar.gz: 72bd6de675fe5fe4bc387a88cff0081c408a9f027d1d4cc7d2f0d9ff2874ca586a7bde86eca100d70c3b0335f16902ef715ed05eccdb53d19ef38d60905284ab
|
@@ -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,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
|
data/.rubocop.yml
CHANGED
@@ -1,28 +1,20 @@
|
|
1
1
|
AllCops:
|
2
2
|
DisplayCopNames: true
|
3
3
|
TargetRubyVersion: 2.3
|
4
|
+
NewCops: enable
|
5
|
+
SuggestExtensions: false
|
4
6
|
|
5
7
|
Layout/EndOfLine:
|
6
8
|
EnforcedStyle: lf
|
7
|
-
Style/
|
9
|
+
Style/OptionalBooleanParameter:
|
8
10
|
Enabled: false
|
9
|
-
|
11
|
+
Lint/MissingSuper:
|
10
12
|
Enabled: false
|
11
|
-
Layout/MultilineMethodCallIndentation:
|
12
|
-
Enabled: false
|
13
|
-
Metrics/AbcSize:
|
14
|
-
Max: 65
|
15
|
-
Metrics/BlockLength:
|
16
|
-
Max: 30
|
17
13
|
Metrics/MethodLength:
|
18
14
|
Max: 50
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
Max: 10
|
25
|
-
Metrics/ParameterLists:
|
26
|
-
Max: 10
|
27
|
-
Layout/AlignParameters:
|
15
|
+
Layout/EndAlignment:
|
16
|
+
Enabled: false
|
17
|
+
Layout/ElseAlignment:
|
18
|
+
Enabled: false
|
19
|
+
Layout/IndentationWidth:
|
28
20
|
Enabled: false
|
data/.rultor.yml
CHANGED
@@ -1,24 +1,19 @@
|
|
1
|
+
docker:
|
2
|
+
image: yegor256/rultor-image:1.9.1
|
1
3
|
assets:
|
2
4
|
rubygems.yml: yegor256/home#assets/rubygems.yml
|
3
|
-
install:
|
4
|
-
|
5
|
-
export GEM_PATH=$GEM_HOME:$GEM_PATH
|
5
|
+
install: |
|
6
|
+
pdd -f /dev/null
|
6
7
|
sudo bundle install --no-color "--gemfile=$(pwd)/Gemfile"
|
7
8
|
release:
|
8
9
|
script: |-
|
9
|
-
bundle exec rake
|
10
|
-
rm -rf *.gem
|
10
|
+
bundle exec rake clean test rubocop copyright
|
11
11
|
sed -i "s/0\.0\.0/${tag}/g" obk.gemspec
|
12
12
|
git add obk.gemspec
|
13
|
-
git commit -m "
|
13
|
+
git commit -m "version set to ${tag}"
|
14
14
|
gem build obk.gemspec
|
15
15
|
chmod 0600 ../rubygems.yml
|
16
16
|
gem push *.gem --config-file ../rubygems.yml
|
17
17
|
merge:
|
18
18
|
script: |-
|
19
|
-
bundle
|
20
|
-
bundle exec rake
|
21
|
-
deploy:
|
22
|
-
script: |-
|
23
|
-
echo 'Nothing to deploy'
|
24
|
-
exit -1
|
19
|
+
bundle exec rake clean test rubocop copyright
|
data/Gemfile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2021 Yegor Bugayenko
|
3
|
+
# Copyright (c) 2021-2022 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/README.md
CHANGED
@@ -4,12 +4,11 @@
|
|
4
4
|
[![DevOps By Rultor.com](http://www.rultor.com/b/yegor256/obk)](http://www.rultor.com/p/yegor256/obk)
|
5
5
|
[![We recommend RubyMine](https://www.elegantobjects.org/rubymine.svg)](https://www.jetbrains.com/ruby/)
|
6
6
|
|
7
|
-
[![
|
8
|
-
[![
|
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
9
|
[![Gem Version](https://badge.fury.io/rb/obk.svg)](http://badge.fury.io/rb/obk)
|
10
|
-
[![Maintainability](https://api.codeclimate.com/v1/badges/
|
10
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/e1be4e43e125fdc1e454/maintainability)](https://codeclimate.com/github/yegor256/obk/maintainability)
|
11
11
|
[![Yard Docs](http://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/github/yegor256/obk/master/frames)
|
12
|
-
|
13
12
|
[![Hits-of-Code](https://hitsofcode.com/github/yegor256/obk)](https://hitsofcode.com/view/github/yegor256/obk)
|
14
13
|
[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/yegor256/obk/blob/master/LICENSE.txt)
|
15
14
|
|
@@ -26,12 +25,12 @@ require 'obk'
|
|
26
25
|
obj = Obk.new(obj, pause: 500)
|
27
26
|
obj.foo
|
28
27
|
# Forced 500ms delay here
|
29
|
-
obj.
|
28
|
+
obj.bar
|
30
29
|
```
|
31
30
|
|
32
|
-
There will be a forced delay of 500 milliseconds between `.foo` calls.
|
31
|
+
There will be a forced delay of 500 milliseconds between `.foo` and `.bar` calls.
|
33
32
|
|
34
|
-
Keep in mind that `Obk` is thread-safe.
|
33
|
+
Keep in mind that `Obk` is _not_ thread-safe.
|
35
34
|
|
36
35
|
## How to contribute
|
37
36
|
|
data/Rakefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright (c) 2021 Yegor Bugayenko
|
3
|
+
# Copyright (c) 2021-2022 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
|
@@ -55,3 +55,11 @@ RuboCop::RakeTask.new(:rubocop) do |task|
|
|
55
55
|
task.fail_on_error = true
|
56
56
|
task.requires << 'rubocop-rspec'
|
57
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
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# (The MIT License)
|
4
4
|
#
|
5
|
-
# Copyright (c) 2021 Yegor Bugayenko
|
5
|
+
# Copyright (c) 2021-2022 Yegor Bugayenko
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -28,22 +28,27 @@
|
|
28
28
|
# {README}[https://github.com/yegor256/obk/blob/master/README.md] file.
|
29
29
|
#
|
30
30
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
31
|
-
# Copyright:: Copyright (c) 2021 Yegor Bugayenko
|
31
|
+
# Copyright:: Copyright (c) 2021-2022 Yegor Bugayenko
|
32
32
|
# License:: MIT
|
33
33
|
class Obk
|
34
34
|
def initialize(origin, pause: 1000)
|
35
35
|
@origin = origin
|
36
|
-
@pause = pause
|
36
|
+
@pause = pause / 1000.0
|
37
|
+
@latest = Time.now
|
37
38
|
end
|
38
39
|
|
39
40
|
def method_missing(*args)
|
40
|
-
|
41
|
+
left = @pause - (Time.now - @latest)
|
42
|
+
sleep left if left.positive?
|
43
|
+
result = if block_given?
|
41
44
|
@origin.__send__(*args) do |*a|
|
42
45
|
yield(*a)
|
43
46
|
end
|
44
47
|
else
|
45
48
|
@origin.__send__(*args)
|
46
49
|
end
|
50
|
+
@latest = Time.now
|
51
|
+
result
|
47
52
|
end
|
48
53
|
|
49
54
|
def respond_to?(method, include_private = false)
|
data/obk.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# (The MIT License)
|
4
4
|
#
|
5
|
-
# Copyright (c) 2021 Yegor Bugayenko
|
5
|
+
# Copyright (c) 2021-2022 Yegor Bugayenko
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -24,27 +24,23 @@
|
|
24
24
|
|
25
25
|
require 'English'
|
26
26
|
Gem::Specification.new do |s|
|
27
|
-
s.
|
28
|
-
if s.respond_to? :required_rubygems_version=
|
29
|
-
s.required_rubygems_version = Gem::Requirement.new('>= 0')
|
30
|
-
end
|
31
|
-
s.rubygems_version = '2.3.3'
|
27
|
+
s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
|
32
28
|
s.required_ruby_version = '>=2.3'
|
33
29
|
s.name = 'obk'
|
34
|
-
s.version = '0.
|
30
|
+
s.version = '0.3.0'
|
35
31
|
s.license = 'MIT'
|
36
|
-
s.summary = '
|
37
|
-
s.description = '
|
32
|
+
s.summary = 'Ruby decorator to throttle object method calls'
|
33
|
+
s.description = 'Ruby decorator to throttle object method calls'
|
38
34
|
s.authors = ['Yegor Bugayenko']
|
39
35
|
s.email = 'yegor256@gmail.com'
|
40
36
|
s.homepage = 'http://github.com/yegor256/obk'
|
41
37
|
s.files = `git ls-files`.split($RS)
|
42
|
-
s.test_files = s.files.grep(%r{^(test)/})
|
43
38
|
s.rdoc_options = ['--charset=UTF-8']
|
44
39
|
s.extra_rdoc_files = ['README.md']
|
45
|
-
s.add_development_dependency 'minitest', '5.
|
46
|
-
s.add_development_dependency 'rake', '
|
47
|
-
s.add_development_dependency 'rdoc', '4.
|
48
|
-
s.add_development_dependency 'rubocop', '
|
49
|
-
s.add_development_dependency 'rubocop-rspec', '
|
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'
|
50
46
|
end
|
data/test/test_obk.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# (The MIT License)
|
4
4
|
#
|
5
|
-
# Copyright (c) 2021 Yegor Bugayenko
|
5
|
+
# Copyright (c) 2021-2022 Yegor Bugayenko
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the 'Software'), to deal
|
@@ -28,7 +28,7 @@ require_relative '../lib/obk'
|
|
28
28
|
|
29
29
|
# Obk test.
|
30
30
|
# Author:: Yegor Bugayenko (yegor256@gmail.com)
|
31
|
-
# Copyright:: Copyright (c) 2021 Yegor Bugayenko
|
31
|
+
# Copyright:: Copyright (c) 2021-2022 Yegor Bugayenko
|
32
32
|
# License:: MIT
|
33
33
|
class ObkTest < Minitest::Test
|
34
34
|
def test_simple
|
@@ -36,8 +36,11 @@ class ObkTest < Minitest::Test
|
|
36
36
|
def obj.read(foo)
|
37
37
|
foo
|
38
38
|
end
|
39
|
-
|
40
|
-
|
41
|
-
assert_equal(42,
|
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)
|
42
45
|
end
|
43
46
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: obk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yegor Bugayenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
@@ -16,71 +16,71 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 5.
|
19
|
+
version: 5.16.2
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 5.
|
26
|
+
version: 5.16.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 13.0.6
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 13.0.6
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rdoc
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - '='
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 4.
|
47
|
+
version: 6.4.0
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - '='
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 4.
|
54
|
+
version: 6.4.0
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rubocop
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 1.34.1
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 1.34.1
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rubocop-rspec
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 2.12.1
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
83
|
-
description:
|
82
|
+
version: 2.12.1
|
83
|
+
description: Ruby decorator to throttle object method calls
|
84
84
|
email: yegor256@gmail.com
|
85
85
|
executables: []
|
86
86
|
extensions: []
|
@@ -88,16 +88,18 @@ extra_rdoc_files:
|
|
88
88
|
- README.md
|
89
89
|
files:
|
90
90
|
- ".0pdd.yml"
|
91
|
+
- ".github/workflows/codecov.yml"
|
92
|
+
- ".github/workflows/pdd.yml"
|
93
|
+
- ".github/workflows/rake.yml"
|
94
|
+
- ".github/workflows/xcop.yml"
|
91
95
|
- ".gitignore"
|
92
96
|
- ".pdd"
|
93
97
|
- ".rubocop.yml"
|
94
98
|
- ".rultor.yml"
|
95
|
-
- ".travis.yml"
|
96
99
|
- Gemfile
|
97
100
|
- LICENSE.txt
|
98
101
|
- README.md
|
99
102
|
- Rakefile
|
100
|
-
- appveyor.yml
|
101
103
|
- lib/obk.rb
|
102
104
|
- logo.svg
|
103
105
|
- obk.gemspec
|
@@ -105,7 +107,8 @@ files:
|
|
105
107
|
homepage: http://github.com/yegor256/obk
|
106
108
|
licenses:
|
107
109
|
- MIT
|
108
|
-
metadata:
|
110
|
+
metadata:
|
111
|
+
rubygems_mfa_required: 'true'
|
109
112
|
post_install_message:
|
110
113
|
rdoc_options:
|
111
114
|
- "--charset=UTF-8"
|
@@ -122,9 +125,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
125
|
- !ruby/object:Gem::Version
|
123
126
|
version: '0'
|
124
127
|
requirements: []
|
125
|
-
rubygems_version: 3.
|
128
|
+
rubygems_version: 3.1.2
|
126
129
|
signing_key:
|
127
|
-
specification_version:
|
128
|
-
summary:
|
129
|
-
test_files:
|
130
|
-
- test/test_obk.rb
|
130
|
+
specification_version: 4
|
131
|
+
summary: Ruby decorator to throttle object method calls
|
132
|
+
test_files: []
|
data/.travis.yml
DELETED
data/appveyor.yml
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
version: '{build}'
|
2
|
-
skip_tags: true
|
3
|
-
clone_depth: 10
|
4
|
-
branches:
|
5
|
-
only:
|
6
|
-
- master
|
7
|
-
except:
|
8
|
-
- gh-pages
|
9
|
-
os: Windows Server 2012
|
10
|
-
environment:
|
11
|
-
matrix:
|
12
|
-
- ruby_version: "25-x64"
|
13
|
-
install:
|
14
|
-
- ps: |
|
15
|
-
$Env:PATH = "C:\Ruby${Env:ruby_version}\bin;${Env:PATH}"
|
16
|
-
- bundle config --local path vendor/bundle
|
17
|
-
- ruby -v
|
18
|
-
- bundle -v
|
19
|
-
build_script:
|
20
|
-
- bundle update
|
21
|
-
- bundle install
|
22
|
-
test_script:
|
23
|
-
- bundle exec rake --quiet
|
24
|
-
cache:
|
25
|
-
- vendor/bundle
|