init_copy 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rdoc_options +1 -0
- data/Gemfile +4 -4
- data/README.md +23 -14
- data/Rakefile +1 -1
- data/init_copy.gemspec +2 -3
- data/lib/init_copy/version.rb +13 -0
- data/lib/init_copy.rb +5 -25
- data/test/init_copy_test.rb +143 -148
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2ea381fdf2b5c0bec710f2b219f87e2f897e8bba17246591982617e02a5024c
|
4
|
+
data.tar.gz: c33f202bb2301400918c86fc49a8acf0a43be8f82f5e7e2df1dc6ca9935fc4c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36b93091f59641bf0ea2fc2a7c520815f285e24aa5136d7e03c1e837811084f2b62e6040f82e98a1facd9e6b0930834558f7df7783cfe01a60a17b20d99152c9
|
7
|
+
data.tar.gz: fb2e3f6d74272af1061f73794814874bdb7d76f16c7998fdd9cfd41d1c5d17a7eda9985a0e0724be9fa16e1a55ba64f557ae431d93eff9a2637fc6bffab1312f
|
data/.rdoc_options
CHANGED
data/Gemfile
CHANGED
@@ -6,11 +6,11 @@ source 'https://rubygems.org'
|
|
6
6
|
gemspec
|
7
7
|
|
8
8
|
group :development,:test do
|
9
|
-
gem 'bundler'
|
10
|
-
gem 'rake'
|
11
|
-
gem 'rdoc'
|
9
|
+
gem 'bundler' ,'~> 2.6 '
|
10
|
+
gem 'rake' ,'~> 13.3 '
|
11
|
+
gem 'rdoc' ,'~> 6.14'
|
12
12
|
end
|
13
13
|
|
14
14
|
group :test do
|
15
|
-
gem 'minitest'
|
15
|
+
gem 'minitest','~> 5.25'
|
16
16
|
end
|
data/README.md
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
[](https://badge.fury.io/rb/init_copy)
|
4
4
|
[](https://github.com/esotericpig/init_copy/actions/workflows/ci.yml)
|
5
|
-
|
6
5
|
[](https://github.com/esotericpig/init_copy)
|
7
6
|
[](CHANGELOG.md)
|
8
7
|
[](LICENSE.txt)
|
@@ -18,6 +17,7 @@ module SecretExt
|
|
18
17
|
end
|
19
18
|
end
|
20
19
|
|
20
|
+
# Init vars.
|
21
21
|
bob = 'Bob'
|
22
22
|
bob.extend(SecretExt)
|
23
23
|
bob.freeze
|
@@ -25,6 +25,7 @@ bob.freeze
|
|
25
25
|
clone = bob.clone
|
26
26
|
dup = bob.dup
|
27
27
|
|
28
|
+
# Check vars.
|
28
29
|
puts clone.frozen? #=> true
|
29
30
|
puts dup.frozen? #=> false
|
30
31
|
|
@@ -35,8 +36,9 @@ puts dup.secret #=> NoMethodError
|
|
35
36
|
To solve this issue in the past, we had to define both `initialize_clone` & `initialize_dup` and maintain two copies of all our deep-copy code. That sucks. 😞
|
36
37
|
|
37
38
|
🚀 Instead, *InitCopy* was created:
|
38
|
-
|
39
|
-
|
39
|
+
|
40
|
+
1. Install the gem `init_copy` ([on RubyGems.org](https://rubygems.org/gems/init_copy)).
|
41
|
+
2. Include `InitCopy::Able` in your class/module.
|
40
42
|
3. Override the `init_copy(original)` method.
|
41
43
|
4. Use `ic_copy(var)`, instead of clone/dup.
|
42
44
|
|
@@ -46,14 +48,15 @@ Example usage:
|
|
46
48
|
require 'init_copy'
|
47
49
|
|
48
50
|
class JangoFett
|
49
|
-
include InitCopy
|
51
|
+
include InitCopy::Able
|
50
52
|
|
51
|
-
attr_reader :gear,:order66
|
53
|
+
attr_reader :gear,:bounties,:order66
|
52
54
|
|
53
55
|
def initialize
|
54
56
|
super
|
55
57
|
|
56
58
|
@gear = ['blaster','jetpack']
|
59
|
+
@bounties = ['Padmé','Vosa']
|
57
60
|
|
58
61
|
@order66 = Class.new do
|
59
62
|
undef_method :clone
|
@@ -67,12 +70,15 @@ class JangoFett
|
|
67
70
|
super
|
68
71
|
|
69
72
|
@gear = ic_copy(@gear)
|
73
|
+
@bounties = ic_copy(@bounties)
|
74
|
+
|
70
75
|
@order66 = ic_copy?(@order66) # Safe copy if no dup/clone.
|
71
76
|
end
|
72
77
|
end
|
73
78
|
|
79
|
+
# Init vars.
|
74
80
|
jango = JangoFett.new
|
75
|
-
jango.freeze
|
81
|
+
jango.bounties.freeze
|
76
82
|
|
77
83
|
boba1 = jango.clone
|
78
84
|
boba2 = jango.dup
|
@@ -80,13 +86,17 @@ boba2 = jango.dup
|
|
80
86
|
jango.gear << 'vibroblade'
|
81
87
|
boba1.gear << 'implant'
|
82
88
|
|
83
|
-
|
89
|
+
# Check vars.
|
90
|
+
puts jango.gear.inspect #=> ["blaster", "jetpack", "vibroblade"]
|
84
91
|
|
85
|
-
puts boba1.gear.inspect
|
86
|
-
puts boba2.gear.inspect
|
92
|
+
puts boba1.gear.inspect #=> ["blaster", "jetpack", "implant"]
|
93
|
+
puts boba2.gear.inspect #=> ["blaster", "jetpack"]
|
87
94
|
|
88
|
-
puts boba1.
|
89
|
-
puts boba2.
|
95
|
+
puts boba1.bounties.inspect #=> ["Padmé", "Vosa"]
|
96
|
+
puts boba2.bounties.inspect #=> ["Padmé", "Vosa"]
|
97
|
+
|
98
|
+
puts boba1.bounties.frozen? #=> true (clone)
|
99
|
+
puts boba2.bounties.frozen? #=> false (dup)
|
90
100
|
```
|
91
101
|
|
92
102
|
## // Contents
|
@@ -114,16 +124,15 @@ spec.add_dependency 'init_copy', '~> X.X'
|
|
114
124
|
In your *Gemfile*:
|
115
125
|
|
116
126
|
```ruby
|
117
|
-
# Pick
|
127
|
+
# Pick your poison...
|
118
128
|
gem 'init_copy', '~> X.X'
|
119
|
-
|
120
129
|
gem 'init_copy', git: 'https://github.com/esotericpig/init_copy.git', branch: 'main'
|
121
130
|
```
|
122
131
|
|
123
132
|
From source:
|
124
133
|
|
125
134
|
```bash
|
126
|
-
git clone 'https://github.com/esotericpig/init_copy.git'
|
135
|
+
git clone --depth 1 'https://github.com/esotericpig/init_copy.git'
|
127
136
|
cd init_copy
|
128
137
|
bundle install
|
129
138
|
bundle exec rake install:local
|
data/Rakefile
CHANGED
data/init_copy.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
-
require_relative 'lib/init_copy'
|
4
|
+
require_relative 'lib/init_copy/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'init_copy'
|
@@ -21,9 +21,8 @@ Gem::Specification.new do |spec|
|
|
21
21
|
'changelog_uri' => 'https://github.com/esotericpig/init_copy/blob/main/CHANGELOG.md',
|
22
22
|
}
|
23
23
|
|
24
|
-
# Lowest version that isn't eol (end-of-life).
|
25
24
|
# - https://www.ruby-lang.org/en/downloads/branches/
|
26
|
-
spec.required_ruby_version = '>= 3.
|
25
|
+
spec.required_ruby_version = '>= 3.1'
|
27
26
|
spec.require_paths = ['lib']
|
28
27
|
spec.bindir = 'bin'
|
29
28
|
spec.executables = []
|
data/lib/init_copy.rb
CHANGED
@@ -8,11 +8,13 @@
|
|
8
8
|
# SPDX-License-Identifier: MIT
|
9
9
|
#++
|
10
10
|
|
11
|
+
require 'init_copy/version'
|
12
|
+
|
11
13
|
# Example usage:
|
12
14
|
# require 'init_copy'
|
13
15
|
#
|
14
16
|
# class JangoFett
|
15
|
-
# include InitCopy
|
17
|
+
# include InitCopy::Able
|
16
18
|
#
|
17
19
|
# protected
|
18
20
|
#
|
@@ -24,33 +26,11 @@
|
|
24
26
|
# end
|
25
27
|
# end
|
26
28
|
module InitCopy
|
27
|
-
|
28
|
-
|
29
|
-
def self.included(mod)
|
30
|
-
super
|
31
|
-
|
32
|
-
# NOTE: Can't use prepend(), else children's init_copy() won't call their parents', even with super().
|
33
|
-
mod.include(Copyable)
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.extended(mod)
|
37
|
-
super
|
38
|
-
|
39
|
-
mod.include(Copyable)
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.prepended(mod)
|
43
|
-
super
|
44
|
-
|
45
|
-
# User specifically requested to prepend.
|
46
|
-
mod.prepend(Copyable)
|
47
|
-
end
|
48
|
-
|
49
|
-
module Copyable
|
29
|
+
module Able
|
50
30
|
def initialize_clone(orig)
|
51
31
|
super
|
52
32
|
|
53
|
-
# The instance
|
33
|
+
# The instance var name is long & obnoxious to reduce conflicts.
|
54
34
|
@__init_copy_method_name = :clone
|
55
35
|
init_copy(orig)
|
56
36
|
end
|
data/test/init_copy_test.rb
CHANGED
@@ -12,196 +12,180 @@ require 'minitest/autorun'
|
|
12
12
|
|
13
13
|
require 'init_copy'
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
describe InitCopy do
|
16
|
+
it 'has a correct version' do
|
17
|
+
_(InitCopy::VERSION).must_match(/\d+\.\d+\.\d+(-[0-9A-Za-z\-.]+)?(\+[0-9A-Za-z\-.]+)?/)
|
18
|
+
end
|
18
19
|
|
19
|
-
def
|
20
|
-
|
21
|
-
|
22
|
-
|
20
|
+
def self.add_basic_copy_tests
|
21
|
+
it 'is not the same as the copies' do
|
22
|
+
_(@sut).wont_be_same_as(@sut_clone)
|
23
|
+
_(@sut).wont_be_same_as(@sut_dup)
|
24
|
+
end
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
+
it 'has the correct copy method name' do
|
27
|
+
_(@sut.init_copy_method_name).must_be_nil
|
28
|
+
_(@sut_clone.init_copy_method_name).must_equal(:clone)
|
29
|
+
_(@sut_dup.init_copy_method_name).must_equal(:dup)
|
26
30
|
end
|
27
31
|
end
|
28
32
|
|
29
|
-
def
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
33
|
+
def self.add_deep_copy_tests(is_frozen: false)
|
34
|
+
it 'has the correct original' do
|
35
|
+
_(@sut.orig).must_be_nil
|
36
|
+
_(@sut_clone.orig).must_be_same_as(@sut)
|
37
|
+
_(@sut_dup.orig).must_be_same_as(@sut)
|
38
|
+
end
|
35
39
|
|
36
|
-
|
37
|
-
|
40
|
+
it 'does a deep copy' do
|
41
|
+
_(@sut.nums).wont_be_same_as(@sut_clone.nums)
|
42
|
+
_(@sut.nums).wont_be_same_as(@sut_dup.nums)
|
38
43
|
|
39
|
-
|
40
|
-
end
|
44
|
+
expected = [1,2,3]
|
41
45
|
|
42
|
-
|
43
|
-
|
46
|
+
_(@sut.nums).must_equal(expected)
|
47
|
+
_(@sut_clone.nums).must_equal(expected)
|
48
|
+
_(@sut_dup.nums).must_equal(expected)
|
44
49
|
|
45
|
-
|
46
|
-
|
50
|
+
if !is_frozen
|
51
|
+
@sut.nums << 4
|
52
|
+
@sut_clone.nums << 5
|
53
|
+
@sut_dup.nums << 6
|
47
54
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
return 100
|
55
|
+
_(@sut.nums).must_equal([1,2,3,4])
|
56
|
+
_(@sut_clone.nums).must_equal([1,2,3,5])
|
57
|
+
_(@sut_dup.nums).must_equal([1,2,3,6])
|
52
58
|
end
|
53
59
|
end
|
54
|
-
|
55
|
-
sut = TestBagWithCopy.new
|
56
|
-
sut.extend(sut_ext)
|
57
|
-
|
58
|
-
assert_deep_copy(sut,sut.clone,:clone)
|
59
|
-
assert_deep_copy(sut,sut.dup,:dup)
|
60
|
-
|
61
|
-
sut.nums.freeze
|
62
|
-
sut_clone = sut.clone
|
63
|
-
sut_dup = sut.dup
|
64
|
-
|
65
|
-
assert_predicate(sut.nums,:frozen?,'SUT nums should be frozen')
|
66
|
-
assert_respond_to(sut,:bonus,'SUT should have the bonus extension')
|
67
|
-
assert_equal(100,sut.bonus)
|
68
|
-
|
69
|
-
assert_predicate(sut_clone.nums,:frozen?,'clone should keep the nums as frozen')
|
70
|
-
assert_respond_to(sut_clone,:bonus,'clone should keep the bonus extension')
|
71
|
-
assert_equal(100,sut_clone.bonus)
|
72
|
-
|
73
|
-
refute_predicate(sut_dup.nums,:frozen?,'dup should remove the internal frozen state of nums')
|
74
|
-
refute_respond_to(sut_dup,:bonus,'dup should remove the bonus extension')
|
75
|
-
assert_raises(NoMethodError) { sut_dup.bonus }
|
76
60
|
end
|
77
61
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
assert_deep_copy(sut,sut.clone,:clone)
|
85
|
-
assert_deep_copy(sut,sut.dup,:dup)
|
86
|
-
|
87
|
-
class << sut.nums
|
88
|
-
undef_method :clone
|
89
|
-
undef_method :dup
|
62
|
+
describe 'without copy' do
|
63
|
+
before do
|
64
|
+
@sut = TestBag.new
|
65
|
+
@sut_clone = @sut.clone
|
66
|
+
@sut_dup = @sut.dup
|
90
67
|
end
|
91
68
|
|
92
|
-
|
93
|
-
refute_respond_to(sut.nums,:dup)
|
94
|
-
|
95
|
-
refute_deep_copy(sut,sut.clone,:clone,is_safe_copy: true)
|
96
|
-
refute_deep_copy(sut,sut.dup,:dup,is_safe_copy: true)
|
97
|
-
|
98
|
-
# Make sure we didn't remove clone()/dup() for all arrays.
|
99
|
-
assert_respond_to([1,2,3],:clone)
|
100
|
-
assert_respond_to([1,2,3],:dup)
|
101
|
-
end
|
102
|
-
|
103
|
-
def test_child_copy
|
104
|
-
sut_class = Class.new(TestBagWithCopy) do
|
105
|
-
attr_reader :strs
|
106
|
-
|
107
|
-
def initialize
|
108
|
-
super
|
109
|
-
|
110
|
-
@strs = %w[a b c]
|
111
|
-
end
|
112
|
-
|
113
|
-
def init_copy(*)
|
114
|
-
super
|
69
|
+
add_basic_copy_tests
|
115
70
|
|
116
|
-
|
117
|
-
|
71
|
+
it 'has no original' do
|
72
|
+
_(@sut.orig).must_be_nil
|
73
|
+
_(@sut_clone.orig).must_be_nil
|
74
|
+
_(@sut_dup.orig).must_be_nil
|
118
75
|
end
|
119
76
|
|
120
|
-
|
121
|
-
|
122
|
-
|
77
|
+
it 'does not do a deep copy' do
|
78
|
+
_(@sut.nums).must_be_same_as(@sut_clone.nums)
|
79
|
+
_(@sut.nums).must_be_same_as(@sut_dup.nums)
|
123
80
|
|
124
|
-
|
125
|
-
assert_deep_copy(sut,sut_dup,:dup)
|
81
|
+
expected = [1,2,3]
|
126
82
|
|
127
|
-
|
83
|
+
_(@sut.nums).must_equal(expected)
|
84
|
+
_(@sut_clone.nums).must_equal(expected)
|
85
|
+
_(@sut_dup.nums).must_equal(expected)
|
128
86
|
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
assert_equal(expected,sut_clone.strs)
|
133
|
-
assert_equal(expected,sut_dup.strs)
|
87
|
+
@sut.nums << 4
|
88
|
+
@sut_clone.nums << 5
|
89
|
+
@sut_dup.nums << 6
|
134
90
|
|
135
|
-
|
136
|
-
sut_clone.strs << 'e'
|
137
|
-
sut_dup.strs << 'f'
|
91
|
+
expected = [1,2,3,4,5,6]
|
138
92
|
|
139
|
-
|
140
|
-
|
141
|
-
|
93
|
+
_(@sut.nums).must_equal(expected)
|
94
|
+
_(@sut_clone.nums).must_equal(expected)
|
95
|
+
_(@sut_dup.nums).must_equal(expected)
|
96
|
+
end
|
142
97
|
end
|
143
98
|
|
144
|
-
|
145
|
-
|
99
|
+
describe 'with copy' do
|
100
|
+
before do
|
101
|
+
@sut = TestBagWithCopy.new
|
102
|
+
@sut_clone = @sut.clone
|
103
|
+
@sut_dup = @sut.dup
|
104
|
+
end
|
146
105
|
|
147
|
-
|
148
|
-
|
106
|
+
add_basic_copy_tests
|
107
|
+
add_deep_copy_tests
|
108
|
+
end
|
149
109
|
|
150
|
-
|
151
|
-
|
110
|
+
describe 'with copy and internal state' do
|
111
|
+
before do
|
112
|
+
@sut = TestBagWithCopy.new
|
113
|
+
|
114
|
+
@sut.nums.extend(
|
115
|
+
Module.new do
|
116
|
+
def bonus
|
117
|
+
return 110
|
118
|
+
end
|
119
|
+
end
|
120
|
+
)
|
121
|
+
@sut.nums.freeze
|
122
|
+
|
123
|
+
@sut_clone = @sut.clone
|
124
|
+
@sut_dup = @sut.dup
|
125
|
+
end
|
152
126
|
|
153
|
-
|
127
|
+
add_basic_copy_tests
|
128
|
+
add_deep_copy_tests(is_frozen: true)
|
154
129
|
|
155
|
-
|
156
|
-
|
157
|
-
|
130
|
+
it 'has the correct bonus extension' do
|
131
|
+
_(@sut.nums).must_respond_to(:bonus,'SUT should have the nums bonus extension')
|
132
|
+
_(@sut.nums.bonus).must_equal(110)
|
158
133
|
|
159
|
-
|
160
|
-
|
134
|
+
_(@sut_clone.nums).must_respond_to(:bonus,'clone should keep the nums bonus extension')
|
135
|
+
_(@sut_clone.nums.bonus).must_equal(110)
|
161
136
|
|
162
|
-
|
163
|
-
|
137
|
+
_(@sut_dup.nums).wont_respond_to(:bonus,'dup should remove the nums bonus extension')
|
138
|
+
_ { @sut_dup.bonus }.must_raise(NoMethodError)
|
139
|
+
end
|
164
140
|
|
165
|
-
|
166
|
-
|
167
|
-
|
141
|
+
it 'has the correct frozen state' do
|
142
|
+
_(@sut.nums.frozen?).must_equal(true,'SUT should have the nums as frozen')
|
143
|
+
_(@sut_clone.nums.frozen?).must_equal(true,'clone should keep the nums as frozen')
|
144
|
+
_(@sut_dup.nums.frozen?).must_equal(false,'dup should remove the nums as frozen')
|
145
|
+
end
|
168
146
|
end
|
169
147
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
148
|
+
describe 'child with copy and unsafe var' do
|
149
|
+
before do
|
150
|
+
@sut = TestBagChildWithCopyAndUnsafe.new
|
151
|
+
@sut_clone = @sut.clone
|
152
|
+
@sut_dup = @sut.dup
|
153
|
+
end
|
175
154
|
|
176
|
-
|
155
|
+
add_basic_copy_tests
|
156
|
+
add_deep_copy_tests
|
177
157
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
assert_nil(sut_copy.orig)
|
182
|
-
end
|
158
|
+
it 'does a deep copy of the strs' do
|
159
|
+
_(@sut.strs).wont_be_same_as(@sut_clone.strs)
|
160
|
+
_(@sut.strs).wont_be_same_as(@sut_dup.strs)
|
183
161
|
|
184
|
-
|
162
|
+
expected = %w[a b c]
|
185
163
|
|
186
|
-
|
187
|
-
|
188
|
-
|
164
|
+
_(@sut.strs).must_equal(expected)
|
165
|
+
_(@sut_clone.strs).must_equal(expected)
|
166
|
+
_(@sut_dup.strs).must_equal(expected)
|
189
167
|
|
190
|
-
|
191
|
-
|
168
|
+
@sut.strs << 'd'
|
169
|
+
@sut_clone.strs << 'e'
|
170
|
+
@sut_dup.strs << 'f'
|
192
171
|
|
193
|
-
|
172
|
+
_(@sut.strs).must_equal(%w[a b c d])
|
173
|
+
_(@sut_clone.strs).must_equal(%w[a b c e])
|
174
|
+
_(@sut_dup.strs).must_equal(%w[a b c f])
|
175
|
+
end
|
194
176
|
|
195
|
-
|
196
|
-
|
177
|
+
it 'does not do a deep copy of the unsafe var' do
|
178
|
+
_(@sut.unsafe).wont_respond_to(:clone)
|
179
|
+
_(@sut.unsafe).wont_respond_to(:dup)
|
197
180
|
|
198
|
-
|
199
|
-
|
181
|
+
_(@sut.unsafe).must_be_same_as(@sut_clone.unsafe)
|
182
|
+
_(@sut.unsafe).must_be_same_as(@sut_dup.unsafe)
|
183
|
+
end
|
200
184
|
end
|
201
185
|
end
|
202
186
|
|
203
187
|
class TestBag
|
204
|
-
include InitCopy
|
188
|
+
include InitCopy::Able
|
205
189
|
|
206
190
|
attr_reader :orig
|
207
191
|
attr_reader :nums
|
@@ -230,13 +214,24 @@ class TestBagWithCopy < TestBag
|
|
230
214
|
end
|
231
215
|
end
|
232
216
|
|
233
|
-
class
|
234
|
-
|
217
|
+
class TestBagChildWithCopyAndUnsafe < TestBagWithCopy
|
218
|
+
attr_reader :strs
|
219
|
+
attr_reader :unsafe
|
235
220
|
|
236
|
-
def
|
221
|
+
def initialize
|
237
222
|
super
|
238
223
|
|
239
|
-
@
|
240
|
-
@
|
224
|
+
@strs = %w[a b c]
|
225
|
+
@unsafe = Class.new do
|
226
|
+
undef_method :clone
|
227
|
+
undef_method :dup
|
228
|
+
end.new
|
229
|
+
end
|
230
|
+
|
231
|
+
def init_copy(*)
|
232
|
+
super
|
233
|
+
|
234
|
+
@strs = ic_copy(@strs)
|
235
|
+
@unsafe = ic_copy?(@unsafe)
|
241
236
|
end
|
242
237
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: init_copy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bradley Whited
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-06-
|
11
|
+
date: 2025-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Easily use the correct clone or dup method in initialize_copy.
|
14
14
|
email:
|
@@ -26,6 +26,7 @@ files:
|
|
26
26
|
- Rakefile
|
27
27
|
- init_copy.gemspec
|
28
28
|
- lib/init_copy.rb
|
29
|
+
- lib/init_copy/version.rb
|
29
30
|
- test/init_copy_test.rb
|
30
31
|
homepage: https://github.com/esotericpig/init_copy
|
31
32
|
licenses:
|
@@ -45,14 +46,14 @@ rdoc_options:
|
|
45
46
|
- "--main"
|
46
47
|
- README.md
|
47
48
|
- "--title"
|
48
|
-
- InitCopy v0.
|
49
|
+
- InitCopy v0.3.0
|
49
50
|
require_paths:
|
50
51
|
- lib
|
51
52
|
required_ruby_version: !ruby/object:Gem::Requirement
|
52
53
|
requirements:
|
53
54
|
- - ">="
|
54
55
|
- !ruby/object:Gem::Version
|
55
|
-
version: '3.
|
56
|
+
version: '3.1'
|
56
57
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
58
|
requirements:
|
58
59
|
- - ">="
|