sideband 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/README.md +4 -0
- data/lib/sideband/manager.rb +1 -1
- data/lib/sideband/thread.rb +12 -9
- data/lib/sideband/version.rb +1 -1
- data/sideband.gemspec +2 -2
- data/test/test_manager.rb +1 -1
- data/test/test_sideband.rb +24 -7
- metadata +13 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6dcd1add7c9bf599343ed7d5f8c4efe4ff556418
|
4
|
+
data.tar.gz: 3ef16a42eb4ee99671c0e74afe1c0e7c2cbd177d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b3faaa239f15d4420e9e80bc446090663848c776cb433f07145118804d8f3891cc569ee694291ea58ae7391ffc15fdd1f43c6335cf89ce3f992b9f571aa4ae76
|
7
|
+
data.tar.gz: e641bc9a987b9f628858828df0eed5f2db6c1a96c2816dcec171574ba52bde76aa61a0d0a0a09507d791cd52d6402ee8b3853ec58a417bd6b9d822833f69ed4f
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -80,3 +80,7 @@ end
|
|
80
80
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
81
81
|
4. Push to the branch (`git push origin my-new-feature`)
|
82
82
|
5. Create new Pull Request
|
83
|
+
|
84
|
+
|
85
|
+
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/mje113/sideband/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
|
86
|
+
|
data/lib/sideband/manager.rb
CHANGED
data/lib/sideband/thread.rb
CHANGED
@@ -4,16 +4,19 @@ module Sideband
|
|
4
4
|
attr_reader :thread
|
5
5
|
|
6
6
|
def initialize(manager)
|
7
|
-
@manager = manager
|
8
7
|
@thread = ::Thread.new do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
work
|
14
|
-
|
15
|
-
|
16
|
-
|
8
|
+
queue = manager.queue
|
9
|
+
while true
|
10
|
+
work = queue.pop
|
11
|
+
if work.nil?
|
12
|
+
break # break from the infinite loop when a work of nil is pushed
|
13
|
+
else
|
14
|
+
begin
|
15
|
+
work.call
|
16
|
+
rescue Exception
|
17
|
+
# Sideband will ignore all Exceptions,
|
18
|
+
# better to handle in your workers.
|
19
|
+
end
|
17
20
|
end
|
18
21
|
end
|
19
22
|
end
|
data/lib/sideband/version.rb
CHANGED
data/sideband.gemspec
CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ['lib']
|
19
|
-
|
19
|
+
|
20
20
|
gem.add_development_dependency 'rake'
|
21
|
-
gem.add_development_dependency 'minitest', '
|
21
|
+
gem.add_development_dependency 'minitest', '>= 5.0.8'
|
22
22
|
end
|
data/test/test_manager.rb
CHANGED
data/test/test_sideband.rb
CHANGED
@@ -7,15 +7,32 @@ class TestSideband < Minitest::Test
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def test_has_queue
|
10
|
-
Sideband.initialize!
|
11
|
-
|
12
|
-
end
|
10
|
+
Sideband.initialize!
|
11
|
+
assert_kind_of Sideband::Queue, Sideband.queue
|
13
12
|
end
|
14
13
|
|
15
14
|
def test_can_access_queue_or_send_jobs
|
16
|
-
Sideband.initialize!
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
Sideband.initialize!
|
16
|
+
assert Sideband.queue(-> { 'work' })
|
17
|
+
assert Sideband.enqueue(-> { 'work' })
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_sideband_execution_success
|
21
|
+
$sideband_test_variable = 1
|
22
|
+
|
23
|
+
Sideband.initialize!
|
24
|
+
|
25
|
+
Sideband.queue(-> { $sideband_test_variable = 2 })
|
26
|
+
Sideband.queue(-> { $sideband_test_variable = 3 })
|
27
|
+
|
28
|
+
sleep 1
|
29
|
+
|
30
|
+
assert_equal 3, $sideband_test_variable
|
31
|
+
|
32
|
+
Sideband.queue << (-> { $sideband_test_variable = 4 })
|
33
|
+
|
34
|
+
sleep 1
|
35
|
+
|
36
|
+
assert_equal 4, $sideband_test_variable
|
20
37
|
end
|
21
38
|
end
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sideband
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
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
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: minitest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 5.0.8
|
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: 5.0.8
|
41
41
|
description: Run simple workers in a separate thread
|
42
42
|
email:
|
43
43
|
- mike@urlgonomics.com
|
@@ -45,8 +45,8 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
-
- .gitignore
|
49
|
-
- .travis.yml
|
48
|
+
- ".gitignore"
|
49
|
+
- ".travis.yml"
|
50
50
|
- Gemfile
|
51
51
|
- LICENSE.txt
|
52
52
|
- README.md
|
@@ -73,17 +73,17 @@ require_paths:
|
|
73
73
|
- lib
|
74
74
|
required_ruby_version: !ruby/object:Gem::Requirement
|
75
75
|
requirements:
|
76
|
-
- -
|
76
|
+
- - ">="
|
77
77
|
- !ruby/object:Gem::Version
|
78
78
|
version: '0'
|
79
79
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- -
|
81
|
+
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
84
|
requirements: []
|
85
85
|
rubyforge_project:
|
86
|
-
rubygems_version: 2.
|
86
|
+
rubygems_version: 2.4.5
|
87
87
|
signing_key:
|
88
88
|
specification_version: 4
|
89
89
|
summary: Run simple workers in a separate thread
|
@@ -94,4 +94,3 @@ test_files:
|
|
94
94
|
- test/test_sideband.rb
|
95
95
|
- test/test_thread.rb
|
96
96
|
- test/test_worker.rb
|
97
|
-
has_rdoc:
|