core-copy 0.0.0 → 0.0.1

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
  SHA256:
3
- metadata.gz: d191a1b7d4325322daf22cafb2ea579ef1f82e7f21b2ec1a129a61e3f44fa6be
4
- data.tar.gz: 7885318f05b951dd03a5cab32696d3736c2c38143a9e33589c2a221c8ba0ab7a
3
+ metadata.gz: 701d71057dbc8751c389d663cb65c138be3c72671fde3ce15c816265287b56af
4
+ data.tar.gz: 390ce6bedd93a95b9200d027ee594ded6ecca1094b9f2cf8cd36f93e2f9bb005
5
5
  SHA512:
6
- metadata.gz: 578e6e73ce15d0aa061b8bb9d6e04fe9c5d8e1553056021e5aa806cc2a755530d864ceb06d051fc13907b7042f08f0f5a25b39f6f1337a043ed4c6aa82142e8c
7
- data.tar.gz: 9b2cad7f168c2f2bc954bd2a5495705e6931c4263227430ccd75e62f9c58cf2370fc5cf655562a9dc9422c7ac554142806f3e0a37e84ff7251753c6a1de1a15e
6
+ metadata.gz: 59ec5c152bf6ea5e129a6d357fb8af8ad4b1e6f0b874f0e4721d78bb948e34499b7df77faec86b92d14b3549c3fd9b9fbe15a301131be9b08a23777dd82846c9
7
+ data.tar.gz: d2f3942dec31059edc06998b06c308559275e67d897bba464aacb6c21298e7002ee245948d7dc92a9b65b1ea2fd79d28658638db2f77010caa57dceea9b21ea4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [v0.0.1](https://github.com/metabahn/corerb/releases/tag/2021-05-22)
2
+
3
+ *released on 2021-05-22*
4
+
5
+ * `fix` [#33](https://github.com/metabahn/corerb/pull/33) Resolve several differences between supported ruby versions ([bryanp](https://github.com/bryanp))
6
+ * `fix` [#32](https://github.com/metabahn/corerb/pull/32) Add core-local as a dependency to core-copy ([bryanp](https://github.com/bryanp))
7
+
1
8
  ## [v0.0.0](https://github.com/metabahn/corerb/releases/tag/2021-03-17)
2
9
 
3
10
  *released on 2021-03-17*
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Core
4
4
  module Copy
5
- VERSION = "0.0.0"
5
+ VERSION = "0.0.1"
6
6
 
7
7
  def self.version
8
8
  VERSION
@@ -5,25 +5,46 @@ require "core/local"
5
5
  module Refine
6
6
  module Object
7
7
  module Copy
8
+ DEFAULT = ::Object.new
9
+
8
10
  refine ::Object do
9
11
  # [public] Copies the object using `clone`.
10
12
  #
11
- def copy(freeze: nil)
12
- clone(freeze: freeze)
13
+ if RbConfig::CONFIG["RUBY_PROGRAM_VERSION"] < "3"
14
+ def copy(freeze: DEFAULT)
15
+ should_freeze = resolve_freeze_argument(freeze)
16
+
17
+ value = clone(freeze: should_freeze)
18
+ value.freeze if should_freeze
19
+ value
20
+ end
21
+ else
22
+ def copy(freeze: DEFAULT)
23
+ clone(freeze: resolve_freeze_argument(freeze))
24
+ end
25
+ end
26
+
27
+ private def resolve_freeze_argument(value)
28
+ case value
29
+ when DEFAULT
30
+ frozen?
31
+ else
32
+ !!value
33
+ end
13
34
  end
14
35
  end
15
36
 
16
37
  refine Array do
17
38
  # [public] Copies the array, along with each value.
18
39
  #
19
- def copy(freeze: nil)
40
+ def copy(freeze: DEFAULT)
20
41
  unless Copy.copying?(self)
21
42
  Copy.prevent_recursion(self) do
22
43
  array = map { |value|
23
44
  value.copy(freeze: freeze)
24
45
  }
25
46
 
26
- array.freeze if freeze || (freeze.nil? && frozen?)
47
+ array.freeze if resolve_freeze_argument(freeze)
27
48
 
28
49
  array
29
50
  end
@@ -34,7 +55,7 @@ module Refine
34
55
  refine Hash do
35
56
  # [public] Copies the hash, along with each key and value.
36
57
  #
37
- def copy(freeze: nil)
58
+ def copy(freeze: DEFAULT)
38
59
  unless Copy.copying?(self)
39
60
  Copy.prevent_recursion(self) do
40
61
  hash = {}
@@ -43,7 +64,7 @@ module Refine
43
64
  hash[key.copy(freeze: freeze)] = value.copy(freeze: freeze)
44
65
  end
45
66
 
46
- hash.freeze if freeze || (freeze.nil? && frozen?)
67
+ hash.freeze if resolve_freeze_argument(freeze)
47
68
 
48
69
  hash
49
70
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: core-copy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bryan Powell
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-17 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2021-05-22 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: core-local
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.0'
13
27
  description: Manage how internal object state is copied.
14
28
  email: bryan@metabahn.com
15
29
  executables: []
@@ -33,14 +47,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
33
47
  requirements:
34
48
  - - ">="
35
49
  - !ruby/object:Gem::Version
36
- version: 2.5.0
50
+ version: 2.6.7
37
51
  required_rubygems_version: !ruby/object:Gem::Requirement
38
52
  requirements:
39
53
  - - ">="
40
54
  - !ruby/object:Gem::Version
41
55
  version: '0'
42
56
  requirements: []
43
- rubygems_version: 3.2.4
57
+ rubygems_version: 3.2.15
44
58
  signing_key:
45
59
  specification_version: 4
46
60
  summary: Manage how internal object state is copied.