casbin-ruby 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/casbin-ruby/util/thread_lock.rb +4 -2
- data/lib/casbin-ruby/version.rb +1 -1
- data/spec/casbin/util/thread_lock_spec.rb +17 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28a62b747911baa032114d99d6ac547a5e10a6661e9c73dddb756db0331dd8d9
|
4
|
+
data.tar.gz: dc9c0f3b7651fdff49f5effa17282139c083eac30f176b3544cb75aabe174a38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23a694c48da847813dd0632fef4bdebf5f1a982a7610489453bf7b545edd429b26f125d085879dcd2dc5f3737e8b167c6678bf1e3b9bb2afba951ecdfe920c54
|
7
|
+
data.tar.gz: 4a2dc386dac66769e86836c3ab84ce687e53c7e0f6962dc2f4e136cf8d16d21d1554e7b355c8913a6c7f4b4c35b9d94a66102b5ce9ef5817ec8ced25f02a1240
|
@@ -1,12 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'singleton'
|
4
|
+
require 'forwardable'
|
4
5
|
|
5
6
|
class ThreadLock
|
6
7
|
include Singleton
|
7
8
|
|
8
9
|
class << self
|
9
|
-
|
10
|
+
extend Forwardable
|
11
|
+
def_delegators :instance, :thread=, :thread, :lock?
|
10
12
|
end
|
11
13
|
|
12
14
|
attr_accessor :thread
|
@@ -14,6 +16,6 @@ class ThreadLock
|
|
14
16
|
def lock?
|
15
17
|
return false unless thread
|
16
18
|
|
17
|
-
thread.
|
19
|
+
thread.alive?
|
18
20
|
end
|
19
21
|
end
|
data/lib/casbin-ruby/version.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'casbin-ruby/util/thread_lock'
|
4
|
+
|
5
|
+
describe ThreadLock do
|
6
|
+
it '#lock? with no thread' do
|
7
|
+
expect(described_class).not_to be_lock
|
8
|
+
end
|
9
|
+
|
10
|
+
it '#lock? with thread' do
|
11
|
+
described_class.thread = Thread.new { loop }
|
12
|
+
expect(described_class).to be_lock
|
13
|
+
described_class.thread.exit
|
14
|
+
sleep 0.001 # waiting exit
|
15
|
+
expect(described_class).not_to be_lock
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: casbin-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Kutyavin
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-05-
|
12
|
+
date: 2021-05-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: keisan
|
@@ -113,6 +113,7 @@ files:
|
|
113
113
|
- spec/casbin/rbac/default_role_manager/role_manager_spec.rb
|
114
114
|
- spec/casbin/rbac/default_role_manager/role_spec.rb
|
115
115
|
- spec/casbin/util/builtin_operators_spec.rb
|
116
|
+
- spec/casbin/util/thread_lock_spec.rb
|
116
117
|
- spec/casbin/util_spec.rb
|
117
118
|
- spec/support/model_helper.rb
|
118
119
|
homepage: https://github.com/evrone/casbin-ruby
|
@@ -146,6 +147,7 @@ test_files:
|
|
146
147
|
- spec/casbin/rbac/default_role_manager/role_spec.rb
|
147
148
|
- spec/casbin/rbac/default_role_manager/role_manager_spec.rb
|
148
149
|
- spec/casbin/config/config_spec.rb
|
150
|
+
- spec/casbin/util/thread_lock_spec.rb
|
149
151
|
- spec/casbin/util/builtin_operators_spec.rb
|
150
152
|
- spec/casbin/util_spec.rb
|
151
153
|
- spec/support/model_helper.rb
|