evilution 0.22.4 → 0.22.5

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: 64e44290d350e92d6c70bdd99a4a982fa8f0a33cf36062e3fa8f0fa5eea553a8
4
- data.tar.gz: 31c5dbe19058f73d8c8ae2301649ec44127b1b0487955c8b26b2732e1e69f967
3
+ metadata.gz: 8dfc39a794faace7567c4539876cb9c331cba15f62420625aafc8adf9d3fb7bf
4
+ data.tar.gz: e199a8d90e70db722e76fe785968385dc1725297ee6020b31760fdfad5745c70
5
5
  SHA512:
6
- metadata.gz: 24d6294bd7f0ef343fb7b3d4573e1217389e3c1e38ac5a4056da51ac3cda0a298dbd33abae25d2bdd927f82f07d0079f1d7b3530e65ff2efb8acc96778631e46
7
- data.tar.gz: d767b3b380fcfed64b64915e177931d72939d5fbb6a5498676c989daed2f34df969843e1a2c5f04be83e0498bfba2e4198cc65eb04a9904d654db49758904e99
6
+ metadata.gz: 32d62ef27f34042244512d5d52082c4a53d82b0f6de91e924faebd8317d5d2d8c57a5fa53b8b5f3cc6bee325723e62dcfbd0b32d9bc8c2b17f368cde027a93b1
7
+ data.tar.gz: c4695099eb10bbdd2f69995fa95f3f9dcb8dbb3497532758b9177594fb9e098021080924276cf582c5b951dc95e6af39d1d7e2d1fae404f2e451bf8622fefa39
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.22.5] - 2026-04-12
4
+
5
+ ### Fixed
6
+
7
+ - **`ActiveSupport::Concern` modules: all mutations error with `MultipleIncludedBlocks`** — re-evaluating a mutated concern file triggered Rails' guard because `@_included_block` (and `@_prepended_block`) was already set from the original load with a different `source_location`; now `clear_concern_state` removes these instance variables from affected concern modules before `require`/`load`, matching both original file paths and temp-dir copies via subpath suffix so consecutive mutations of the same concern also succeed (#676, PR #678)
8
+
3
9
  ## [0.22.4] - 2026-04-12
4
10
 
5
11
  ### Fixed
@@ -87,6 +87,7 @@ class Evilution::Integration::Base
87
87
  File.write(dest, mutation.mutated_source)
88
88
  $LOAD_PATH.unshift(@temp_dir)
89
89
  displace_loaded_feature(mutation.file_path)
90
+ clear_concern_state(mutation.file_path)
90
91
  require(subpath.delete_suffix(".rb"))
91
92
  end
92
93
 
@@ -95,6 +96,7 @@ class Evilution::Integration::Base
95
96
  dest = File.join(@temp_dir, absolute)
96
97
  FileUtils.mkdir_p(File.dirname(dest))
97
98
  File.write(dest, mutation.mutated_source)
99
+ clear_concern_state(mutation.file_path)
98
100
  load(dest)
99
101
  end
100
102
 
@@ -110,6 +112,35 @@ class Evilution::Integration::Base
110
112
  @temp_dir = nil
111
113
  end
112
114
 
115
+ def clear_concern_state(file_path)
116
+ return unless defined?(ActiveSupport::Concern)
117
+
118
+ absolute = File.expand_path(file_path)
119
+ subpath = resolve_require_subpath(file_path)
120
+
121
+ ObjectSpace.each_object(Module) do |mod|
122
+ next unless mod.singleton_class.ancestors.include?(ActiveSupport::Concern)
123
+
124
+ %i[@_included_block @_prepended_block].each do |ivar|
125
+ next unless mod.instance_variable_defined?(ivar)
126
+
127
+ block = mod.instance_variable_get(ivar)
128
+ block_file = block.source_location&.first
129
+ next unless block_file
130
+
131
+ expanded = File.expand_path(block_file)
132
+ mod.remove_instance_variable(ivar) if source_matches?(expanded, absolute, subpath)
133
+ end
134
+ end
135
+ end
136
+
137
+ 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
142
+ end
143
+
113
144
  def resolve_require_subpath(file_path)
114
145
  absolute = File.expand_path(file_path)
115
146
  best_subpath = nil
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Evilution
4
- VERSION = "0.22.4"
4
+ VERSION = "0.22.5"
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.4
4
+ version: 0.22.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Kiselev