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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e5dcf753ca6d3cd3a7f67785308963896f58b1fe
4
- data.tar.gz: 61098cce70008cdc16cabf43d579800a4b246a8f
3
+ metadata.gz: 6dcd1add7c9bf599343ed7d5f8c4efe4ff556418
4
+ data.tar.gz: 3ef16a42eb4ee99671c0e74afe1c0e7c2cbd177d
5
5
  SHA512:
6
- metadata.gz: fde0cfb008a6406d2ed9fcbc4ad7d31b304af26f5475cabd37bd0d13f614909a5c37a37369b5d4155ed0a1ffc18a5751ab2b5e6ddcbfd927482334e9d5761533
7
- data.tar.gz: f47a574a0c17145a536cf5d8ba23660d05a103cae7ec873e1b12c822094775017e9baaab574509856bcfb19999d7221cb0da7c7f58eb2762e55c5380f2c5e7fb
6
+ metadata.gz: b3faaa239f15d4420e9e80bc446090663848c776cb433f07145118804d8f3891cc569ee694291ea58ae7391ffc15fdd1f43c6335cf89ce3f992b9f571aa4ae76
7
+ data.tar.gz: e641bc9a987b9f628858828df0eed5f2db6c1a96c2816dcec171574ba52bde76aa61a0d0a0a09507d791cd52d6402ee8b3853ec58a417bd6b9d822833f69ed4f
@@ -3,4 +3,4 @@ rvm:
3
3
  - 1.9.3
4
4
  - 2.0.0
5
5
  - jruby-19mode
6
- - rbx-19mode
6
+ - jruby-20mode
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
+
@@ -47,7 +47,7 @@ module Sideband
47
47
  end
48
48
 
49
49
  def handle_dead_thread
50
- if @thread && @thread.thread.alive?
50
+ unless (@thread && @thread.thread.alive?)
51
51
  thread!
52
52
  end
53
53
  end
@@ -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
- while @manager.queue && work = @manager.queue.pop
10
- exit if work.nil?
11
-
12
- begin
13
- work.call
14
- rescue Exception
15
- # Sideband will ignore all Exceptions,
16
- # better to handle in your workers.
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
@@ -1,3 +1,3 @@
1
1
  module Sideband
2
- VERSION = '1.0.3'
2
+ VERSION = '1.0.4'
3
3
  end
@@ -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', '~> 4.6.2'
21
+ gem.add_development_dependency 'minitest', '>= 5.0.8'
22
22
  end
@@ -46,7 +46,7 @@ class TestManager < Minitest::Test
46
46
 
47
47
  def test_killed
48
48
  @manager.kill
49
- assert_nil @manager.queue
49
+ assert_nil @manager.instance_variable_get(:@queue)
50
50
  assert_nil @manager.thread
51
51
  end
52
52
 
@@ -7,15 +7,32 @@ class TestSideband < Minitest::Test
7
7
  end
8
8
 
9
9
  def test_has_queue
10
- Sideband.initialize! do
11
- assert_kind_of Sideband::Queue, Sideband.queue
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! do
17
- assert Sideband.queue(-> { 'work' })
18
- assert Sideband.enqueue(-> { 'work' })
19
- end
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.3
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: 2013-11-25 00:00:00.000000000 Z
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: 4.6.2
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: 4.6.2
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.0.7
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: