full_clone 0.0.5 → 0.0.6

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: 6356656d26f8c77cdeec7f5eac9d764e4a398623
4
- data.tar.gz: 4eaa1c261d356c755cfe5f64f95d08a26bb700ae
3
+ metadata.gz: e9209ed1e6cb951c55c56e47f7bf00868f6a651a
4
+ data.tar.gz: 1d56f766fe6dbf6ef71fd5599c9a78f7965acf42
5
5
  SHA512:
6
- metadata.gz: 0116b825408bb0554e0a6d6cbcf7ba0219add96b12ad80a3a813e928781f595b961631d7ed97e17d14ee2b9825373e01c80073cd809777cca9382d97f76f83fd
7
- data.tar.gz: 81b56106d08a3374e90b203d212e26dfcdf4a088bc52c54a8bb860461beeb1814bb8cd8312b34f42f4cb06bb35b052161f7448bfd846a8d99a5c9687b09e6de3
6
+ metadata.gz: 65a6910868cfa6e8e8ddd56fee61e885e42fd3d5a8ea9d7a71b88d71e91f6072888c793193bd8aeaaa7208dc55b9f890b1bd185fed4825898d2634ff642174ff
7
+ data.tar.gz: b012aacf6dc4e175b93279cb67834d73c4447d7435e57f9f9881f4753d5fcfd8367b0f15b9bef30080668444acb713d40147a992269df6526cc616f7829feb42
data/README.md CHANGED
@@ -6,6 +6,46 @@ cloned copy. The full_clone method digs deep and makes copies of these internal
6
6
  variables, not just arrays and hashes. It also allows classes to specify an
7
7
  exclusion list of variables that are not to be processed.
8
8
 
9
+ This comprehensive approach creates another issue to be resolved. In Ruby, if an
10
+ attempt is made to clone an immutable data item like a number, an error occurs.
11
+ The justification for this uncharacteristic strictness is not at all clear, but
12
+ it does mean that the clone operation must be applied with great care.
13
+
14
+ Unlike the standard clone method, the full\_clone method does not throw an
15
+ exception when it sees un-clonable value objects like 42 or true. These values
16
+ simply return themselves. This is correct because those types of objects do
17
+ not _need_ to be cloned. Instead of having a fit, the code just works!
18
+
19
+ Another issue that this gem deals with is that of data with looping reference
20
+ chains. To handle this, the code tracks object ID values and does not re-clone
21
+ data that has already been cloned. Thus even nasty edge cases are handled
22
+ without any special effort on the part of the application programmer.
23
+
24
+ ## Family Overview
25
+
26
+ This gem is a member of a family of four gems that all provide data copying
27
+ services in a safe, easy to use format. The following outlines the available
28
+ gems and how to chose from among them.
29
+
30
+ Depth / Action | Need to copy all. | Need to copy data only.
31
+ ---------------|------------------------------|------------
32
+ Need a shallow copy | require 'safe\_clone' | require 'safe\_dup'
33
+ Need a full copy | require 'full\_clone' | require 'full\_dup'
34
+
35
+ <br>**Notes**
36
+ * Since none of these gems override the default clone and dup
37
+ methods, the default behaviors remain available. Further, if multiple,
38
+ differing requirements exists, more than one family member gem may be
39
+ employed in the same project without fear of conflict.
40
+ * If multiple family gems are employed, they will each need to be installed and
41
+ required into the application. See below for details.
42
+ * Meta-data attributes include the frozen status and singleton methods. However
43
+ the tainted status is always copied.
44
+
45
+
46
+
47
+ ## Installation
48
+
9
49
  Add this line to your application's Gemfile:
10
50
 
11
51
  gem 'full_clone'
@@ -18,6 +58,11 @@ Or install it yourself as:
18
58
 
19
59
  $ gem install full_clone
20
60
 
61
+ The safe_dup gem is at: ( https://rubygems.org/gems/safe_dup )
62
+ <br>The safe_clone gem is at: ( https://rubygems.org/gems/safe_clone )
63
+ <br>The full_dup gem is at: ( https://rubygems.org/gems/full_dup )
64
+ <br>The full_clone gem is at: ( https://rubygems.org/gems/full_clone )
65
+
21
66
  ## Usage
22
67
 
23
68
  require 'full_clone'
@@ -33,10 +78,20 @@ instead of
33
78
  To exclude some instance variables from the deep cloning process, define a
34
79
  full_clone_exclude method in the required class:
35
80
 
36
- def full_clone_exclude
37
- [:@bad_var1, :@bad_var2, :@bad_var_etc]
38
- end
39
-
81
+ ```ruby
82
+ def full_clone_exclude
83
+ [:@bad_var1, :@bad_var2, :@bad_var_etc]
84
+ end
85
+ ```
86
+ This also can be applied to arrays and hashes. In this case, it is possible to
87
+ define a singleton method on the cloned data. Then the exclude method would
88
+ return an array of array indexes or hash keys to be omitted from the full clone
89
+ recursion. Here is an example that never clones the first two elements of the
90
+ array:
91
+
92
+ ```ruby
93
+ my_array.define_singleton_method(:full_clone_exclude) { [0, 1] }
94
+ ```
40
95
 
41
96
  ## Notes
42
97
 
@@ -49,8 +104,15 @@ broken!
49
104
 
50
105
  ## Contributing
51
106
 
52
- 1. Fork it
107
+ #### Plan A
108
+
109
+ 1. Fork it ( https://github.com/PeterCamilleri/full_clone/fork )
53
110
  2. Create your feature branch (`git checkout -b my-new-feature`)
54
111
  3. Commit your changes (`git commit -am 'Add some feature'`)
55
112
  4. Push to the branch (`git push origin my-new-feature`)
56
113
  5. Create new Pull Request
114
+
115
+ #### Plan B
116
+
117
+ Go to the GitHub repository and raise an issue calling attention to some
118
+ aspect that could use some TLC or a suggestion or an idea.
data/full_clone.gemspec CHANGED
@@ -14,11 +14,11 @@ Gem::Specification.new do |spec|
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
17
- # spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
18
  spec.require_paths = ["lib"]
20
19
 
21
20
  spec.add_development_dependency 'minitest_visible', ">= 0.1.0"
21
+ spec.add_development_dependency 'mini_readline', ">= 0.4.8"
22
22
  spec.add_development_dependency "bundler", "~> 1.3"
23
23
  spec.add_development_dependency "rake"
24
24
  spec.add_development_dependency 'minitest', "~> 4.7.5"
data/irbt.rb ADDED
@@ -0,0 +1,20 @@
1
+ # coding: utf-8
2
+ # An IRB + full_clone test bed
3
+
4
+ require 'irb'
5
+ $force_alias_read_line_module = true
6
+ require 'mini_readline'
7
+
8
+ puts "Starting an IRB console with full_clone loaded."
9
+
10
+ if ARGV[0] == 'local'
11
+ require_relative 'lib/full_clone'
12
+ puts "full_clone loaded locally: #{FullClone::VERSION}"
13
+
14
+ ARGV.shift
15
+ else
16
+ require 'full_clone'
17
+ puts "full_clone loaded from gem: #{FullClone::VERSION}"
18
+ end
19
+
20
+ IRB.start
@@ -1,3 +1,3 @@
1
1
  module FullClone
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
data/lib/full_clone.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # coding: utf-8
2
+
1
3
  require_relative 'full_clone/version'
2
4
  require_relative 'full_clone/object'
3
5
  require_relative 'full_clone/array'
@@ -12,9 +12,13 @@ Rake::TestTask.new do |t|
12
12
  t.verbose = false
13
13
  end
14
14
 
15
+ desc "Run an IRB Session with full_clone loaded."
16
+ task :console do
17
+ system "ruby irbt.rb local"
18
+ end
19
+
15
20
  desc "What version of full_clone is this?"
16
21
  task :vers do |t|
17
22
  puts
18
23
  puts "full_clone version = #{FullClone::VERSION}"
19
24
  end
20
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: full_clone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Camilleri
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-18 00:00:00.000000000 Z
11
+ date: 2016-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest_visible
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.1.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: mini_readline
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.4.8
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.4.8
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -78,14 +92,15 @@ files:
78
92
  - Gemfile
79
93
  - LICENSE.txt
80
94
  - README.md
81
- - Rakefile
82
95
  - full_clone.gemspec
96
+ - irbt.rb
83
97
  - lib/full_clone.rb
84
98
  - lib/full_clone/array.rb
85
99
  - lib/full_clone/hash.rb
86
100
  - lib/full_clone/object.rb
87
101
  - lib/full_clone/struct.rb
88
102
  - lib/full_clone/version.rb
103
+ - rakefile.rb
89
104
  - test/array_tests.rb
90
105
  - test/deep_clone_tests.rb
91
106
  - test/hash_tests.rb