safe_dup 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +33 -0
- data/irbt.rb +20 -0
- data/lib/safe_dup/version.rb +1 -1
- data/{Rakefile → rakefile.rb} +6 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c853b9fa3c84641d0a931c20bb808415cabe1eae
|
4
|
+
data.tar.gz: 803608d0f50cc8002f5528001bb7d8bff0c10058
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdf8de453fc428b4025592c6d8c3ace6aa5e439ae96e124abdc2072cd55d247e3dc1027213224ba8bbfeda584a5c7b34a1a901fb3aab4968da6dc787a396df35
|
7
|
+
data.tar.gz: e2d4a33e4e06e55c9b4c7a737c08103926626fe22ee4799b141e089bf91e10107b37c71c52b861b81002dd51883646284bbb480db4b8bc50759949920d9168d0
|
data/README.md
CHANGED
@@ -19,6 +19,28 @@ Modifying such a crucial method was considered too risky. Instead, the
|
|
19
19
|
safe_dup method is introduced. This is done to reduce the possibility of
|
20
20
|
breaking existing code that often occurs when monkey patching goes too far.
|
21
21
|
|
22
|
+
## Family Overview
|
23
|
+
|
24
|
+
This gem is a member of a family of four gems that all provide data copying
|
25
|
+
services in a safe, easy to use format. The following outlines the available
|
26
|
+
gems and how to chose from among them.
|
27
|
+
|
28
|
+
Depth / Action | Need to copy all. | Need to copy data only.
|
29
|
+
---------------|------------------------------|------------
|
30
|
+
Need a shallow copy | require 'safe\_clone' | require 'safe\_dup'
|
31
|
+
Need a full copy | require 'full\_clone' | require 'full\_dup'
|
32
|
+
|
33
|
+
<br>**Notes**
|
34
|
+
* Since none of these gems override the default clone and dup
|
35
|
+
methods, the default behaviors remain available. Further, if multiple,
|
36
|
+
differing requirements exists, more than one family member gem may be
|
37
|
+
employed in the same project without fear of conflict.
|
38
|
+
* If multiple family gems are employed, they will each need to be installed and
|
39
|
+
required into the application. See below for details.
|
40
|
+
* Meta-data attributes include the frozen status and singleton methods. However
|
41
|
+
the tainted status is always copied.
|
42
|
+
|
43
|
+
|
22
44
|
## Installation
|
23
45
|
|
24
46
|
Add this line to your application's Gemfile:
|
@@ -33,6 +55,11 @@ Or install it yourself as:
|
|
33
55
|
|
34
56
|
$ gem install safe_dup
|
35
57
|
|
58
|
+
The safe_dup gem is at: ( https://rubygems.org/gems/safe_dup )
|
59
|
+
<br>The safe_clone gem is at: ( https://rubygems.org/gems/safe_clone )
|
60
|
+
<br>The full_dup gem is at: ( https://rubygems.org/gems/full_dup )
|
61
|
+
<br>The full_clone gem is at: ( https://rubygems.org/gems/full_clone )
|
62
|
+
|
36
63
|
## Usage
|
37
64
|
|
38
65
|
require 'safe_dup'
|
@@ -52,6 +79,12 @@ instead of
|
|
52
79
|
It is actually pretty easy to determine where safe_dup needs to be used. It's
|
53
80
|
those places where the dup method is generating unwanted exceptions.
|
54
81
|
|
82
|
+
## Demo
|
83
|
+
|
84
|
+
A test bed for experimenting with the safe_dup gem is available as a rake task:
|
85
|
+
|
86
|
+
$ rake console
|
87
|
+
|
55
88
|
## Performance
|
56
89
|
A reasonable question to raise is "How does safe\_dup compare with just
|
57
90
|
catching the exception and handling it?" The benchmark sets a a realistic
|
data/irbt.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# An IRB + safe_dup 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 safe_dup loaded."
|
9
|
+
|
10
|
+
if ARGV[0] == 'local'
|
11
|
+
require_relative 'lib/safe_dup'
|
12
|
+
puts "safe_dup loaded locally: #{SafeDup::VERSION}"
|
13
|
+
|
14
|
+
ARGV.shift
|
15
|
+
else
|
16
|
+
require 'safe_dup'
|
17
|
+
puts "safe_dup loaded from gem: #{SafeDup::VERSION}"
|
18
|
+
end
|
19
|
+
|
20
|
+
IRB.start
|
data/lib/safe_dup/version.rb
CHANGED
data/{Rakefile → rakefile.rb}
RENAMED
@@ -8,7 +8,12 @@ Rake::TestTask.new do |t|
|
|
8
8
|
t.verbose = false
|
9
9
|
end
|
10
10
|
|
11
|
-
desc "
|
11
|
+
desc "Fire up an IRB session with safe_dup preloaded."
|
12
|
+
task :console do
|
13
|
+
system "ruby irbt.rb local"
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "What version of safe_dup is this?"
|
12
17
|
task :vers do |t|
|
13
18
|
puts
|
14
19
|
puts "safe_dup version = #{SafeDup::VERSION}"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: safe_dup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
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-
|
11
|
+
date: 2016-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest_visible
|
@@ -77,10 +77,11 @@ files:
|
|
77
77
|
- Gemfile
|
78
78
|
- LICENSE.txt
|
79
79
|
- README.md
|
80
|
-
- Rakefile
|
81
80
|
- bench/bench.rb
|
81
|
+
- irbt.rb
|
82
82
|
- lib/safe_dup.rb
|
83
83
|
- lib/safe_dup/version.rb
|
84
|
+
- rakefile.rb
|
84
85
|
- safe_dup.gemspec
|
85
86
|
- test/safe_dup_tests.rb
|
86
87
|
homepage: http://teuthida-technologies.com/
|