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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 69ce5ea038b9a035ac62e61824f08b9e6d806e26309f5666b6bdbd778baeb385
4
- data.tar.gz: 02e3504ffb6547ce784ccd4579f4b4e2cd0f0deddedc228f3c390bfee202240f
3
+ metadata.gz: b9dfa8197e311e8c51f00bf57763bb8b50310208e6a99a7baa3a60c874620956
4
+ data.tar.gz: 68f60f4bcdcd68a06c39f72a1960a29a7c378a1e14ec419fcbcfa9c51e811399
5
5
  SHA512:
6
- metadata.gz: 80e0df606115bfde6d963d4511664c1862d924dd3f6678a1368cd12290c144dc43ede2a62f3abd3bf8be294d9e72e99f0da42611aa9e0c9c298141acd426faf3
7
- data.tar.gz: e3a735efe724e487dc4f032c2b0f67a9fc1b2fd2840ff8c5840ffedd46c0889906e213a6946dc27f2bdcedab72e9067a1f188de55b003d8c34216781eca1318f
6
+ metadata.gz: b0160a2ea66e1a2a8f05a0f49bf03be28a0b5bb05999014006855078dfc2143cab53f33ac686fb39dbe4de1318b60873526239d0cc802f6700064d206dffdfe0
7
+ data.tar.gz: 489e9e5984d81dc8e7bc848d308c5bfd82774ea88e13cc26ef2e8daa8ac23d7928ab562adcad1b0d92e74e2b1ae8613f94d86a7f9ffe1fa73c0fba9e64cf3619
@@ -0,0 +1,6 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: 'github-actions'
4
+ directory: '/'
5
+ schedule:
6
+ interval: 'weekly'
@@ -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
@@ -32,7 +32,7 @@ end
32
32
  This ensures that only one instance of Klass can be created.
33
33
 
34
34
  ```ruby
35
- a,b = Klass.instance, Klass.instance
35
+ a,b = Klass.instance, Klass.instance
36
36
 
37
37
  a == b
38
38
  # => true
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 = Klass.instance, Klass.instance
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 and taint
62
- # state, from the instance. Classes using Singleton can provide custom
63
- # _load(str) and _dump(depth) methods to retain some of the previous state of
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
- return @singleton__instance__ if @singleton__instance__
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
- lib = File.expand_path("lib", __dir__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require "singleton/version"
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 = "singleton"
7
- spec.version = Singleton::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.license = "BSD-2-Clause"
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.1.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: 2019-11-06 00:00:00.000000000 Z
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.3
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
@@ -1,7 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.6.3
7
- before_install: gem install bundler -v 2.0.2
@@ -1,3 +0,0 @@
1
- module Singleton
2
- VERSION = "0.1.0"
3
- end