safe_clone 0.0.8 → 1.0.3

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
- SHA1:
3
- metadata.gz: c54291db91a02ba2c6051e1cd100cdfc1ce4a178
4
- data.tar.gz: 8a518a9f94d888be31eb81e00dda2fdfd467ef8a
2
+ SHA256:
3
+ metadata.gz: f5c988942602b1795ede67effed38ffcacc8ffc52c5fa5226708a954070735f7
4
+ data.tar.gz: 481ad67eb3df2e17ad886ea8c2c3a905440812dcbe11203b51e72d86f34ae12a
5
5
  SHA512:
6
- metadata.gz: b8dce83b680dabab18d8501201528bc07e87676b48abbf935627955fefcbf1b04f32bfadcfa8034211d0c39dfb56b6c77da8923c37691ee4c277cb99062d83a3
7
- data.tar.gz: 0e76392ffc621ad7b5e5890f9bf92ebc5ec14b94fc6a84a1a7cdb54c7ac6c8875d40e3ca0fbf542f798771f05c00a41babc38016ff48cea3490d0280ebab1981
6
+ metadata.gz: a39d2f0d51a49f6dfda438cd37bc1fac7b859f6813e726d990fbb1c45c74e96bee2eb6e1ee1d50ad7dca653fd35fe4b71543bdc48f353a14993ad6c7b2436e3b
7
+ data.tar.gz: 1c9fd8d4891c7d137ce21381a94a59bb7305a84e2ba6cacb1f68413afa50179e8b0aa710c7034bf64a5168323c50c151bbe2ff47d12beec0c5ca4841222e4676
data/README.md CHANGED
@@ -6,9 +6,10 @@ The justification for this uncharacteristic strictness is not at all clear, but
6
6
  it does mean that the clone operation must be applied with great care.
7
7
 
8
8
  Unlike the standard clone method, the safe\_clone method does not throw an
9
- exception when sent to un-clonable value objects like 42 or true. These values
10
- simply return themselves. This is correct because those types of objects do
11
- not _need_ to be cloned. Instead of having a fit, the code just works!
9
+ exception when it sees un-clonable value objects like 42 or true. These values
10
+ simply return themselves. This is deemed correct because those types of objects
11
+ are immutable and do not need to be duped. Instead of raising an exception,
12
+ the code returns the immutable object instead.
12
13
 
13
14
  On a note about performance, this gem does not just rescue the exceptions
14
15
  normally generated by clone, it prevents them from occurring and wasting time
@@ -190,3 +191,13 @@ Overall: Shorter code _and_ faster. Winner, winner, chicken dinner!
190
191
  Go to the GitHub repository and raise an issue calling attention to some
191
192
  aspect that could use some TLC or a suggestion or an idea.
192
193
 
194
+ ## License
195
+
196
+ The gem is available as open source under the terms of the
197
+ [MIT License](./LICENSE.txt).
198
+
199
+ ## Code of Conduct
200
+
201
+ Everyone interacting in the fully_freeze project’s codebases, issue trackers,
202
+ chat rooms and mailing lists is expected to follow the
203
+ [code of conduct](./CODE_OF_CONDUCT.md).
data/lib/safe_clone.rb CHANGED
@@ -1,19 +1,53 @@
1
+ # coding: utf-8
2
+
1
3
  require_relative "safe_clone/version"
2
4
 
5
+ # The default safe clone is Ruby clone.
3
6
  class Object
4
7
  #By default, reference types use the clone method.
5
- def safe_clone; self.clone; end
8
+ def safe_clone
9
+ clone
10
+ end
6
11
  end
7
12
 
8
- #For value types, just return self!
13
+ # For value types, safe clone just returns self.
9
14
  module SafeClone
10
- def safe_clone; self; end
15
+ def safe_clone
16
+ self
17
+ end
18
+ end
19
+
20
+ # Numeric does safe clone.
21
+ class Numeric
22
+ include SafeClone
23
+ end
24
+
25
+ # NilClass does safe clone.
26
+ class NilClass
27
+ include SafeClone
28
+ end
29
+
30
+ # TrueClass does safe clone.
31
+ class TrueClass
32
+ include SafeClone
11
33
  end
12
34
 
13
- #Update the Ruby value types.
14
- class Numeric; include SafeClone; end
15
- class NilClass; include SafeClone; end
16
- class TrueClass; include SafeClone; end
17
- class FalseClass; include SafeClone; end
18
- class Symbol; include SafeClone; end
19
- class Regexp; include SafeClone; end
35
+ # FalseClass does safe clone.
36
+ class FalseClass
37
+ include SafeClone
38
+ end
39
+
40
+ # Symbols do safe clone.
41
+ class Symbol
42
+ include SafeClone
43
+ end
44
+
45
+ # Regular expressions do safe clone.
46
+ class Regexp
47
+ include SafeClone
48
+ end
49
+
50
+ # Threads do safe clone.
51
+ class Thread
52
+ include SafeClone
53
+ end
@@ -1,3 +1,3 @@
1
1
  module SafeClone
2
- VERSION = "0.0.8"
2
+ VERSION = "1.0.3"
3
3
  end
data/rakefile.rb CHANGED
@@ -8,6 +8,11 @@ Rake::TestTask.new do |t|
8
8
  t.verbose = false
9
9
  end
10
10
 
11
+ desc "Run a scan for smelly code!"
12
+ task :reek do |t|
13
+ `reek --no-color lib > reek.txt`
14
+ end
15
+
11
16
  desc "Fire up an IRB session with safe_clone preloaded."
12
17
  task :console do
13
18
  system "ruby irbt.rb local"
data/reek.txt ADDED
@@ -0,0 +1 @@
1
+ 0 total warnings
data/safe_clone.gemspec CHANGED
@@ -17,9 +17,8 @@ Gem::Specification.new do |spec|
17
17
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
18
  spec.require_paths = ["lib"]
19
19
 
20
- spec.add_development_dependency "rake", "~> 12.0"
21
- spec.add_development_dependency "bundler", "~> 1.3"
20
+ spec.add_development_dependency "rake", ">= 12.3.3"
21
+ spec.add_development_dependency "bundler", ">= 2.1.0"
22
22
  spec.add_development_dependency 'minitest', "~> 5.7"
23
- spec.add_development_dependency 'minitest_visible', "~> 0.1"
24
-
23
+ spec.add_development_dependency 'reek', "~> 5.0.2"
25
24
  end
@@ -3,14 +3,10 @@
3
3
  require_relative '../lib/safe_clone'
4
4
  gem 'minitest'
5
5
  require 'minitest/autorun'
6
- require 'minitest_visible'
7
6
 
8
7
  #Test the monkey patches applied to the Object class.
9
8
  class SafeCloneTester < Minitest::Test
10
9
 
11
- #Track mini-test progress.
12
- include MinitestVisible
13
-
14
10
  def test_for_safe_value_cloning
15
11
  assert_equal((6).safe_clone, 6)
16
12
  assert_equal((6).safe_clone.object_id, (6).object_id)
@@ -24,7 +20,7 @@ class SafeCloneTester < Minitest::Test
24
20
  assert_equal((false).safe_clone, false)
25
21
  assert_equal((false).safe_clone.object_id, (false).object_id)
26
22
 
27
- assert_equal((nil).safe_clone, nil)
23
+ assert_nil((nil).safe_clone)
28
24
  assert_equal((nil).safe_clone.object_id, (nil).object_id)
29
25
 
30
26
  rex = /ABC/
metadata CHANGED
@@ -1,43 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: safe_clone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 1.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: 2017-02-14 00:00:00.000000000 Z
11
+ date: 2021-05-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '12.0'
19
+ version: 12.3.3
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '12.0'
26
+ version: 12.3.3
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.3'
33
+ version: 2.1.0
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: '1.3'
40
+ version: 2.1.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -53,19 +53,19 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '5.7'
55
55
  - !ruby/object:Gem::Dependency
56
- name: minitest_visible
56
+ name: reek
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '0.1'
61
+ version: 5.0.2
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: '0.1'
68
+ version: 5.0.2
69
69
  description: A safer version of the clone method that avoids unnecessary exceptions.
70
70
  email:
71
71
  - peter.c.camilleri@gmail.com
@@ -83,6 +83,7 @@ files:
83
83
  - lib/safe_clone.rb
84
84
  - lib/safe_clone/version.rb
85
85
  - rakefile.rb
86
+ - reek.txt
86
87
  - safe_clone.gemspec
87
88
  - test/safe_clone_tests.rb
88
89
  homepage: https://github.com/PeterCamilleri/safe_clone
@@ -104,11 +105,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
105
  - !ruby/object:Gem::Version
105
106
  version: '0'
106
107
  requirements: []
107
- rubyforge_project:
108
- rubygems_version: 2.2.3
108
+ rubygems_version: 3.2.17
109
109
  signing_key:
110
110
  specification_version: 4
111
111
  summary: A safer version of the clone method.
112
112
  test_files:
113
113
  - test/safe_clone_tests.rb
114
- has_rdoc: