recursive-open-struct 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4474b5a862c6ea4da4f2c930664880ca70a01f75c077a2e9952fd80ed2d26da
4
- data.tar.gz: dcea4c80ebe98a5f91f9ea40b2b7e82cc219b259eae83b62a00329f8075cc85a
3
+ metadata.gz: 3cc972f20fd1aba4f8eea6fe1766c17c7d9e663a3ed999e8375549ac37ae4b08
4
+ data.tar.gz: 9c0d0230d431aedeae47f0f2026d77196dfb230c3ebe9359763b4265c9a4c4d6
5
5
  SHA512:
6
- metadata.gz: e8698402e67013a209a3434235e26201550c2249db8ae82480ec2208bdd0c83fb6524be046ecb4af3ed8cfe09adebd513a383d56b8b40d91f2c973fcd1f18196
7
- data.tar.gz: a15827f31947ca85607086b9cda61ab18b4421bb310dd3034ca4dd39ef43ecf5215d599103cb897152924d6faa1ae94e0bc800cf197c5e96ab50fc794c547a2c
6
+ metadata.gz: dcdc725048e24182c562551875b2fa90d100248008af5dd4a974bb8df82f48ec5f618b3d76458d16f868b76b55263e96d3576a6d92f5ace69979beb29ae3213f
7
+ data.tar.gz: d67c50798fcaa7ca49003a924e57df0a22e83a5d688ef6ff90b61f462855f2b6ef8882e5873c0994558416030a9b265fe60cccfe586fd5bf9688e463d92279fe
@@ -1,22 +1,22 @@
1
1
  ---
2
2
  language: ruby
3
3
  rvm:
4
- # No longer supported
5
- # - 1.9.3 # json gem now requires Ruby ~> 2.0
4
+ # No longer supported (but test anyways)
6
5
  - 2.0.0
7
6
  - 2.1.10
8
7
  - 2.2.10
9
8
  - jruby-19mode
10
- # Current stable supported by Travis
11
9
  - 2.3.8
12
- - 2.4.9
13
- - 2.5.7
14
- - 2.6.5
15
- - 2.7.0
10
+ - 2.4.10
11
+ # Current stable supported by Travis
12
+ - 2.5.8
13
+ - 2.6.6
14
+ - 2.7.1
16
15
  - jruby-9.1.9.0
17
16
  # Future
18
17
  - ruby-head
19
18
  - jruby-head
19
+ - truffleruby-head
20
20
  sudo: false
21
21
  matrix:
22
22
  allow_failures:
@@ -25,7 +25,9 @@ matrix:
25
25
  - rvm: 2.1.10
26
26
  - rvm: 2.2.10
27
27
  - rvm: 2.3.8
28
+ - rvm: 2.4.10
28
29
  - rvm: jruby-19mode
29
30
  # Future
30
31
  - rvm: ruby-head
31
32
  - rvm: jruby-head
33
+ - rvm: truffleruby-head
@@ -8,6 +8,8 @@ Recursive-open-struct was written by these fine people:
8
8
  * Ewoud Kohl van Wijngaarden <ewoud@kohlvanwijngaarden.nl>
9
9
  * Federico Aloi <federico.aloi@gmail.com>
10
10
  * fervic <roberto@runawaybit.com>
11
+ * Igor Victor <gogainda@yandex.ru>
12
+ * Jean Boussier <jean.boussier@gmail.com>
11
13
  * Joe Rafaniello <jrafanie@redhat.com>
12
14
  * Kris Dekeyser <kris.dekeyser@libis.be>
13
15
  * Matt Culpepper <matt@culpepper.co>
@@ -1,3 +1,13 @@
1
+ 1.1.3 / 2020/10/15
2
+ ==================
3
+
4
+ * No longer officially supporting Ruby 2.4.x, but compatiblity continues.
5
+ * [#68](https://github.com/aetherknight/recursive-open-struct/pull/68): Igor
6
+ Victor: Add truffleruby-head to travis
7
+ * FIX [#67](https://github.com/aetherknight/recursive-open-struct/pull/67):
8
+ Jean Boussier: Support upstream changes to OpenStruct in ruby-head (Ruby
9
+ 3.0.0-dev)
10
+
1
11
  1.1.2 / 2020/06/20
2
12
  ==================
3
13
 
@@ -39,13 +39,16 @@ class RecursiveOpenStruct < OpenStruct
39
39
  @sub_elements = {}
40
40
  end
41
41
 
42
- def initialize_copy(orig)
43
- super
44
42
 
45
- # deep copy the table to separate the two objects
46
- @table = @deep_dup.call(orig.instance_variable_get(:@table))
47
- # Forget any memoized sub-elements
48
- @sub_elements = {}
43
+ if OpenStruct.public_instance_methods.include?(:initialize_copy)
44
+ def initialize_copy(orig)
45
+ super
46
+
47
+ # deep copy the table to separate the two objects
48
+ @table = @deep_dup.call(@table)
49
+ # Forget any memoized sub-elements
50
+ @sub_elements = {}
51
+ end
49
52
  end
50
53
 
51
54
  def to_h
@@ -56,6 +59,19 @@ class RecursiveOpenStruct < OpenStruct
56
59
  # itself to be a "kind of" Hash.
57
60
  alias_method :to_hash, :to_h
58
61
 
62
+ # Continue supporting older rubies -- JRuby 9.1.x.x is still considered
63
+ # stable, but is based on Ruby
64
+ # 2.3.x and so uses :modifiable instead of :modifiable?. Furthermore, if
65
+ # :modifiable is private, then make :modifiable? private too.
66
+ if !OpenStruct.private_instance_methods.include?(:modifiable?)
67
+ if OpenStruct.private_instance_methods.include?(:modifiable)
68
+ alias_method :modifiable?, :modifiable
69
+ elsif OpenStruct.public_instance_methods.include?(:modifiable)
70
+ alias_method :modifiable?, :modifiable
71
+ private :modifiable?
72
+ end
73
+ end
74
+
59
75
  def [](name)
60
76
  key_name = _get_key_from_table_(name)
61
77
  v = @table[key_name]
@@ -69,11 +85,19 @@ class RecursiveOpenStruct < OpenStruct
69
85
  end
70
86
  end
71
87
 
72
- def []=(name, value)
73
- key_name = _get_key_from_table_(name)
74
- tbl = modifiable? # Ensure we are modifiable
75
- @sub_elements.delete(key_name)
76
- tbl[key_name] = value
88
+ if private_instance_methods.include?(:modifiable?) || public_instance_methods.include?(:modifiable?)
89
+ def []=(name, value)
90
+ key_name = _get_key_from_table_(name)
91
+ tbl = modifiable? # Ensure we are modifiable
92
+ @sub_elements.delete(key_name)
93
+ tbl[key_name] = value
94
+ end
95
+ else
96
+ def []=(name, value)
97
+ key_name = _get_key_from_table_(name)
98
+ @table[key_name] = value # raises if self is frozen in Ruby 3.0
99
+ @sub_elements.delete(key_name)
100
+ end
77
101
  end
78
102
 
79
103
  # Makes sure ROS responds as expected on #respond_to? and #method requests
@@ -82,17 +106,6 @@ class RecursiveOpenStruct < OpenStruct
82
106
  @table.key?(mname) || super
83
107
  end
84
108
 
85
- # Continue supporting older rubies -- JRuby 9.1.x.x is still considered
86
- # stable, but is based on Ruby
87
- # 2.3.x and so uses :modifiable instead of :modifiable?. Furthermore, if
88
- # :modifiable is private, then make :modifiable? private too.
89
- if !OpenStruct.private_instance_methods.include?(:modifiable?)
90
- alias_method :modifiable?, :modifiable
91
- if OpenStruct.private_instance_methods.include?(:modifiable)
92
- private :modifiable?
93
- end
94
- end
95
-
96
109
  # Adapted implementation of method_missing to accommodate the differences
97
110
  # between ROS and OS.
98
111
  def method_missing(mid, *args)
@@ -155,6 +168,16 @@ class RecursiveOpenStruct < OpenStruct
155
168
 
156
169
  private
157
170
 
171
+ unless OpenStruct.public_instance_methods.include?(:initialize_copy)
172
+ def initialize_dup(orig)
173
+ super
174
+ # deep copy the table to separate the two objects
175
+ @table = @deep_dup.call(@table)
176
+ # Forget any memoized sub-elements
177
+ @sub_elements = {}
178
+ end
179
+ end
180
+
158
181
  def _get_key_from_table_(name)
159
182
  return name.to_s if @table.has_key?(name.to_s)
160
183
  return name.to_sym if @table.has_key?(name.to_sym)
@@ -3,5 +3,5 @@
3
3
  require 'ostruct'
4
4
 
5
5
  class RecursiveOpenStruct < OpenStruct
6
- VERSION = "1.1.2"
6
+ VERSION = "1.1.3"
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recursive-open-struct
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - William (B.J.) Snow Orvis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-21 00:00:00.000000000 Z
11
+ date: 2020-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler