evilution 0.22.5 → 0.22.6

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: 8dfc39a794faace7567c4539876cb9c331cba15f62420625aafc8adf9d3fb7bf
4
- data.tar.gz: e199a8d90e70db722e76fe785968385dc1725297ee6020b31760fdfad5745c70
3
+ metadata.gz: f88a719ecd12ca2576f1254f3ef1771359f64345eea28e3537e0d9dae38e2c78
4
+ data.tar.gz: 01c65258b5a9d496a566437b74460ff77175d0dbea9988643d048df3b2e18171
5
5
  SHA512:
6
- metadata.gz: 32d62ef27f34042244512d5d52082c4a53d82b0f6de91e924faebd8317d5d2d8c57a5fa53b8b5f3cc6bee325723e62dcfbd0b32d9bc8c2b17f368cde027a93b1
7
- data.tar.gz: c4695099eb10bbdd2f69995fa95f3f9dcb8dbb3497532758b9177594fb9e098021080924276cf582c5b951dc95e6af39d1d7e2d1fae404f2e451bf8622fefa39
6
+ metadata.gz: 136e6f94f55a9e312b777573bd73391d6ec7d05ac8c7455817341589edf018002836db6e550255ff16deb974e6a320a8e818e08661b7918bd2ac6e2f4e85aea1
7
+ data.tar.gz: 8e48faca42c452ba1d8ba1b8800deaf1eafc89d264997f34dc04840324296d2431fdc7e9ccb31f2cff5127862adeb818c15a10da5d060301bdcae0b0352d0cf4
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.22.6] - 2026-04-12
4
+
5
+ ### Fixed
6
+
7
+ - **Zeitwerk re-autoloads original file during mutation load** — Zeitwerk's `const_added` hook re-autoloaded the original source when a module constant was reopened from a temp-dir copy, re-setting `@_included_block` after `clear_concern_state` already removed it; now `pin_autoloaded_constants` resolves all module/class constants from the source via `Object.const_get` before loading, preventing the autoloader from re-triggering (#680)
8
+
3
9
  ## [0.22.5] - 2026-04-12
4
10
 
5
11
  ### Fixed
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "fileutils"
4
+ require "prism"
4
5
  require "tmpdir"
5
6
  require_relative "../integration"
6
7
  require_relative "../temp_dir_tracker"
@@ -87,6 +88,7 @@ class Evilution::Integration::Base
87
88
  File.write(dest, mutation.mutated_source)
88
89
  $LOAD_PATH.unshift(@temp_dir)
89
90
  displace_loaded_feature(mutation.file_path)
91
+ pin_autoloaded_constants(mutation.original_source)
90
92
  clear_concern_state(mutation.file_path)
91
93
  require(subpath.delete_suffix(".rb"))
92
94
  end
@@ -96,6 +98,7 @@ class Evilution::Integration::Base
96
98
  dest = File.join(@temp_dir, absolute)
97
99
  FileUtils.mkdir_p(File.dirname(dest))
98
100
  File.write(dest, mutation.mutated_source)
101
+ pin_autoloaded_constants(mutation.original_source)
99
102
  clear_concern_state(mutation.file_path)
100
103
  load(dest)
101
104
  end
@@ -112,6 +115,30 @@ class Evilution::Integration::Base
112
115
  @temp_dir = nil
113
116
  end
114
117
 
118
+ def pin_autoloaded_constants(source)
119
+ collect_constant_names(Prism.parse(source).value).each do |name|
120
+ Object.const_get(name) if Object.const_defined?(name, false)
121
+ rescue NameError # :nodoc:
122
+ nil
123
+ end
124
+ end
125
+
126
+ def collect_constant_names(node, nesting = [])
127
+ names = []
128
+ case node
129
+ when Prism::ModuleNode, Prism::ClassNode
130
+ const = node.constant_path.full_name
131
+ qualified = nesting.any? && !const.include?("::") ? "#{nesting.join("::")}::#{const}" : const
132
+ names << qualified
133
+ names.concat(collect_constant_names(node.body, nesting + [const])) if node.body
134
+ when Prism::ProgramNode
135
+ names.concat(collect_constant_names(node.statements, nesting)) if node.statements
136
+ when Prism::StatementsNode
137
+ node.body.each { |child| names.concat(collect_constant_names(child, nesting)) }
138
+ end
139
+ names
140
+ end
141
+
115
142
  def clear_concern_state(file_path)
116
143
  return unless defined?(ActiveSupport::Concern)
117
144
 
@@ -135,10 +162,7 @@ class Evilution::Integration::Base
135
162
  end
136
163
 
137
164
  def source_matches?(block_path, absolute, subpath)
138
- return true if block_path == absolute
139
- return true if subpath && block_path.end_with?("/#{subpath}")
140
-
141
- false
165
+ block_path == absolute || (subpath && block_path.end_with?("/#{subpath}"))
142
166
  end
143
167
 
144
168
  def resolve_require_subpath(file_path)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Evilution
4
- VERSION = "0.22.5"
4
+ VERSION = "0.22.6"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: evilution
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.22.5
4
+ version: 0.22.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Kiselev