singleton 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +6 -0
- data/.github/workflows/test.yml +28 -0
- data/README.md +1 -1
- data/lib/singleton.rb +7 -12
- data/singleton.gemspec +12 -7
- metadata +9 -8
- data/.travis.yml +0 -7
- data/lib/singleton/version.rb +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9dfa8197e311e8c51f00bf57763bb8b50310208e6a99a7baa3a60c874620956
|
4
|
+
data.tar.gz: 68f60f4bcdcd68a06c39f72a1960a29a7c378a1e14ec419fcbcfa9c51e811399
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0160a2ea66e1a2a8f05a0f49bf03be28a0b5bb05999014006855078dfc2143cab53f33ac686fb39dbe4de1318b60873526239d0cc802f6700064d206dffdfe0
|
7
|
+
data.tar.gz: 489e9e5984d81dc8e7bc848d308c5bfd82774ea88e13cc26ef2e8daa8ac23d7928ab562adcad1b0d92e74e2b1ae8613f94d86a7f9ffe1fa73c0fba9e64cf3619
|
@@ -0,0 +1,28 @@
|
|
1
|
+
name: test
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
ruby-versions:
|
7
|
+
uses: ruby/actions/.github/workflows/ruby_versions.yml@master
|
8
|
+
with:
|
9
|
+
engine: cruby
|
10
|
+
min_version: 2.4
|
11
|
+
test:
|
12
|
+
needs: ruby-versions
|
13
|
+
name: build (${{ matrix.ruby }} / ${{ matrix.os }})
|
14
|
+
strategy:
|
15
|
+
matrix:
|
16
|
+
ruby: ${{ fromJson(needs.ruby-versions.outputs.versions) }}
|
17
|
+
os: [ ubuntu-latest, macos-latest ]
|
18
|
+
runs-on: ${{ matrix.os }}
|
19
|
+
steps:
|
20
|
+
- uses: actions/checkout@v4
|
21
|
+
- name: Set up Ruby
|
22
|
+
uses: ruby/setup-ruby@v1
|
23
|
+
with:
|
24
|
+
ruby-version: ${{ matrix.ruby }}
|
25
|
+
- name: Install dependencies
|
26
|
+
run: bundle install
|
27
|
+
- name: Run test
|
28
|
+
run: rake test
|
data/README.md
CHANGED
data/lib/singleton.rb
CHANGED
@@ -13,7 +13,7 @@
|
|
13
13
|
#
|
14
14
|
# This ensures that only one instance of Klass can be created.
|
15
15
|
#
|
16
|
-
# a,b
|
16
|
+
# a,b = Klass.instance, Klass.instance
|
17
17
|
#
|
18
18
|
# a == b
|
19
19
|
# # => true
|
@@ -58,10 +58,9 @@
|
|
58
58
|
# == Singleton and Marshal
|
59
59
|
#
|
60
60
|
# By default Singleton's #_dump(depth) returns the empty string. Marshalling by
|
61
|
-
# default will strip state information, e.g. instance variables
|
62
|
-
#
|
63
|
-
#
|
64
|
-
# the instance.
|
61
|
+
# default will strip state information, e.g. instance variables from the instance.
|
62
|
+
# Classes using Singleton can provide custom _load(str) and _dump(depth) methods
|
63
|
+
# to retain some of the previous state of the instance.
|
65
64
|
#
|
66
65
|
# require 'singleton'
|
67
66
|
#
|
@@ -82,7 +81,6 @@
|
|
82
81
|
# a = Example.instance
|
83
82
|
# a.keep = "keep this"
|
84
83
|
# a.strip = "get rid of this"
|
85
|
-
# a.taint
|
86
84
|
#
|
87
85
|
# stored_state = Marshal.dump(a)
|
88
86
|
#
|
@@ -94,6 +92,8 @@
|
|
94
92
|
# p a.strip # => nil
|
95
93
|
#
|
96
94
|
module Singleton
|
95
|
+
VERSION = "0.2.0"
|
96
|
+
|
97
97
|
# Raises a TypeError to prevent cloning.
|
98
98
|
def clone
|
99
99
|
raise TypeError, "can't clone instance of singleton #{self.class}"
|
@@ -121,12 +121,7 @@ module Singleton
|
|
121
121
|
end
|
122
122
|
|
123
123
|
def instance # :nodoc:
|
124
|
-
|
125
|
-
@singleton__mutex__.synchronize {
|
126
|
-
return @singleton__instance__ if @singleton__instance__
|
127
|
-
@singleton__instance__ = new()
|
128
|
-
}
|
129
|
-
@singleton__instance__
|
124
|
+
@singleton__instance__ || @singleton__mutex__.synchronize { @singleton__instance__ ||= new }
|
130
125
|
end
|
131
126
|
|
132
127
|
private
|
data/singleton.gemspec
CHANGED
@@ -1,23 +1,28 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
name = File.basename(__FILE__, ".gemspec")
|
4
|
+
version = ["lib", Array.new(name.count("-")+1, ".").join("/")].find do |dir|
|
5
|
+
break File.foreach(File.join(__dir__, dir, "#{name.tr('-', '/')}.rb")) do |line|
|
6
|
+
/^\s*VERSION\s*=\s*"(.*)"/ =~ line and break $1
|
7
|
+
end rescue nil
|
8
|
+
end
|
4
9
|
|
5
10
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name =
|
7
|
-
spec.version =
|
11
|
+
spec.name = name
|
12
|
+
spec.version = version
|
8
13
|
spec.authors = ["Yukihiro Matsumoto"]
|
9
14
|
spec.email = ["matz@ruby-lang.org"]
|
10
15
|
|
11
16
|
spec.summary = %q{The Singleton module implements the Singleton pattern.}
|
12
17
|
spec.description = spec.summary
|
13
18
|
spec.homepage = "https://github.com/ruby/singleton"
|
14
|
-
spec.
|
19
|
+
spec.licenses = ["Ruby", "BSD-2-Clause"]
|
15
20
|
|
16
21
|
spec.metadata["homepage_uri"] = spec.homepage
|
17
22
|
spec.metadata["source_code_uri"] = spec.homepage
|
18
23
|
|
19
24
|
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
20
|
-
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
`git ls-files -z 2>#{IO::NULL}`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
21
26
|
end
|
22
27
|
spec.bindir = "exe"
|
23
28
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: singleton
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yukihiro Matsumoto
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: The Singleton module implements the Singleton pattern.
|
14
14
|
email:
|
@@ -17,8 +17,9 @@ executables: []
|
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
+
- ".github/dependabot.yml"
|
21
|
+
- ".github/workflows/test.yml"
|
20
22
|
- ".gitignore"
|
21
|
-
- ".travis.yml"
|
22
23
|
- Gemfile
|
23
24
|
- LICENSE.txt
|
24
25
|
- README.md
|
@@ -26,15 +27,15 @@ files:
|
|
26
27
|
- bin/console
|
27
28
|
- bin/setup
|
28
29
|
- lib/singleton.rb
|
29
|
-
- lib/singleton/version.rb
|
30
30
|
- singleton.gemspec
|
31
31
|
homepage: https://github.com/ruby/singleton
|
32
32
|
licenses:
|
33
|
+
- Ruby
|
33
34
|
- BSD-2-Clause
|
34
35
|
metadata:
|
35
36
|
homepage_uri: https://github.com/ruby/singleton
|
36
37
|
source_code_uri: https://github.com/ruby/singleton
|
37
|
-
post_install_message:
|
38
|
+
post_install_message:
|
38
39
|
rdoc_options: []
|
39
40
|
require_paths:
|
40
41
|
- lib
|
@@ -49,8 +50,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
49
50
|
- !ruby/object:Gem::Version
|
50
51
|
version: '0'
|
51
52
|
requirements: []
|
52
|
-
rubygems_version: 3.0.
|
53
|
-
signing_key:
|
53
|
+
rubygems_version: 3.5.0.dev
|
54
|
+
signing_key:
|
54
55
|
specification_version: 4
|
55
56
|
summary: The Singleton module implements the Singleton pattern.
|
56
57
|
test_files: []
|
data/.travis.yml
DELETED
data/lib/singleton/version.rb
DELETED