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 +4 -4
- data/.rultor.yml +1 -1
- data/lib/syncem.rb +3 -1
- data/syncem.gemspec +1 -1
- data/test/test_syncem.rb +18 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5761e6992463f8579483a2b08eceec8a322aaac1e7474a77b161a47919655311
|
4
|
+
data.tar.gz: 825171250d56b5e20e4b139058b4cfddf44edc8882dcced73ac71f2fe72994c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41b7696bbb9cd74832e1e6c0cc6255ef3d3c0d815d3c177aa51cbfb449f1d3985ca25065c0ab36aea39d9e4e25b5d078d813a7a0bbedea4b58ac0a6c09217679
|
7
|
+
data.tar.gz: adce504a8e497df4b2bbb372a5c9dc19e64003c81d523778d4b459e6cb16b978e59cb708ce6a7bc943213bdfdb5888c30df72f197772122ec9236b29ff14d509
|
data/.rultor.yml
CHANGED
data/lib/syncem.rb
CHANGED
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.
|
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.
|
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-
|
11
|
+
date: 2019-04-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|