always 0.0.2 → 0.0.3

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
  SHA256:
3
- metadata.gz: 1d5c02ea320168984342dcf8805da07bec45d9a685097400c9f3e406a75a96b9
4
- data.tar.gz: 0db1ae1c2006db2de79982172f8fd7cc1d53e3fb8dfaffc8e474ea5972139224
3
+ metadata.gz: ed19cd7a3109c141b0537f2229876cc00f5d0a70740095b810b281c47fe44834
4
+ data.tar.gz: 793763757135f8492edb8bb6b6abb6b9ee19459c7e35d3acde3ac13f0c97a230
5
5
  SHA512:
6
- metadata.gz: 628d7ddcbc48d5e1b87adcccb7446a60c0ec1b4f1e047ee85b9a3188f76e3dbd42de40d384fc7e4f84de21c750ba26312b136d63a1248b575a1d3c2d68430a0a
7
- data.tar.gz: d9e259a904b1785543bb0282f026b0ee08e7ec1b641ee2243bd23d063a99df90b9dc69c69438f6d36f09bc7351a893b32581d0f475b7761d9997d7f112afa75a
6
+ metadata.gz: 3c09324fe351d257d252e466e9be7d263ffb0e9781d1134b777ae207ee0321779273b82771d595fad47f4ca67ed2bebbc4a8864758c0f522f0233f66b5745b79
7
+ data.tar.gz: 44c0a7f8d9117e69845c58577b6f40ccd29f7292e07c9df0cc18a05870a3fb4b5795c85cc0bfcd5434c543ed5575a081b35de6cc7a402ef59d70459ac87659de
data/always.gemspec CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
26
26
  s.required_rubygems_version = Gem::Requirement.new('>= 0') if s.respond_to? :required_rubygems_version=
27
27
  s.required_ruby_version = '>=3.2'
28
28
  s.name = 'always'
29
- s.version = '0.0.2'
29
+ s.version = '0.0.3'
30
30
  s.license = 'MIT'
31
31
  s.summary = 'A simple Ruby framework that spins a loop forever, in a background thread'
32
32
  s.description =
data/lib/always.rb CHANGED
@@ -44,7 +44,7 @@ require 'concurrent/atom'
44
44
  # License:: MIT
45
45
  class Always
46
46
  # The version of the framework.
47
- VERSION = '0.0.2'
47
+ VERSION = '0.0.3'
48
48
 
49
49
  # Constructor.
50
50
  # @param [Integer] total The number of threads to run
@@ -78,12 +78,12 @@ class Always
78
78
 
79
79
  # Start them all.
80
80
  # @param [Integer] pause The delay between cycles, in seconds
81
- def start(pause = 0)
81
+ def start(pause = 0, &)
82
82
  raise 'It is running now, call .stop() first' unless @threads.empty?
83
83
 
84
84
  (0..@total - 1).each do |i|
85
85
  @threads[i] = Thread.new do
86
- body(i, pause)
86
+ body(i, pause, &)
87
87
  @cycles.swap { |c| c + 1 }
88
88
  end
89
89
  end
data/test/test_always.rb CHANGED
@@ -55,4 +55,15 @@ class TestAlways < Minitest::Test
55
55
  assert(a.to_s.start_with?('5/'))
56
56
  a.stop
57
57
  end
58
+
59
+ def test_with_counter
60
+ a = Always.new(1)
61
+ done = 0
62
+ a.start do
63
+ done += 1
64
+ end
65
+ sleep(0.1)
66
+ a.stop
67
+ assert(done.positive?)
68
+ end
58
69
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: always
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko