monkey_lens 0.3.0 → 0.4.0

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: 9c3c706d59eb29d1ad4de38b99d3e5539891aa630fac314d39dc16fa3b3fbdbd
4
- data.tar.gz: 60e610c3c01434eadb5edc1e4dc2dfe699f48d914c685bd0b1659cff1649f0f5
3
+ metadata.gz: 731b73d48ea7d97b0d3ce1f66a5f246fee22298053e4011c2f1e3a8fd8060f57
4
+ data.tar.gz: a3ddb66de6351e173ee7db2b785949e1ea602487192c0a899396ef345efe745f
5
5
  SHA512:
6
- metadata.gz: 5908c484375db223128fadb7cf724de9f79d0a14c8e713a886962a965ae00882b73762d05a4f360fd3761464811f749fcbadcb6dff2644ca1f9c6a17f17d080e
7
- data.tar.gz: 7f64d16a2bc0035ed66caca551786d53495b1bed098cbfd6cad47f7532cb177ac73feec73e83e3c4108ec24c3545c14588fd1822c10d85fc88af5693a05f7d6e
6
+ metadata.gz: 5939da5fffbbb4c203da4f5d2168a3a04e03b578c67e323ef80b54bacbf7265ceec4916bea7cf87502b8977e5d60907e52c1306eb3ec35373f8dae701efb5ab9
7
+ data.tar.gz: 22c9b607eb22bf61e6455346fc10b07eae60d3ef3d8186fcb8e7b238c3996a689381c3fc0b503b1df890db617b48e74a4109f5e31d557af26d0923f488b37d80
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  All notable changes to MonkeyLens are documented here.
4
4
 
5
+ ## 0.4.0 — 2026-08-14
6
+
7
+ - Record `original_name`, `aliases`, and `super_owner` on every captured method.
8
+ - Diff `alias_changed` and `super_owner_changed` so alias_method and prepend-layer shifts are visible.
9
+ - Inspect output includes aliases and the super-method owner.
10
+
5
11
  ## 0.3.0 — 2026-08-11
6
12
 
7
13
  - Added `MonkeyLens::Provenance` to attribute method `source_location` to gem, app, stdlib, or eval origins.
data/README.md CHANGED
@@ -152,11 +152,13 @@ end
152
152
  | Change | Default severity |
153
153
  | --- | --- |
154
154
  | Method owner changed | Critical |
155
+ | Super-method owner changed | High |
155
156
  | Method source changed | High |
156
157
  | Method removed | High |
157
158
  | Prepend/ancestor order changed | High |
158
159
  | Method signature changed | Medium |
159
160
  | Visibility changed | Medium |
161
+ | Method aliases changed | Medium |
160
162
  | Method added | Low |
161
163
 
162
164
  The threshold is configured with `fail_on: low|medium|high|critical`.
@@ -55,6 +55,9 @@ module MonkeyLens
55
55
 
56
56
  method = receiver.instance_method(method_name)
57
57
  visibility = VISIBILITIES.find { |candidate| receiver.public_send("#{candidate}_method_defined?", method_name) }
58
+ aliases = aliases_for(receiver, method_name, method)
59
+ super_method = method.super_method
60
+ original = method.respond_to?(:original_name) ? method.original_name.to_s : method_name.to_s
58
61
 
59
62
  [method_name.to_s, {
60
63
  "owner" => constant_name(method.owner),
@@ -62,7 +65,10 @@ module MonkeyLens
62
65
  "parameters" => method.parameters.map { |kind, parameter| [kind.to_s, parameter&.to_s] },
63
66
  "arity" => method.arity,
64
67
  "source_location" => normalize_source(method.source_location),
65
- "provenance" => provenance_for(method.source_location)
68
+ "provenance" => provenance_for(method.source_location),
69
+ "original_name" => original,
70
+ "aliases" => aliases,
71
+ "super_owner" => super_method && constant_name(super_method.owner)
66
72
  }.compact]
67
73
  rescue NameError
68
74
  nil
@@ -91,5 +97,15 @@ module MonkeyLens
91
97
 
92
98
  Provenance.for_source_location(location)&.to_h
93
99
  end
100
+
101
+ def aliases_for(receiver, method_name, method)
102
+ receiver.instance_methods(true).filter_map do |other|
103
+ next if other == method_name
104
+
105
+ other.to_s if receiver.instance_method(other) == method
106
+ rescue NameError
107
+ nil
108
+ end.sort
109
+ end
94
110
  end
95
111
  end
@@ -104,7 +104,10 @@ module MonkeyLens
104
104
  source = method.fetch("source_location")&.join(":") || "native"
105
105
  provenance = method["provenance"]
106
106
  provenance_text = provenance ? " provenance=#{provenance.fetch("kind")}" : ""
107
- @out.puts " ##{name} [#{method.fetch("visibility")}] owner=#{method.fetch("owner")} source=#{source}#{provenance_text}"
107
+ aliases = Array(method["aliases"])
108
+ alias_text = aliases.empty? ? "" : " aliases=#{aliases.join(",")}"
109
+ super_text = method["super_owner"] ? " super=#{method["super_owner"]}" : ""
110
+ @out.puts " ##{name} [#{method.fetch("visibility")}] owner=#{method.fetch("owner")} source=#{source}#{provenance_text}#{alias_text}#{super_text}"
108
111
  end
109
112
  0
110
113
  end
@@ -110,6 +110,12 @@ module MonkeyLens
110
110
  if before.fetch("visibility") != after.fetch("visibility")
111
111
  changes << change("visibility_changed", "medium", target, method_id:, before: before.fetch("visibility"), after: after.fetch("visibility"), message: "method visibility changed")
112
112
  end
113
+ if before.fetch("aliases", []) != after.fetch("aliases", [])
114
+ changes << change("alias_changed", "medium", target, method_id:, before: before.fetch("aliases", []), after: after.fetch("aliases", []), message: "method aliases changed")
115
+ end
116
+ if before.fetch("super_owner", nil) != after.fetch("super_owner", nil)
117
+ changes << change("super_owner_changed", "high", target, method_id:, before: before.fetch("super_owner", nil), after: after.fetch("super_owner", nil), message: "super-method owner changed")
118
+ end
113
119
  end
114
120
 
115
121
  def signature(method)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MonkeyLens
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monkey_lens
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Looney
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - "~>"
17
17
  - !ruby/object:Gem::Version
18
- version: '5.0'
18
+ version: '6.0'
19
19
  type: :development
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - "~>"
24
24
  - !ruby/object:Gem::Version
25
- version: '5.0'
25
+ version: '6.0'
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: rake
28
28
  requirement: !ruby/object:Gem::Requirement