proc-throttle 0.1.0 → 0.1.1

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.
@@ -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
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
5
+ - 1.9.3
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 |increment|
24
- count += increment || 1
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
- throttled_proc = proc.throttle(1)
31
+ count // => 1
28
32
 
29
33
 
30
34
  ## Contributing
data/Rakefile CHANGED
@@ -1,2 +1,10 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
+
4
+ require 'rspec/core'
5
+ require 'rspec/core/rake_task'
6
+ RSpec::Core::RakeTask.new(:spec) do |spec|
7
+ spec.pattern = FileList['spec/**/*_spec.rb']
8
+ end
9
+
10
+ task :default => :spec
@@ -10,9 +10,11 @@ class Proc
10
10
  thread.kill
11
11
  end
12
12
 
13
- if !debounce && (last_exec.nil? || (last_exec + delay_sec < now))
14
- self.call(*args)
15
- last_exec = now
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)
@@ -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.0'
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
@@ -24,13 +24,13 @@ describe Proc do
24
24
 
25
25
  sleep 1.1
26
26
 
27
- count.should eql(4)
27
+ count.should eql(3)
28
28
 
29
29
  sleep 1.1
30
30
 
31
31
  throttled_proc.call(10)
32
32
 
33
- count.should eql(14)
33
+ count.should eql(13)
34
34
  end
35
35
  end
36
36
 
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.0
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: 2012-05-24 00:00:00.000000000 Z
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: &70357420018840 !ruby/object:Gem::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: *70357420018840
25
- description: ! 'Proc#throttle: throttling calls'
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: 1.8.10
78
+ rubygems_version: 2.0.14
69
79
  signing_key:
70
- specification_version: 3
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