instance_storage 1.0.0 → 2.0.0

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
- SHA1:
3
- metadata.gz: 2ab3fca4c92a0d5c88ff4fff5751feda09592ede
4
- data.tar.gz: db4128fe44f81bd8895e9c9b3c38fe695047d034
2
+ SHA256:
3
+ metadata.gz: b4414e48f6f8a3205350ec9bf2d2dd9ccacdf7fd3270bb7839653ec7da1aa584
4
+ data.tar.gz: 650d26f71f71fc5a2d127e655f68dd403bd7a1d89a8047d947e457f2251c6486
5
5
  SHA512:
6
- metadata.gz: 747dabd4ac2cc2c925fc0127422bf350455d032ba79f9177b8cd29f8cef6ff4051ef9d9264923a93f714ad3046b9883e25e775feb7241d84cae51995d507a367
7
- data.tar.gz: 6b590975c1845dba1ce2db36b315c35835332d7b57b384c1d5aefeb45f6375e02201a26728c64838a9453506faac5fc48c9e2555a177eafa400701713125bbec
6
+ metadata.gz: c738539fb9d881e5da97c3211a7b9b8bb4bff30b0a26802f67b3c6af92d266dd38579f021f071e73566c523d8207cb576c13c52e0d2e2736ffa2f22ec0c70081
7
+ data.tar.gz: ee0954e2c469b8ec7dae217cd32ec623aa724442537d50289331e536fecc2e45a4ab4433eda087c6b6ea90a394d436bb633c2b4dc60abf8646a5d5fb9b79e59e
data/Steepfile ADDED
@@ -0,0 +1,22 @@
1
+ target :lib do
2
+ signature "sig"
3
+ check "lib" # Directory name
4
+ # check "Gemfile" # File name
5
+ # ignore "lib/templates/*.rb"
6
+ # library "pathname", "set" # Standard libraries
7
+ # library "strong_json" # Gems
8
+ end
9
+
10
+ target :test do
11
+ signature "sig"
12
+ check "test"
13
+ end
14
+
15
+ # target :spec do
16
+ # signature "sig", "sig-private"
17
+ #
18
+ # check "spec"
19
+ #
20
+ # # library "pathname", "set" # Standard libraries
21
+ # # library "rspec"
22
+ # end
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["toshi.alternative@gmail.com"]
11
11
  spec.summary = %q{Manage class instances with dictionary}
12
12
  spec.description = %q{Manage class instances with dictionary.}
13
- spec.homepage = ""
13
+ spec.homepage = "https://github.com/toshia/instance_storage"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0")
@@ -18,7 +18,9 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.7"
22
- spec.add_development_dependency "rake", "~> 10.0"
23
- spec.add_development_dependency "minitest"
21
+ spec.required_ruby_version = '>= 2.6.0'
22
+
23
+ spec.add_development_dependency "bundler", "~> 2.0"
24
+ spec.add_development_dependency "rake", "~> 13.0"
25
+ spec.add_development_dependency "minitest", "~> 5.1"
24
26
  end
@@ -18,7 +18,7 @@ module InstanceStorage
18
18
  end
19
19
 
20
20
  def initialize(name)
21
- @name = name end
21
+ @name = name.to_sym end
22
22
 
23
23
  # 名前を文字列にして返す
24
24
  # ==== Return
@@ -35,7 +35,9 @@ module InstanceStorage
35
35
 
36
36
  # 定義されているインスタンスを全て削除する
37
37
  def clear!
38
- @instances = @storage_lock = nil end
38
+ @instances = nil
39
+ self
40
+ end
39
41
 
40
42
  # インスタンス _event_name_ を返す。既に有る場合はそのインスタンス、ない場合は新しく作って返す。
41
43
  # ==== Args
@@ -82,6 +84,8 @@ module InstanceStorage
82
84
  instances_dict[name.to_sym] end
83
85
 
84
86
  def destroy(name)
85
- instances_dict.delete(name.to_sym) end
87
+ instances_dict.delete(name.to_sym)
88
+ self
89
+ end
86
90
  end
87
91
  end
@@ -1,3 +1,3 @@
1
1
  module InstanceStorage
2
- VERSION = "1.0.0"
2
+ VERSION = "2.0.0"
3
3
  end
@@ -0,0 +1,29 @@
1
+ # TypeProf 0.13.0
2
+
3
+ # Classes
4
+ module InstanceStorage
5
+ VERSION: String
6
+ extend InstanceStorageExtend
7
+
8
+ attr_reader name: Symbol
9
+ alias to_sym name
10
+ def self.included: (Class) -> void
11
+ def initialize: (Symbol|String) -> void
12
+ def to_s: -> String
13
+
14
+ module InstanceStorageExtend
15
+ @instances: Hash[Symbol, self]?
16
+ @storage_lock: Thread::Mutex?
17
+
18
+ def instances_dict: -> Hash[Symbol, self]
19
+ def storage_lock: -> Thread::Mutex
20
+ def clear!: -> self
21
+ def []: (Symbol|String) -> self
22
+ def instances: -> Array[self]
23
+ def instances_name: -> Array[Symbol]
24
+ def instance_exist?: (Symbol|String) -> bool
25
+ def instance: (Symbol|String) -> self
26
+ def destroy: (Symbol|String) -> self
27
+ def new: (Symbol|String) -> self
28
+ end
29
+ end
@@ -5,23 +5,22 @@ require 'minitest/autorun'
5
5
 
6
6
  require 'instance_storage'
7
7
 
8
- describe(InstanceStorage) do
9
-
10
- it 'get and create instance' do
8
+ class InstanceStorageTest < MiniTest::Unit::TestCase
9
+ def test_get_and_create_instance
11
10
  klass = Class.new do
12
11
  include InstanceStorage end
13
12
  assert_same(klass[:foo], klass[:foo])
14
13
  refute_same(klass[:foo], klass[:bar])
15
14
  end
16
15
 
17
- it "get all instances" do
16
+ def test_get_all_instances
18
17
  klass = Class.new do
19
18
  include InstanceStorage end
20
19
  assert_equal([], klass.instances)
21
20
  assert_equal([klass[:a], klass[:b]], klass.instances)
22
21
  end
23
22
 
24
- it "get all instances name" do
23
+ def test_get_all_instances_name
25
24
  klass = Class.new do
26
25
  include InstanceStorage end
27
26
  assert_equal([], klass.instances_name)
@@ -30,7 +29,7 @@ describe(InstanceStorage) do
30
29
  assert_equal([:a, :b], klass.instances_name)
31
30
  end
32
31
 
33
- it "destroy instance" do
32
+ def test_destroy_instance
34
33
  klass = Class.new do
35
34
  include InstanceStorage end
36
35
  klass[:a]
@@ -39,14 +38,14 @@ describe(InstanceStorage) do
39
38
  assert(! klass.instance_exist?(:a))
40
39
  end
41
40
 
42
- it "get existing instance" do
41
+ def test_get_existing_instance
43
42
  klass = Class.new do
44
43
  include InstanceStorage end
45
44
  assert_nil(klass.instance(:a))
46
45
  assert_equal(klass[:a], klass.instance(:a))
47
46
  end
48
47
 
49
- it "should support inherited class" do
48
+ def test_should_support_inherited_class
50
49
  klass = Class.new do
51
50
  include InstanceStorage end
52
51
  child = Class.new(klass)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: instance_storage
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toshiaki Asai
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-03 00:00:00.000000000 Z
11
+ date: 2021-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.7'
19
+ version: '2.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.7'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '13.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '5.1'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '5.1'
55
55
  description: Manage class instances with dictionary.
56
56
  email:
57
57
  - toshi.alternative@gmail.com
@@ -64,15 +64,17 @@ files:
64
64
  - LICENSE.txt
65
65
  - README.md
66
66
  - Rakefile
67
+ - Steepfile
67
68
  - instance_storage.gemspec
68
69
  - lib/instance_storage.rb
69
70
  - lib/instance_storage/version.rb
71
+ - sig/instance_storage.rbs
70
72
  - test/instance_storage_test.rb
71
- homepage: ''
73
+ homepage: https://github.com/toshia/instance_storage
72
74
  licenses:
73
75
  - MIT
74
76
  metadata: {}
75
- post_install_message:
77
+ post_install_message:
76
78
  rdoc_options: []
77
79
  require_paths:
78
80
  - lib
@@ -80,16 +82,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
80
82
  requirements:
81
83
  - - ">="
82
84
  - !ruby/object:Gem::Version
83
- version: '0'
85
+ version: 2.6.0
84
86
  required_rubygems_version: !ruby/object:Gem::Requirement
85
87
  requirements:
86
88
  - - ">="
87
89
  - !ruby/object:Gem::Version
88
90
  version: '0'
89
91
  requirements: []
90
- rubyforge_project:
91
- rubygems_version: 2.4.5
92
- signing_key:
92
+ rubygems_version: 3.2.13
93
+ signing_key:
93
94
  specification_version: 4
94
95
  summary: Manage class instances with dictionary
95
96
  test_files: