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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52a08bf07cc4d7925f0e23993f1745f1cf69585ba941138c12f88ca3498705b1
4
- data.tar.gz: 1db55f6ab3c6e853ae2f84271b08f1c67d795ea5c86afb9e7b84d94091dd9ddc
3
+ metadata.gz: 28a62b747911baa032114d99d6ac547a5e10a6661e9c73dddb756db0331dd8d9
4
+ data.tar.gz: dc9c0f3b7651fdff49f5effa17282139c083eac30f176b3544cb75aabe174a38
5
5
  SHA512:
6
- metadata.gz: 3eaa9572203f449d6b653d725a05ef7c59f42bc9cd34d3ee7ef55afe63f1a933951934a63131aa0b7eb4d117b524f105561ce84e805a9617df976e35a3894ab4
7
- data.tar.gz: dcc181227a68e920b78b705eb018a0b23a69417e8408c6014a2c22c05243ac08787a518efa73918e4266291c3a8f6b52dbd3ad2ce4ffb4b40743cdd0e0e0a2dd
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
- delegate :thread=, :lock?, to: :instance
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.active?
19
+ thread.alive?
18
20
  end
19
21
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Casbin
4
- VERSION = '1.0.4'
4
+ VERSION = '1.0.5'
5
5
  end
@@ -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
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-13 00:00:00.000000000 Z
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