deep_dive 0.1.1 → 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
  SHA1:
3
- metadata.gz: f9d588e7278531383b09030e833ac161a227df3a
4
- data.tar.gz: 0968544de295370ffd1bf24806b42ab612ec06c9
3
+ metadata.gz: edde2b4a8730e1e8bed8db0b7e194279c5974893
4
+ data.tar.gz: b67e80d31e82fa916576524c3d605005d92cdcb1
5
5
  SHA512:
6
- metadata.gz: cef93bef51e527093b6986cf72e8c3ce5653c38df59a28ef31dd65f5bcf70ff928e362a0b69077b6757d50565d81eb628ac684587f433585929601d60358a93a
7
- data.tar.gz: 98f523a0f803f33dbbd519be8af4d29957077c56ad52a22b04670a692effee4bc3c81297dc93803c97df0d2639f2bb7f882239dacf2faee00382bfc8c74faa13
6
+ metadata.gz: 1e93440296af10cc8a4487394e10576df13eaa9efc72c83df8e1953ad08864c4338bf75f162ba08740782ae93b77a4c7b0c9055b31fa2ddf4144c8f4d22f2e43
7
+ data.tar.gz: ff00ca474c2288f878bf2680ea9ee00e74e4c8de43be33dab8bd47f8033353306f225c0f3ca72be774e94c9e3ac7e85067e54217422a28625214fe19743c4141
data/.semver CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 0
3
- :minor: 1
4
- :patch: 1
3
+ :minor: 2
4
+ :patch: 0
5
5
  :special: ''
data/Gemfile CHANGED
@@ -5,12 +5,12 @@ gem 'debase'
5
5
  # Add dependencies to develop your gem here.
6
6
  # Include everything needed to run rake, tests, features, etc.
7
7
  group :development do
8
- gem "rspec", "~> 2.8.0"
9
- gem "rdoc", "~> 3.12"
10
- gem "bundler", "~> 1.0"
11
- gem "jeweler", "~> 1.8.7"
12
- gem "simplecov"
13
- gem 'semver'
14
- gem 'guard-rspec'
15
- gem 'ruby-debug-ide'
8
+ gem 'rspec', '~> 2'
9
+ gem 'rdoc', '~> 3'
10
+ gem 'bundler', '~> 1'
11
+ gem 'jeweler', '~> 1'
12
+ gem 'simplecov', '~> 0'
13
+ gem 'semver', '~> 1'
14
+ gem 'guard-rspec', '~> 1'
15
+ gem 'ruby-debug-ide', '~> 0'
16
16
  end
data/Gemfile.lock CHANGED
@@ -9,7 +9,7 @@ GEM
9
9
  debase (0.0.9)
10
10
  debugger-ruby_core_source
11
11
  debugger-ruby_core_source (1.3.5)
12
- diff-lcs (1.1.3)
12
+ diff-lcs (1.2.5)
13
13
  docile (1.1.5)
14
14
  faraday (0.8.9)
15
15
  multipart-post (~> 1.2.0)
@@ -71,14 +71,14 @@ GEM
71
71
  ffi (>= 0.5.0)
72
72
  rdoc (3.12.2)
73
73
  json (~> 1.4)
74
- rspec (2.8.0)
75
- rspec-core (~> 2.8.0)
76
- rspec-expectations (~> 2.8.0)
77
- rspec-mocks (~> 2.8.0)
78
- rspec-core (2.8.0)
79
- rspec-expectations (2.8.0)
80
- diff-lcs (~> 1.1.2)
81
- rspec-mocks (2.8.0)
74
+ rspec (2.99.0)
75
+ rspec-core (~> 2.99.0)
76
+ rspec-expectations (~> 2.99.0)
77
+ rspec-mocks (~> 2.99.0)
78
+ rspec-core (2.99.1)
79
+ rspec-expectations (2.99.2)
80
+ diff-lcs (>= 1.1.3, < 2.0)
81
+ rspec-mocks (2.99.2)
82
82
  ruby-debug-ide (0.4.22)
83
83
  rake (>= 0.8.1)
84
84
  semver (1.0.1)
@@ -95,12 +95,12 @@ PLATFORMS
95
95
  ruby
96
96
 
97
97
  DEPENDENCIES
98
- bundler (~> 1.0)
98
+ bundler (~> 1)
99
99
  debase
100
- guard-rspec
101
- jeweler (~> 1.8.7)
102
- rdoc (~> 3.12)
103
- rspec (~> 2.8.0)
104
- ruby-debug-ide
105
- semver
106
- simplecov
100
+ guard-rspec (~> 1)
101
+ jeweler (~> 1)
102
+ rdoc (~> 3)
103
+ rspec (~> 2)
104
+ ruby-debug-ide (~> 0)
105
+ semver (~> 1)
106
+ simplecov (~> 0)
data/README.rdoc CHANGED
@@ -38,6 +38,13 @@ It will simply use the reference to that object instead (a.k.a shallow copying)
38
38
  exclude :dontcopy
39
39
  end
40
40
 
41
+ class FooBlock < FooBar
42
+ attr_accessor :freject, :fa, :fb, :fc, :frecur, :fexcludeme
43
+ exclude { |sym, obj|
44
+ sym == :@fexcludeme if obj.instance_variable_defined?(:@freject) and obj.send(:freject)
45
+ }
46
+ end
47
+
41
48
  @foo = Foo.new
42
49
  @bar = Bar.new
43
50
  @foobar = FooBar.new
@@ -66,18 +73,17 @@ which will basically do a deep dup of @foo.
66
73
  Please see spec/lib/deep_dive/deep_dive_spec.rb for a more comprehensve example
67
74
  of the above. Better documentation will be supplied shortly.
68
75
 
69
- == Future Proposals
70
-
71
- It may be desirable to be able to pass a block into the 'exclude' DSL for more
72
- fine-grained control of whether a instance variable is copied or referenced.
73
-
74
76
  == Note Well
75
77
 
76
78
  DeepDive is expected to undergo rapid evolution until it hits 1.0.0. I will take
77
79
  every effort to keep the API backwards compatable until then.
78
80
 
81
+ == Release Notes
82
+
83
+ 2014-07-27 0.2.0 -- Implemented the exclusion block,
84
+ made gem restrictive to Ruby 2.x and higher.
85
+
79
86
  == Copyright
80
87
 
81
88
  Copyright (c) 2013-2014 Fred Mitchell. See LICENSE.txt for
82
89
  further details.
83
-
data/deep_dive.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: deep_dive 0.1.1 ruby lib
5
+ # stub: deep_dive 0.2.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "deep_dive"
9
- s.version = "0.1.1"
9
+ s.version = "0.2.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Fred Mitchell"]
14
- s.date = "2014-07-20"
14
+ s.date = "2014-07-28"
15
15
  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 "
16
16
  s.email = "lordalveric@yahoo.com"
17
17
  s.extra_rdoc_files = [
@@ -44,35 +44,35 @@ Gem::Specification.new do |s|
44
44
 
45
45
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
46
46
  s.add_runtime_dependency(%q<debase>, [">= 0"])
47
- s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
48
- s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
49
- s.add_development_dependency(%q<bundler>, ["~> 1.0"])
50
- s.add_development_dependency(%q<jeweler>, ["~> 1.8.7"])
51
- s.add_development_dependency(%q<simplecov>, [">= 0"])
52
- s.add_development_dependency(%q<semver>, [">= 0"])
53
- s.add_development_dependency(%q<guard-rspec>, [">= 0"])
54
- s.add_development_dependency(%q<ruby-debug-ide>, [">= 0"])
47
+ s.add_development_dependency(%q<rspec>, ["~> 2"])
48
+ s.add_development_dependency(%q<rdoc>, ["~> 3"])
49
+ s.add_development_dependency(%q<bundler>, ["~> 1"])
50
+ s.add_development_dependency(%q<jeweler>, ["~> 1"])
51
+ s.add_development_dependency(%q<simplecov>, ["~> 0"])
52
+ s.add_development_dependency(%q<semver>, ["~> 1"])
53
+ s.add_development_dependency(%q<guard-rspec>, ["~> 1"])
54
+ s.add_development_dependency(%q<ruby-debug-ide>, ["~> 0"])
55
55
  else
56
56
  s.add_dependency(%q<debase>, [">= 0"])
57
- s.add_dependency(%q<rspec>, ["~> 2.8.0"])
58
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
59
- s.add_dependency(%q<bundler>, ["~> 1.0"])
60
- s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
61
- s.add_dependency(%q<simplecov>, [">= 0"])
62
- s.add_dependency(%q<semver>, [">= 0"])
63
- s.add_dependency(%q<guard-rspec>, [">= 0"])
64
- s.add_dependency(%q<ruby-debug-ide>, [">= 0"])
57
+ s.add_dependency(%q<rspec>, ["~> 2"])
58
+ s.add_dependency(%q<rdoc>, ["~> 3"])
59
+ s.add_dependency(%q<bundler>, ["~> 1"])
60
+ s.add_dependency(%q<jeweler>, ["~> 1"])
61
+ s.add_dependency(%q<simplecov>, ["~> 0"])
62
+ s.add_dependency(%q<semver>, ["~> 1"])
63
+ s.add_dependency(%q<guard-rspec>, ["~> 1"])
64
+ s.add_dependency(%q<ruby-debug-ide>, ["~> 0"])
65
65
  end
66
66
  else
67
67
  s.add_dependency(%q<debase>, [">= 0"])
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
- s.add_dependency(%q<guard-rspec>, [">= 0"])
75
- s.add_dependency(%q<ruby-debug-ide>, [">= 0"])
68
+ s.add_dependency(%q<rspec>, ["~> 2"])
69
+ s.add_dependency(%q<rdoc>, ["~> 3"])
70
+ s.add_dependency(%q<bundler>, ["~> 1"])
71
+ s.add_dependency(%q<jeweler>, ["~> 1"])
72
+ s.add_dependency(%q<simplecov>, ["~> 0"])
73
+ s.add_dependency(%q<semver>, ["~> 1"])
74
+ s.add_dependency(%q<guard-rspec>, ["~> 1"])
75
+ s.add_dependency(%q<ruby-debug-ide>, ["~> 0"])
76
76
  end
77
77
  end
78
78
 
@@ -40,7 +40,7 @@ module DeepDive
40
40
  include API
41
41
  end
42
42
 
43
- # not meant to be called externally. Use either ddup or dclone.
43
+ # Not meant to be called externally. Use either ddup or dclone.
44
44
  def _replicate(dupit: true, oc: {})
45
45
  unless oc.member? self
46
46
  copy = oc[self] = if dupit
@@ -53,7 +53,7 @@ module DeepDive
53
53
  end.reject do |var, ob|
54
54
  not ob.respond_to? :_replicate
55
55
  end.reject do |var, ob|
56
- self.class.excluded? var
56
+ self.class.excluded?(var, self)
57
57
  end.each do |var, value|
58
58
  copy.instance_variable_set(var, value._replicate(oc: oc, dupit: dupit))
59
59
  end
@@ -125,14 +125,17 @@ module DeepDive
125
125
  module CMeth
126
126
  @@exclusion = []
127
127
  # exclusion list of instance variables to dup/clone
128
- def exclude(*list)
128
+ def exclude(*list, &block)
129
129
  @@exclusion << list.map { |s| "@#{s}".to_sym }
130
130
  @@exclusion.flatten!
131
+ @@exclusion_block = block if block_given?
131
132
  end
132
133
 
133
134
  # Internal function not meant to be called by the application.
134
- def excluded?(sym)
135
- @@exclusion.member? sym
135
+ def excluded?(sym, ob = nil)
136
+ unless @@exclusion_block.nil?
137
+ @@exclusion_block.(sym, ob)
138
+ end || @@exclusion.member?(sym)
136
139
  end
137
140
  end
138
141
 
@@ -18,11 +18,20 @@ class FooBar < FooBase
18
18
  exclude :dontcopy
19
19
  end
20
20
 
21
+ class FooBarFoo < FooBar
22
+ attr_accessor :freject, :fa, :fb, :fc, :frecur, :fexcludeme
23
+ exclude { |sym, obj|
24
+ sym == :@fexcludeme if obj.instance_variable_defined?(:@freject) and obj.send(:freject)
25
+ }
26
+ end
27
+
21
28
  describe DeepDive do
22
29
  before(:each) do
23
30
  @foo = Foo.new
24
31
  @bar = Bar.new
25
32
  @foobar = FooBar.new
33
+ @fbf = FooBarFoo.new
34
+
26
35
  @foobar.arr = [@foo, @bar, @foobar, "Just a string"]
27
36
  @foobar.hsh = {foo: @foo, bar: @bar, foobar: @foobar, nonddob: "just a string"}
28
37
 
@@ -33,6 +42,12 @@ describe DeepDive do
33
42
  @foo.c = @bar.c = @foobar.c = @foobar
34
43
  @foo.h = @bar.h = {1 => "one", 2 => "two", 3 => "three"}
35
44
  @foo.changeme = @bar.changeme = @foobar.changeme = "initial"
45
+
46
+ @fbf.fa = @foo
47
+ @fbf.fb = @bar
48
+ @fbf.fc = @foobar
49
+ @fbf.frecur = @fbf
50
+ @fbf.fexcludeme = Foo.new
36
51
  end
37
52
 
38
53
 
@@ -110,4 +125,18 @@ describe DeepDive do
110
125
  end
111
126
  end
112
127
  end
128
+
129
+ context 'block exclusions' do
130
+ it 'copies with freject true' do
131
+ @fbf.freject = true
132
+ a = @fbf.dclone
133
+ a.fexcludeme.should == @fbf.fexcludeme
134
+ end
135
+
136
+ it 'copies with freject false' do
137
+ @fbf.freject = false
138
+ b = @fbf.dclone
139
+ b.fexcludeme.should_not == @fbf.fexcludeme
140
+ end
141
+ end
113
142
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deep_dive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fred Mitchell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-20 00:00:00.000000000 Z
11
+ date: 2014-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: debase
@@ -30,110 +30,110 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 2.8.0
33
+ version: '2'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 2.8.0
40
+ version: '2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rdoc
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3.12'
47
+ version: '3'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3.12'
54
+ version: '3'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '1.0'
61
+ version: '1'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '1.0'
68
+ version: '1'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: jeweler
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 1.8.7
75
+ version: '1'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 1.8.7
82
+ version: '1'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: simplecov
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: semver
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: '1'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: '1'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: guard-rspec
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: '0'
117
+ version: '1'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: '1'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: ruby-debug-ide
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ">="
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ">="
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  description: "\n When you have a system of objects that have many references to each