syncem 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b7d113c834d559321aeaa30fa6f9da68bb49f26b83e2309196fda47e70656a82
4
- data.tar.gz: 277e6dd0a02a58113dc3aed41aeb250ebc0629c1d804f7a77050c2e2c3789908
3
+ metadata.gz: 5761e6992463f8579483a2b08eceec8a322aaac1e7474a77b161a47919655311
4
+ data.tar.gz: 825171250d56b5e20e4b139058b4cfddf44edc8882dcced73ac71f2fe72994c8
5
5
  SHA512:
6
- metadata.gz: efff7adc096e2036d36176221755cbcf353af7213f39eb03c211832fe7e0ed3ebbc7363585158cddaf320ac8d3f8901a42139cda770bddd50e3bfbb9f5f9ffa6
7
- data.tar.gz: d7183f7a4731ef650f9909401f2b02712a001f6b06cc5685f8a783fdaacf692de0b0386fb26c57ba7c7583e61d8e67adbf84cc3eb3d848831e5125af1f8c5e22
6
+ metadata.gz: 41b7696bbb9cd74832e1e6c0cc6255ef3d3c0d815d3c177aa51cbfb449f1d3985ca25065c0ab36aea39d9e4e25b5d078d813a7a0bbedea4b58ac0a6c09217679
7
+ data.tar.gz: adce504a8e497df4b2bbb372a5c9dc19e64003c81d523778d4b459e6cb16b978e59cb708ce6a7bc943213bdfdb5888c30df72f197772122ec9236b29ff14d509
data/.rultor.yml CHANGED
@@ -6,7 +6,7 @@ install: |-
6
6
  release:
7
7
  script: |-
8
8
  bundle install
9
- rake
9
+ bundle exec rake
10
10
  rm -rf *.gem
11
11
  sed -i "s/0\.0\.0/${tag}/g" syncem.gemspec
12
12
  git add syncem.gemspec
data/lib/syncem.rb CHANGED
@@ -40,7 +40,9 @@ class SyncEm
40
40
  def method_missing(*args)
41
41
  @mutex.synchronize do
42
42
  if @origin.respond_to?(args[0])
43
- @origin.send(*args)
43
+ @origin.send(*args) do |*a|
44
+ yield(*a) if block_given?
45
+ end
44
46
  else
45
47
  super
46
48
  end
data/syncem.gemspec CHANGED
@@ -31,7 +31,7 @@ Gem::Specification.new do |s|
31
31
  s.rubygems_version = '2.3.3'
32
32
  s.required_ruby_version = '>=2.3'
33
33
  s.name = 'syncem'
34
- s.version = '0.1.0'
34
+ s.version = '0.1.1'
35
35
  s.license = 'MIT'
36
36
  s.summary = 'Thread-safe decorator of Ruby objects'
37
37
  s.description = 'Sometimes you have an object that is not thread-safe,
data/test/test_syncem.rb CHANGED
@@ -44,6 +44,10 @@ class SyncEmTest < Minitest::Test
44
44
  now = File.exist?(@file) ? IO.read(@file).to_i : 0
45
45
  IO.write(@file, (now + amount).to_s)
46
46
  end
47
+
48
+ def read
49
+ yield balance
50
+ end
47
51
  end
48
52
 
49
53
  def test_wraps_simple_object
@@ -67,6 +71,20 @@ class SyncEmTest < Minitest::Test
67
71
  end
68
72
  end
69
73
 
74
+ def test_works_with_block
75
+ Dir.mktmpdir do |dir|
76
+ path = File.join(dir, 'f.txt')
77
+ acc = SyncEm.new(Account.new(path))
78
+ acc.add(50)
79
+ before = 0
80
+ acc.read do |b|
81
+ assert_equal(50, b)
82
+ before = b
83
+ end
84
+ assert_equal(50, before)
85
+ end
86
+ end
87
+
70
88
  def test_multiple_threads
71
89
  Dir.mktmpdir do |dir|
72
90
  path = File.join(dir, 'f.txt')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: syncem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-06 00:00:00.000000000 Z
11
+ date: 2019-04-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest