deep_dive 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.idea/.name +1 -0
- data/.idea/.rakeTasks +7 -0
- data/.idea/deep_dive.iml +47 -0
- data/.idea/encodings.xml +5 -0
- data/.idea/misc.xml +5 -0
- data/.idea/modules.xml +9 -0
- data/.idea/scopes/scope_settings.xml +5 -0
- data/.idea/vcs.xml +7 -0
- data/.idea/workspace.xml +497 -0
- data/.rspec +1 -0
- data/.semver +5 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +72 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +28 -0
- data/Rakefile +63 -0
- data/deep_dive.gemspec +76 -0
- data/lib/deep_dive/deep_dive.rb +125 -0
- data/lib/deep_dive.rb +1 -0
- data/spec/lib/deep_dive/deep_dive_spec.rb +86 -0
- data/spec/spec_helper.rb +12 -0
- metadata +156 -0
data/.semver
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
ruby '2.0.0'
|
7
|
+
|
8
|
+
# Add dependencies to develop your gem here.
|
9
|
+
# Include everything needed to run rake, tests, features, etc.
|
10
|
+
group :development do
|
11
|
+
gem "rspec", "~> 2.8.0"
|
12
|
+
gem "rdoc", "~> 3.12"
|
13
|
+
gem "bundler", "~> 1.0"
|
14
|
+
gem "jeweler", "~> 1.8.7"
|
15
|
+
gem "simplecov"
|
16
|
+
gem 'semver'
|
17
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
addressable (2.3.5)
|
5
|
+
builder (3.2.2)
|
6
|
+
diff-lcs (1.1.3)
|
7
|
+
docile (1.1.1)
|
8
|
+
faraday (0.8.8)
|
9
|
+
multipart-post (~> 1.2.0)
|
10
|
+
git (1.2.6)
|
11
|
+
github_api (0.10.1)
|
12
|
+
addressable
|
13
|
+
faraday (~> 0.8.1)
|
14
|
+
hashie (>= 1.2)
|
15
|
+
multi_json (~> 1.4)
|
16
|
+
nokogiri (~> 1.5.2)
|
17
|
+
oauth2
|
18
|
+
hashie (2.0.5)
|
19
|
+
highline (1.6.20)
|
20
|
+
httpauth (0.2.0)
|
21
|
+
jeweler (1.8.8)
|
22
|
+
builder
|
23
|
+
bundler (~> 1.0)
|
24
|
+
git (>= 1.2.5)
|
25
|
+
github_api (= 0.10.1)
|
26
|
+
highline (>= 1.6.15)
|
27
|
+
nokogiri (= 1.5.10)
|
28
|
+
rake
|
29
|
+
rdoc
|
30
|
+
json (1.8.1)
|
31
|
+
jwt (0.1.8)
|
32
|
+
multi_json (>= 1.5)
|
33
|
+
multi_json (1.8.2)
|
34
|
+
multi_xml (0.5.5)
|
35
|
+
multipart-post (1.2.0)
|
36
|
+
nokogiri (1.5.10)
|
37
|
+
oauth2 (0.9.2)
|
38
|
+
faraday (~> 0.8)
|
39
|
+
httpauth (~> 0.2)
|
40
|
+
jwt (~> 0.1.4)
|
41
|
+
multi_json (~> 1.0)
|
42
|
+
multi_xml (~> 0.5)
|
43
|
+
rack (~> 1.2)
|
44
|
+
rack (1.5.2)
|
45
|
+
rake (10.1.1)
|
46
|
+
rdoc (3.12.2)
|
47
|
+
json (~> 1.4)
|
48
|
+
rspec (2.8.0)
|
49
|
+
rspec-core (~> 2.8.0)
|
50
|
+
rspec-expectations (~> 2.8.0)
|
51
|
+
rspec-mocks (~> 2.8.0)
|
52
|
+
rspec-core (2.8.0)
|
53
|
+
rspec-expectations (2.8.0)
|
54
|
+
diff-lcs (~> 1.1.2)
|
55
|
+
rspec-mocks (2.8.0)
|
56
|
+
semver (1.0.1)
|
57
|
+
simplecov (0.8.2)
|
58
|
+
docile (~> 1.1.0)
|
59
|
+
multi_json
|
60
|
+
simplecov-html (~> 0.8.0)
|
61
|
+
simplecov-html (0.8.0)
|
62
|
+
|
63
|
+
PLATFORMS
|
64
|
+
ruby
|
65
|
+
|
66
|
+
DEPENDENCIES
|
67
|
+
bundler (~> 1.0)
|
68
|
+
jeweler (~> 1.8.7)
|
69
|
+
rdoc (~> 3.12)
|
70
|
+
rspec (~> 2.8.0)
|
71
|
+
semver
|
72
|
+
simplecov
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Fred Mitchell
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
= DeepDive Deep Contolled Cloning
|
2
|
+
|
3
|
+
When you have a system of objects that have many references to each other, it becomes an
|
4
|
+
issue to be able to clone properly that object graph. There may be control objects you may
|
5
|
+
not want to clone, but maintain references to. And some references you may not wish to clone at all.
|
6
|
+
|
7
|
+
Enter DeepDive. Allows you a means by which you can do controlled deep cloning or
|
8
|
+
copying of your complex interconnected objects.
|
9
|
+
|
10
|
+
== Usage
|
11
|
+
Simply include DeepDive in your base class. All classes derived will be set
|
12
|
+
for deep cloning or deep duping.
|
13
|
+
|
14
|
+
== Contributing to deep_dive
|
15
|
+
|
16
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
17
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
18
|
+
* Fork the project.
|
19
|
+
* Start a feature/bugfix branch.
|
20
|
+
* Commit and push until you are happy with your contribution.
|
21
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
22
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
23
|
+
|
24
|
+
== Copyright
|
25
|
+
|
26
|
+
Copyright (c) 2013 Fred Mitchell. See LICENSE.txt for
|
27
|
+
further details.
|
28
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
require 'semver'
|
6
|
+
|
7
|
+
def s_version
|
8
|
+
SemVer.find.format "%M.%m.%p%s"
|
9
|
+
end
|
10
|
+
|
11
|
+
begin
|
12
|
+
Bundler.setup(:default, :development)
|
13
|
+
rescue Bundler::BundlerError => e
|
14
|
+
$stderr.puts e.message
|
15
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
16
|
+
exit e.status_code
|
17
|
+
end
|
18
|
+
require 'rake'
|
19
|
+
|
20
|
+
require 'jeweler'
|
21
|
+
Jeweler::Tasks.new do |gem|
|
22
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
23
|
+
gem.name = "deep_dive"
|
24
|
+
gem.homepage = "https://github.com/flajann2/deep_dive"
|
25
|
+
gem.license = "MIT"
|
26
|
+
gem.summary = %Q{DeepDive Deep Contolled Cloning}
|
27
|
+
gem.version = s_version
|
28
|
+
gem.description = %Q{
|
29
|
+
When you have a system of objects that have many references to each other, it becomes an
|
30
|
+
issue to be able to clone properly that object graph. There may be control objects you may
|
31
|
+
not want to clone, but maintain references to. And some references you may not wish to clone at all.
|
32
|
+
|
33
|
+
Enter DeepDive. Allows you a means by which you can do controlled deep cloning or
|
34
|
+
copying of your complex interconnected objects.
|
35
|
+
}
|
36
|
+
gem.email = "fred@lrcsoft.com"
|
37
|
+
gem.authors = ["Fred Mitchell"]
|
38
|
+
# dependencies defined in Gemfile
|
39
|
+
end
|
40
|
+
Jeweler::RubygemsDotOrgTasks.new
|
41
|
+
|
42
|
+
require 'rspec/core'
|
43
|
+
require 'rspec/core/rake_task'
|
44
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
45
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
46
|
+
end
|
47
|
+
|
48
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
49
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
50
|
+
spec.rcov = true
|
51
|
+
end
|
52
|
+
|
53
|
+
task :default => :spec
|
54
|
+
|
55
|
+
require 'rdoc/task'
|
56
|
+
Rake::RDocTask.new do |rdoc|
|
57
|
+
version = s_version
|
58
|
+
|
59
|
+
rdoc.rdoc_dir = 'rdoc'
|
60
|
+
rdoc.title = "deep_dive #{version}"
|
61
|
+
rdoc.rdoc_files.include('README*')
|
62
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
63
|
+
end
|
data/deep_dive.gemspec
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "deep_dive"
|
8
|
+
s.version = "0.0.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Fred Mitchell"]
|
12
|
+
s.date = "2013-12-30"
|
13
|
+
s.description = "\n When you have a system of objects that have many references to each other, it becomes an\n issue to be able to clone properly that object graph. There may be control objects you may\n not want to clone, but maintain references to. And some references you may not wish to clone at all.\n\n Enter DeepDive. Allows you a means by which you can do controlled deep cloning or\n copying of your complex interconnected objects.\n "
|
14
|
+
s.email = "fred@lrcsoft.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".idea/.name",
|
22
|
+
".idea/.rakeTasks",
|
23
|
+
".idea/deep_dive.iml",
|
24
|
+
".idea/encodings.xml",
|
25
|
+
".idea/misc.xml",
|
26
|
+
".idea/modules.xml",
|
27
|
+
".idea/scopes/scope_settings.xml",
|
28
|
+
".idea/vcs.xml",
|
29
|
+
".idea/workspace.xml",
|
30
|
+
".rspec",
|
31
|
+
".semver",
|
32
|
+
"Gemfile",
|
33
|
+
"Gemfile.lock",
|
34
|
+
"LICENSE.txt",
|
35
|
+
"README.rdoc",
|
36
|
+
"Rakefile",
|
37
|
+
"deep_dive.gemspec",
|
38
|
+
"lib/deep_dive.rb",
|
39
|
+
"lib/deep_dive/deep_dive.rb",
|
40
|
+
"spec/lib/deep_dive/deep_dive_spec.rb",
|
41
|
+
"spec/spec_helper.rb"
|
42
|
+
]
|
43
|
+
s.homepage = "https://github.com/flajann2/deep_dive"
|
44
|
+
s.licenses = ["MIT"]
|
45
|
+
s.require_paths = ["lib"]
|
46
|
+
s.rubygems_version = "2.0.14"
|
47
|
+
s.summary = "DeepDive Deep Contolled Cloning"
|
48
|
+
|
49
|
+
if s.respond_to? :specification_version then
|
50
|
+
s.specification_version = 4
|
51
|
+
|
52
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
53
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
54
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
55
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
56
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.7"])
|
57
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
58
|
+
s.add_development_dependency(%q<semver>, [">= 0"])
|
59
|
+
else
|
60
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
61
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
62
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
63
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
|
64
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
65
|
+
s.add_dependency(%q<semver>, [">= 0"])
|
66
|
+
end
|
67
|
+
else
|
68
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
69
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
70
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
71
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
|
72
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
73
|
+
s.add_dependency(%q<semver>, [">= 0"])
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
@@ -0,0 +1,125 @@
|
|
1
|
+
=begin rdoc
|
2
|
+
=DeepDive Deep Contolled Cloning
|
3
|
+
|
4
|
+
When you have a system of objects that have many references to each other, it becomes an
|
5
|
+
issue to be able to clone properly that object graph. There may be control objects you may
|
6
|
+
not want to clone, but maintain references to. And some references you may not wish to clone at all.
|
7
|
+
|
8
|
+
Enter DeepDive. Allows you a means by which you can do controlled deep cloning or
|
9
|
+
copying of your complex interconnected objects.
|
10
|
+
|
11
|
+
=Usage
|
12
|
+
Simply include DeepDive in your base class. All classes derived will be set
|
13
|
+
for deep cloning or deep duping.
|
14
|
+
=end
|
15
|
+
require 'set'
|
16
|
+
|
17
|
+
module DeepDive
|
18
|
+
class DeepDiveException < Exception
|
19
|
+
end
|
20
|
+
|
21
|
+
# #ddup is a Deep Dive's replacement for #dup.
|
22
|
+
def ddup
|
23
|
+
_replicate dupit: true
|
24
|
+
end
|
25
|
+
|
26
|
+
# #dclone is Deep Dive's replacement for #clone.
|
27
|
+
def dclone
|
28
|
+
_replicate dupit: false
|
29
|
+
end
|
30
|
+
|
31
|
+
# not meant to be called externally. Use either ddup or dclone.
|
32
|
+
def _replicate(dupit: true, oc: {})
|
33
|
+
unless oc.member? self
|
34
|
+
copy = oc[self] = if dupit
|
35
|
+
dup
|
36
|
+
else
|
37
|
+
clone
|
38
|
+
end
|
39
|
+
copy.instance_variables.map do |var|
|
40
|
+
[var, instance_variable_get(var)]
|
41
|
+
end.reject do |var, ob|
|
42
|
+
not ob.respond_to? :_replicate
|
43
|
+
end.reject do |var, ob|
|
44
|
+
self.class.excluded? var
|
45
|
+
end.each do |var, value|
|
46
|
+
copy.instance_variable_set(var, value._replicate(oc: oc, dupit: dupit))
|
47
|
+
end
|
48
|
+
end
|
49
|
+
oc[self]
|
50
|
+
end
|
51
|
+
|
52
|
+
# For all enumerable objects, we will have to handle their situation
|
53
|
+
# differently.
|
54
|
+
module ::Enumerable
|
55
|
+
# add a single element to the enumerable.
|
56
|
+
# You may pass a single parameter, or a key, value. In any case,
|
57
|
+
# all will added.
|
58
|
+
#
|
59
|
+
# Here all the logic will be present to handle the "special case"
|
60
|
+
# enumerables. Most notedly, Hash and Array will require special
|
61
|
+
# treatment.
|
62
|
+
def _add(v: nil, dupit: nil, oc: nil)
|
63
|
+
unless _pairs?
|
64
|
+
case
|
65
|
+
when self.kind_of?(Set)
|
66
|
+
when self.kind_of?(Array)
|
67
|
+
self << v._replicate(oc: oc, dupit: dupit)
|
68
|
+
else
|
69
|
+
raise DeepDiveException.new("Don't know how to add new elements for class #{self.class}")
|
70
|
+
end
|
71
|
+
else
|
72
|
+
self[v.first] = v.last._replicate(oc: oc, dupit: dupit)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# We try to determine if this enumberable will return pairs
|
77
|
+
# (as in the case of a Hash) or objects (which may look like pairs
|
78
|
+
# but not really).
|
79
|
+
def _pairs?
|
80
|
+
self.kind_of? Hash
|
81
|
+
end
|
82
|
+
|
83
|
+
# Here, with this Enumerator, we want to create a new empty instance
|
84
|
+
# and populate it with replicas (or references) of the contained
|
85
|
+
# objects.
|
86
|
+
#
|
87
|
+
# here, a nasty problem is that there is no unified API for *adding*
|
88
|
+
# or *substituting* objects into the new collection, so we are going
|
89
|
+
# to abstract that issue to #_add.
|
90
|
+
#
|
91
|
+
# FIXME: We will initially not handle Enumberables that have instance variables.
|
92
|
+
# FIXME: This issue will be addressed at a later date.
|
93
|
+
def _replicate(dupit: true, oc: {})
|
94
|
+
unless oc.member? self
|
95
|
+
self.inject(oc[self] = self.class.new) do |copy, v|
|
96
|
+
copy._add(v: v, dupit: dupit, oc: oc)
|
97
|
+
copy
|
98
|
+
end
|
99
|
+
end
|
100
|
+
oc[self]
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
module CMeth
|
105
|
+
@@exclusion = []
|
106
|
+
# exclusion list of instance variables to dup/clone
|
107
|
+
def exclude(*list)
|
108
|
+
@@exclusion << list.map { |s| "@#{s}".to_sym }
|
109
|
+
@@exclusion.flatten!
|
110
|
+
end
|
111
|
+
|
112
|
+
# Internal function not meant to be called by the application.
|
113
|
+
def excluded?(sym)
|
114
|
+
@@exclusion.member? sym
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def self.included(base)
|
119
|
+
base.extend(CMeth)
|
120
|
+
end
|
121
|
+
|
122
|
+
def self.inherited(sub)
|
123
|
+
sub.include(DeepDive)
|
124
|
+
end
|
125
|
+
end
|
data/lib/deep_dive.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'deep_dive/deep_dive'
|
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'deep_dive'
|
2
|
+
|
3
|
+
class FooBase
|
4
|
+
include DeepDive
|
5
|
+
exclude :c
|
6
|
+
end
|
7
|
+
|
8
|
+
class Foo < FooBase
|
9
|
+
attr_accessor :a, :b, :c, :changeme
|
10
|
+
end
|
11
|
+
|
12
|
+
class Bar < FooBase
|
13
|
+
attr_accessor :a, :b, :c, :changeme
|
14
|
+
end
|
15
|
+
|
16
|
+
class FooBar < FooBase
|
17
|
+
attr_accessor :a, :b, :c, :changeme, :dontcopy, :arr, :hsh
|
18
|
+
exclude :dontcopy
|
19
|
+
end
|
20
|
+
|
21
|
+
describe DeepDive do
|
22
|
+
before(:each) do
|
23
|
+
@foo = Foo.new
|
24
|
+
@bar = Bar.new
|
25
|
+
@foobar = FooBar.new
|
26
|
+
@foobar.arr = [@foo, @bar, @foobar]
|
27
|
+
@foobar.hsh = {foo: @foo, bar: @bar, foobar: @foobar}
|
28
|
+
|
29
|
+
@foo.a = 'foo just around'
|
30
|
+
@bar.a = 'bar hanging around'
|
31
|
+
@foo.b = @bar
|
32
|
+
@bar.b = @foo
|
33
|
+
@foo.c = @bar.c = @foobar.c = @foobar
|
34
|
+
@foo.changeme = @bar.changeme = @foobar.changeme = "initial"
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
context 'clone' do
|
39
|
+
it 'simple' do
|
40
|
+
cfoo = @foo.dclone
|
41
|
+
cfoo.should_not == nil
|
42
|
+
cfoo.should_not == @foo
|
43
|
+
@foo.b.changeme = 'changed'
|
44
|
+
@foobar.changeme = 'also changed'
|
45
|
+
cfoo.c.changeme.should == @foobar.changeme
|
46
|
+
cfoo.b.changeme.should_not == @foo.b.changeme
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'exclusion' do
|
50
|
+
@foobar.dontcopy = @bar
|
51
|
+
cfoobar = @foobar.dclone
|
52
|
+
cfoobar.dontcopy.should == @foobar.dontcopy
|
53
|
+
|
54
|
+
@foo.a = @bar
|
55
|
+
cfoo = @foo.dclone
|
56
|
+
cfoo.a.should_not == @foo.a
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'dup' do
|
61
|
+
it 'simple' do
|
62
|
+
cfoo = @foo.ddup
|
63
|
+
cfoo.should_not == nil
|
64
|
+
end
|
65
|
+
it 'deep'
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'enumerables' do
|
69
|
+
it 'makes copies of the arrayed objects' do
|
70
|
+
cfb = @foobar.dclone
|
71
|
+
cfb.arr.size.should > 0
|
72
|
+
(0 ... cfb.arr.size).each do |i|
|
73
|
+
cfb.arr[i].should_not be_nil
|
74
|
+
cfb.arr[i].should_not == @foobar.arr[i]
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'makes copies of the hashed objects' do
|
79
|
+
cfb = @foobar.dclone
|
80
|
+
cfb.hsh.size.should > 0
|
81
|
+
cfb.hsh.each do |k, o|
|
82
|
+
cfb.hsh[k].should_not == @foobar.hsh[k]
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'deep_dive'
|
5
|
+
|
6
|
+
# Requires supporting files with custom matchers and macros, etc,
|
7
|
+
# in ./support/ and its subdirectories.
|
8
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: deep_dive
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Fred Mitchell
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-30 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.8.0
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.8.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rdoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.12'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: jeweler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.8.7
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.8.7
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: semver
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: "\n When you have a system of objects that have many references to each
|
98
|
+
other, it becomes an\n issue to be able to clone properly that object graph. There
|
99
|
+
may be control objects you may\n not want to clone, but maintain references to.
|
100
|
+
And some references you may not wish to clone at all.\n\n Enter DeepDive. Allows
|
101
|
+
you a means by which you can do controlled deep cloning or\n copying of your complex
|
102
|
+
interconnected objects.\n "
|
103
|
+
email: fred@lrcsoft.com
|
104
|
+
executables: []
|
105
|
+
extensions: []
|
106
|
+
extra_rdoc_files:
|
107
|
+
- LICENSE.txt
|
108
|
+
- README.rdoc
|
109
|
+
files:
|
110
|
+
- .document
|
111
|
+
- .idea/.name
|
112
|
+
- .idea/.rakeTasks
|
113
|
+
- .idea/deep_dive.iml
|
114
|
+
- .idea/encodings.xml
|
115
|
+
- .idea/misc.xml
|
116
|
+
- .idea/modules.xml
|
117
|
+
- .idea/scopes/scope_settings.xml
|
118
|
+
- .idea/vcs.xml
|
119
|
+
- .idea/workspace.xml
|
120
|
+
- .rspec
|
121
|
+
- .semver
|
122
|
+
- Gemfile
|
123
|
+
- Gemfile.lock
|
124
|
+
- LICENSE.txt
|
125
|
+
- README.rdoc
|
126
|
+
- Rakefile
|
127
|
+
- deep_dive.gemspec
|
128
|
+
- lib/deep_dive.rb
|
129
|
+
- lib/deep_dive/deep_dive.rb
|
130
|
+
- spec/lib/deep_dive/deep_dive_spec.rb
|
131
|
+
- spec/spec_helper.rb
|
132
|
+
homepage: https://github.com/flajann2/deep_dive
|
133
|
+
licenses:
|
134
|
+
- MIT
|
135
|
+
metadata: {}
|
136
|
+
post_install_message:
|
137
|
+
rdoc_options: []
|
138
|
+
require_paths:
|
139
|
+
- lib
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - '>='
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
146
|
+
requirements:
|
147
|
+
- - '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
requirements: []
|
151
|
+
rubyforge_project:
|
152
|
+
rubygems_version: 2.0.14
|
153
|
+
signing_key:
|
154
|
+
specification_version: 4
|
155
|
+
summary: DeepDive Deep Contolled Cloning
|
156
|
+
test_files: []
|