proc-throttle 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.travis.yml +5 -0
- data/README.md +8 -4
- data/Rakefile +8 -0
- data/lib/proc/throttle.rb +5 -3
- data/proc-throttle.gemspec +2 -1
- data/spec/throttle_spec.rb +2 -2
- metadata +30 -20
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 54f3626202d28a8548aecbcb5dc03e8f7f7e1c45
|
4
|
+
data.tar.gz: 69a1004eecdffe2b08bd631a0ac35f2c26a87449
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2f66edaaf30175e1ff9301b5d4cf057dfeb144ae8d0acc1c7f7b1a3d0ad046382ce55088c5f6e814344375401a8f787de90f5613cab800104e05fd8688fa7734
|
7
|
+
data.tar.gz: bbcce279ecce78f37973ea2d53d9f6fd19ab35ace3ecaec376f52b9200f3bd58166c00aa982de4cb6522147157eb2e353370a6579c2dff613b2ba80517769332
|
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# proc-throttle
|
1
|
+
# proc-throttle [![Build Status](https://secure.travis-ci.org/youpy/proc-throttle.png)](http://travis-ci.org/youpy/proc-throttle)
|
2
2
|
|
3
3
|
Proc#throttle: throttling calls
|
4
4
|
|
@@ -20,11 +20,15 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
count = 0
|
22
22
|
|
23
|
-
proc = Proc.new do
|
24
|
-
count +=
|
23
|
+
proc = Proc.new do
|
24
|
+
count += 1
|
25
|
+
end.throttle(1)
|
26
|
+
|
27
|
+
10.times do
|
28
|
+
proc.call
|
25
29
|
end
|
26
30
|
|
27
|
-
|
31
|
+
count // => 1
|
28
32
|
|
29
33
|
|
30
34
|
## Contributing
|
data/Rakefile
CHANGED
data/lib/proc/throttle.rb
CHANGED
@@ -10,9 +10,11 @@ class Proc
|
|
10
10
|
thread.kill
|
11
11
|
end
|
12
12
|
|
13
|
-
if !debounce
|
14
|
-
|
15
|
-
|
13
|
+
if !debounce
|
14
|
+
if (last_exec.nil? || (last_exec + delay_sec < now))
|
15
|
+
self.call(*args)
|
16
|
+
last_exec = now
|
17
|
+
end
|
16
18
|
else
|
17
19
|
thread = Thread.new do
|
18
20
|
sleep(delay_sec)
|
data/proc-throttle.gemspec
CHANGED
@@ -11,7 +11,8 @@ Gem::Specification.new do |gem|
|
|
11
11
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
12
12
|
gem.name = "proc-throttle"
|
13
13
|
gem.require_paths = ["lib"]
|
14
|
-
gem.version = '0.1.
|
14
|
+
gem.version = '0.1.1'
|
15
15
|
|
16
|
+
gem.add_development_dependency('rspec', ["~> 2.8.0"])
|
16
17
|
gem.add_development_dependency('rake')
|
17
18
|
end
|
data/spec/throttle_spec.rb
CHANGED
metadata
CHANGED
@@ -1,28 +1,44 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: proc-throttle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- youpy
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2015-10-30 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.8.0
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.8.0
|
14
27
|
- !ruby/object:Gem::Dependency
|
15
28
|
name: rake
|
16
|
-
requirement:
|
17
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
18
30
|
requirements:
|
19
|
-
- -
|
31
|
+
- - '>='
|
20
32
|
- !ruby/object:Gem::Version
|
21
33
|
version: '0'
|
22
34
|
type: :development
|
23
35
|
prerelease: false
|
24
|
-
version_requirements:
|
25
|
-
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: 'Proc#throttle: throttling calls'
|
26
42
|
email:
|
27
43
|
- youpy@buycheapviagraonlinenow.com
|
28
44
|
executables: []
|
@@ -31,6 +47,7 @@ extra_rdoc_files: []
|
|
31
47
|
files:
|
32
48
|
- .gitignore
|
33
49
|
- .rspec
|
50
|
+
- .travis.yml
|
34
51
|
- Gemfile
|
35
52
|
- LICENSE
|
36
53
|
- README.md
|
@@ -41,33 +58,26 @@ files:
|
|
41
58
|
- spec/throttle_spec.rb
|
42
59
|
homepage: ''
|
43
60
|
licenses: []
|
61
|
+
metadata: {}
|
44
62
|
post_install_message:
|
45
63
|
rdoc_options: []
|
46
64
|
require_paths:
|
47
65
|
- lib
|
48
66
|
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
67
|
requirements:
|
51
|
-
- -
|
68
|
+
- - '>='
|
52
69
|
- !ruby/object:Gem::Version
|
53
70
|
version: '0'
|
54
|
-
segments:
|
55
|
-
- 0
|
56
|
-
hash: 740962742363662978
|
57
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
72
|
requirements:
|
60
|
-
- -
|
73
|
+
- - '>='
|
61
74
|
- !ruby/object:Gem::Version
|
62
75
|
version: '0'
|
63
|
-
segments:
|
64
|
-
- 0
|
65
|
-
hash: 740962742363662978
|
66
76
|
requirements: []
|
67
77
|
rubyforge_project:
|
68
|
-
rubygems_version:
|
78
|
+
rubygems_version: 2.0.14
|
69
79
|
signing_key:
|
70
|
-
specification_version:
|
80
|
+
specification_version: 4
|
71
81
|
summary: A library to add Proc#throttle for throttling calls
|
72
82
|
test_files:
|
73
83
|
- spec/spec_helper.rb
|