full_clone 0.0.1 → 0.0.2
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 +8 -8
- data/README.md +5 -5
- data/deep_clone.gemspec +1 -1
- data/lib/full_clone/version.rb +2 -2
- data/lib/full_clone.rb +7 -7
- data/test/array_tests.rb +1 -1
- data/test/deep_clone_tests.rb +1 -1
- data/test/hash_tests.rb +1 -1
- data/test/object_tests.rb +1 -1
- data/test/struct_tests.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDc2N2Q1ZDU5OTljNTRkMjcyYTM3MDFlYjJiODFiYTA3Nzc0YjY4MQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
M2EwOGU0MDlmODQ1NTAzZmJmMDk5ZGM3ZDhjNGE5OTAwM2FkMDVjMg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MjRjODE1MDk4ODNlYTBmN2U4MzkyZWI3MzQzNjcxMzQxZWNkOTc0ZjZlZmQ3
|
10
|
+
ODI2MjNlZjZiYTU0Y2M0YjEwMjI1MGUwNDFjNGY4Njg0MjNjZDNkNGE2MGI3
|
11
|
+
OGRjMjg3MmJhNTExNDk3N2I5YzIyMWIzYWNlNDY1N2JiZGJjYzY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
M2M4YTFmYTViYTdmNzhkYzBiMjZiMjFmMmJkZmU1ZjQzODY0MGRmYzRlMzNh
|
14
|
+
YTQ5NzU0ZmJkODgwZGUyMTk5OTliZTk3MGNkOGRiZjE4NjE0YTg0M2M3NjVj
|
15
|
+
OWM0M2JkZWRhOGQyYjQ1YjAxNmY2NWU0ZWY2NDRhMDQ2NWM0MjY=
|
data/README.md
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
The standard clone method creates a fresh instance of most (non-scalar) objects
|
4
4
|
but does not clone internal state. This internal state remains aliased in the
|
5
5
|
cloned copy. The full_clone method digs deep and makes copies of these internal
|
6
|
-
variables. It also allows classes to specify an
|
7
|
-
are not to be processed.
|
6
|
+
variables, not just arrays and hashes. It also allows classes to specify an
|
7
|
+
exclusion list of variables that are not to be processed.
|
8
8
|
|
9
9
|
Add this line to your application's Gemfile:
|
10
10
|
|
@@ -33,9 +33,9 @@ instead of
|
|
33
33
|
To exclude some instance variables from the deep cloning process, define a
|
34
34
|
full_clone_exclude method in the required class:
|
35
35
|
|
36
|
-
def full_clone_exclude
|
37
|
-
|
38
|
-
end
|
36
|
+
def full_clone_exclude
|
37
|
+
[:@bad_var1, :@bad_var2, :@bad_var_etc]
|
38
|
+
end
|
39
39
|
|
40
40
|
|
41
41
|
## Contributing
|
data/deep_clone.gemspec
CHANGED
@@ -5,7 +5,7 @@ require 'full_clone/version'
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "full_clone"
|
8
|
-
spec.version =
|
8
|
+
spec.version = FullClone::VERSION
|
9
9
|
spec.authors = ["Peter Camilleri"]
|
10
10
|
spec.email = ["peter.c.camilleri@gmail.com"]
|
11
11
|
spec.description = "A (safe/no exceptions) clone variant that performs a deep, recursive copy."
|
data/lib/full_clone/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
module
|
2
|
-
VERSION = "0.0.
|
1
|
+
module FullClone
|
2
|
+
VERSION = "0.0.2"
|
3
3
|
end
|
data/lib/full_clone.rb
CHANGED
@@ -4,32 +4,32 @@ require_relative 'full_clone/array'
|
|
4
4
|
require_relative 'full_clone/hash'
|
5
5
|
require_relative 'full_clone/struct'
|
6
6
|
|
7
|
-
module
|
7
|
+
module FullClone
|
8
8
|
def full_clone(_progress={})
|
9
9
|
self
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
13
|
class Numeric
|
14
|
-
include
|
14
|
+
include FullClone
|
15
15
|
end
|
16
16
|
|
17
17
|
class NilClass
|
18
|
-
include
|
18
|
+
include FullClone
|
19
19
|
end
|
20
20
|
|
21
21
|
class TrueClass
|
22
|
-
include
|
22
|
+
include FullClone
|
23
23
|
end
|
24
24
|
|
25
25
|
class FalseClass
|
26
|
-
include
|
26
|
+
include FullClone
|
27
27
|
end
|
28
28
|
|
29
29
|
class Symbol
|
30
|
-
include
|
30
|
+
include FullClone
|
31
31
|
end
|
32
32
|
|
33
33
|
class Regexp
|
34
|
-
include
|
34
|
+
include FullClone
|
35
35
|
end
|
data/test/array_tests.rb
CHANGED
@@ -4,7 +4,7 @@ require_relative '../lib/full_clone'
|
|
4
4
|
require 'minitest/autorun'
|
5
5
|
|
6
6
|
#Test the monkey patches applied to the Object class.
|
7
|
-
class
|
7
|
+
class ArrayFullCloneTester < MiniTest::Unit::TestCase
|
8
8
|
|
9
9
|
#Special initialize to track rake progress.
|
10
10
|
def initialize(*all)
|
data/test/deep_clone_tests.rb
CHANGED
@@ -4,7 +4,7 @@ require_relative '../lib/full_clone'
|
|
4
4
|
require 'minitest/autorun'
|
5
5
|
|
6
6
|
#Test the monkey patches applied to the Object class.
|
7
|
-
class
|
7
|
+
class FullCloneTester < MiniTest::Unit::TestCase
|
8
8
|
|
9
9
|
#Special initialize to track rake progress.
|
10
10
|
def initialize(*all)
|
data/test/hash_tests.rb
CHANGED
@@ -4,7 +4,7 @@ require_relative '../lib/full_clone'
|
|
4
4
|
require 'minitest/autorun'
|
5
5
|
|
6
6
|
#Test the monkey patches applied to the Object class.
|
7
|
-
class
|
7
|
+
class HashFullCloneTester < MiniTest::Unit::TestCase
|
8
8
|
|
9
9
|
#Special initialize to track rake progress.
|
10
10
|
def initialize(*all)
|
data/test/object_tests.rb
CHANGED
@@ -4,7 +4,7 @@ require_relative '../lib/full_clone'
|
|
4
4
|
require 'minitest/autorun'
|
5
5
|
|
6
6
|
#Test the monkey patches applied to the Object class.
|
7
|
-
class
|
7
|
+
class ObjectFullCloneTester < MiniTest::Unit::TestCase
|
8
8
|
|
9
9
|
class SimpleClass
|
10
10
|
attr_accessor :iva
|
data/test/struct_tests.rb
CHANGED
@@ -4,7 +4,7 @@ require_relative '../lib/full_clone'
|
|
4
4
|
require 'minitest/autorun'
|
5
5
|
|
6
6
|
#Test the monkey patches applied to the Object class.
|
7
|
-
class
|
7
|
+
class StructFullCloneTester < MiniTest::Unit::TestCase
|
8
8
|
|
9
9
|
SimpleStruct = Struct.new(:iva, :ivb, :ivc)
|
10
10
|
|