multi_xml 0.9.0 → 0.9.1

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: 35c36bec2ca00daa71d6eae5b1f388f5bdf3493d06ade5d6c8aeb54fb2f8762f
4
- data.tar.gz: fe3a14804a79e8dd143ab381b5ef11abf917ce3a1653d6c780d99fa7d6b9dd44
3
+ metadata.gz: d8e4560022692cf83853b50994663cbabfc0bdb943e78c4c2288dff38869bd08
4
+ data.tar.gz: d25368ffc55f43108708b46cc228e7d4506f44d61cb4d371cdb549fe36bfea2b
5
5
  SHA512:
6
- metadata.gz: 5863c814199d20da08c88b6fc52b56186c2e4d0c2c9248d9678c04862dab09cb048473ab86c605a022add743e1b1be91682974cf21c192d8c3eeb98abcbc6011
7
- data.tar.gz: 48fe9f604a468b59a01832187869b0bb118f5a8c63ccb2c8b51c27d2fe00b6bb7aedd3beeb384cc69ee5562b75e5196cb93ac37f79fd6fb68aba9ea82c692dbc
6
+ metadata.gz: 82885e626a6961ffaa1f34d039ba1a4ac0017c917c46f8232413f020252f9b88873643e44ca7c2b5ad1a7e510c2bccaf3757c246c4c2df801600048ee440f4c1
7
+ data.tar.gz: 96ea0d4b0947cdeb5230f07687d94be756379a80db7f7fd5e0484ff5a2b1cbc3407eee3c2ea3dce6e49d2595b0daa2f5ab404d20fda5d71fc8dd9bc0bbc7a748
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ 0.9.1
2
+ -----
3
+ * Fix `MultiXml.method(:load)` resolving to `Kernel#load`. The legacy `MultiXml` constant forwarded calls to `MultiXML` via `method_missing`, but `Module#method` doesn't consult `method_missing`, so `MultiXml.method(:load)` resolved to the inherited `Kernel#load` and crashed with `LoadError` when invoked. Replaces `method_missing` with explicit singleton-method forwarders for every public method on `MultiXML`, mirroring the [analogous fix in MultiJSON](https://github.com/sferik/multi_json/issues/66).
4
+
1
5
  0.9.0
2
6
  -----
3
7
  * Add `MultiXML.with_parser` for fiber-local scoped parser overrides, matching `MultiJSON.with_adapter`. The override lives in `Fiber[:multi_xml_parser]`, so concurrent fibers and threads each see their own parser without racing on a shared module variable; nested calls save and restore the previous value.
@@ -3,5 +3,5 @@ module MultiXML
3
3
  #
4
4
  # @api public
5
5
  # @return [Gem::Version] the gem version
6
- VERSION = Gem::Version.create("0.9.0")
6
+ VERSION = Gem::Version.create("0.9.1")
7
7
  end
data/lib/multi_xml.rb CHANGED
@@ -157,45 +157,35 @@ require_relative "multi_xml/deprecated"
157
157
  #
158
158
  # Downstream code that still writes MultiXml.parse(...) or
159
159
  # rescue MultiXml::ParseError continues to work, but emits a one-time
160
- # deprecation warning pointing at MultiXML. The module forwards every
161
- # method call to {MultiXML} via {.method_missing} and resolves constant
162
- # access via {.const_missing}, so both dotted calls and :: constant
163
- # lookups (including rescue clauses) route through the canonical module.
160
+ # deprecation warning pointing at MultiXML. Each public method on
161
+ # {MultiXML} gets an explicit forwarder defined on this module, and
162
+ # constant access resolves via {.const_missing}, so both dotted calls
163
+ # and :: constant lookups (including rescue clauses) route through
164
+ # the canonical module.
164
165
  #
165
166
  # @api public
166
167
  # @deprecated Use {MultiXML} (all-caps) instead. Will be removed in v1.0.
167
168
  module MultiXml
168
- class << self
169
- # Forward method calls to {MultiXML}, emitting a one-time warning
170
- #
171
- # @api public
172
- # @return [Object] the delegated call's return value
173
- # @example
174
- # MultiXml.parse("<a>1</a>") # delegates to MultiXML.parse
175
- # rubocop:disable Naming/BlockForwarding, Style/ArgumentsForwarding
176
- def method_missing(name, *args, **kwargs, &block)
169
+ # Forward every public method MultiXML exposes through an explicit
170
+ # singleton method on the legacy MultiXml module, so callers that
171
+ # capture the method as a Method object (``MultiXml.method(:load)``)
172
+ # find this forwarder instead of falling back to inherited methods like
173
+ # ``Kernel#load``. The earlier ``method_missing``-based shim left
174
+ # ``MultiXml.method(:load)`` resolving to ``Kernel#load`` (because
175
+ # ``Module#method`` doesn't consult ``method_missing``) so a captured
176
+ # ``MultiXml.method(:load)`` would interpret the XML payload as a file
177
+ # path and crash with ``LoadError``. Forwarding eagerly fixes the
178
+ # capture path while preserving the one-time deprecation warning each
179
+ # call emits.
180
+ (::MultiXML.public_methods - ::Module.public_methods).each do |forwarded|
181
+ define_singleton_method(forwarded) do |*args, **kwargs, &block|
177
182
  ::MultiXML.warn_deprecation_once(:multi_xml_constant,
178
183
  "The MultiXml constant is deprecated and will be removed in v1.0. Use MultiXML instead.")
179
- if ::MultiXML.respond_to?(name)
180
- ::MultiXML.public_send(name, *args, **kwargs, &block)
181
- else
182
- super
183
- end
184
- end
185
- # rubocop:enable Naming/BlockForwarding, Style/ArgumentsForwarding
186
-
187
- # Respond to any method {MultiXML} responds to
188
- #
189
- # @api public
190
- # @param name [Symbol] method name
191
- # @param include_private [Boolean] include private methods
192
- # @return [Boolean] true if {MultiXML} responds to the method
193
- # @example
194
- # MultiXml.respond_to?(:parse) #=> true
195
- def respond_to_missing?(name, include_private)
196
- ::MultiXML.respond_to?(name, include_private)
184
+ ::MultiXML.public_send(forwarded, *args, **kwargs, &block)
197
185
  end
186
+ end
198
187
 
188
+ class << self
199
189
  # Resolve missing constants to their {MultiXML} counterparts
200
190
  #
201
191
  # The lookup is performed with ``inherit: false`` so a stray
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multi_xml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Berlin