monkey_bars 0.2.0 → 0.2.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 +4 -4
- data/README.md +2 -0
- data/docs/llm-usage.md +5 -0
- data/lib/monkey_bars/errors.rb +6 -0
- data/lib/monkey_bars/validation.rb +4 -4
- data/lib/monkey_bars/version.rb +1 -1
- data/lib/monkey_bars.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 959654729be5d09d997d89340df3d00652a0a39f962cbf0f87a3223a24b22195
|
|
4
|
+
data.tar.gz: b36eaea242ef45cb939040f6436af3ed3f9cb806f261141ab5c68e9ba7c24967
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5084d4cc7c224bf0fcf5eeaae3aa02da22ea2b5cac93e8561983bb1d1d3d61a371f7a5401d319117b9efce894ff2e85c1f908a7e2a8777d585791160a4959359
|
|
7
|
+
data.tar.gz: 4633ed06204dd319134fd7c05ff437c649c1c441ab890abe4b3c51b38bcc02c0bc976c41f7e634d17b9bc461b2d0294007bc055f82fa8c71b47e4770322eacd2
|
data/README.md
CHANGED
|
@@ -73,6 +73,7 @@ declared inside a block and then applied with `patch` (immediately) or
|
|
|
73
73
|
- `patch!` applies a prepared patch
|
|
74
74
|
|
|
75
75
|
If `patch!` runs without any methods or constants defined, it emits a warning.
|
|
76
|
+
Calling `prepare_for_patching` or `patch!` more than once raises an error.
|
|
76
77
|
|
|
77
78
|
The `monkey` can be:
|
|
78
79
|
|
|
@@ -242,6 +243,7 @@ MonkeyBars raises specific errors to keep patches safe and explicit:
|
|
|
242
243
|
- `MonkeyBars::PatchConstantNotFoundError`
|
|
243
244
|
- `MonkeyBars::NewConstantAlreadyExistsError`
|
|
244
245
|
- `MonkeyBars::PatchAlreadyPerformedError`
|
|
246
|
+
- `MonkeyBars::PrepareForPatchingAlreadyPerformedError`
|
|
245
247
|
|
|
246
248
|
## Development
|
|
247
249
|
|
data/docs/llm-usage.md
CHANGED
|
@@ -46,6 +46,8 @@ compares it with `version` using exact equality. Mismatches raise
|
|
|
46
46
|
- `prepare_for_patching(...)` validates and stores the patch.
|
|
47
47
|
- `patch!` applies a previously prepared patch and can only be called once.
|
|
48
48
|
|
|
49
|
+
Calling `prepare_for_patching` more than once raises
|
|
50
|
+
`MonkeyBars::PrepareForPatchingAlreadyPerformedError`.
|
|
49
51
|
Calling `patch!` more than once raises `MonkeyBars::PatchAlreadyPerformedError`.
|
|
50
52
|
|
|
51
53
|
## API reference
|
|
@@ -273,6 +275,9 @@ Use this section when the patch fails. The message usually suggests the fix.
|
|
|
273
275
|
Move it to `patch_constants`.
|
|
274
276
|
- `MonkeyBars::PatchAlreadyPerformedError`: `patch!` was called twice.
|
|
275
277
|
Ensure you only call `patch!` once per prepared patch.
|
|
278
|
+
- `MonkeyBars::PrepareForPatchingAlreadyPerformedError`:
|
|
279
|
+
`prepare_for_patching` was called twice. Ensure you only prepare once per
|
|
280
|
+
patcher.
|
|
276
281
|
|
|
277
282
|
## Best practices for LLMs
|
|
278
283
|
|
data/lib/monkey_bars/errors.rb
CHANGED
|
@@ -120,4 +120,10 @@ module MonkeyBars
|
|
|
120
120
|
super("[#{patcher_name}] Couldn't find constant `#{constant}` on `#{monkey}` despite it being marked as patchable. Perhaps move it to the `new_constants` block?")
|
|
121
121
|
end
|
|
122
122
|
end
|
|
123
|
+
|
|
124
|
+
class PrepareForPatchingAlreadyPerformedError < StandardError
|
|
125
|
+
def initialize(patcher_name)
|
|
126
|
+
super("[#{patcher_name}] `#prepare_for_patching` has already been called and cannot be called again")
|
|
127
|
+
end
|
|
128
|
+
end
|
|
123
129
|
end
|
|
@@ -34,7 +34,7 @@ module MonkeyBars
|
|
|
34
34
|
preexisting_instance_method => {block:, ignore_arity_errors:, include_super_super:}
|
|
35
35
|
module_to_prepend.module_eval(&block)
|
|
36
36
|
module_to_prepend.instance_methods.each do |method_name|
|
|
37
|
-
next if module_to_prepend.
|
|
37
|
+
next if module_to_prepend.protected_method_defined?(method_name)
|
|
38
38
|
|
|
39
39
|
if @monkey.protected_method_defined?(method_name)
|
|
40
40
|
raise(PatchableInstanceMethodIsProtectedError.new(@monkey_patcher_name, monkey: @monkey, method: method_name))
|
|
@@ -126,7 +126,7 @@ module MonkeyBars
|
|
|
126
126
|
preexisting_class_method => {block:, ignore_arity_errors:, include_super_super:}
|
|
127
127
|
module_to_prepend.module_eval(&block)
|
|
128
128
|
module_to_prepend.instance_methods.each do |method_name|
|
|
129
|
-
next if module_to_prepend.
|
|
129
|
+
next if module_to_prepend.protected_method_defined?(method_name)
|
|
130
130
|
|
|
131
131
|
if @monkey.singleton_class.protected_method_defined?(method_name)
|
|
132
132
|
raise(PatchableClassMethodIsProtectedError.new(@monkey_patcher_name, monkey: @monkey, method: method_name))
|
|
@@ -216,7 +216,7 @@ module MonkeyBars
|
|
|
216
216
|
module_to_redefine = Module.new
|
|
217
217
|
module_to_redefine.module_eval(&redefined_constant)
|
|
218
218
|
module_to_redefine.constants(false).each do |const_name|
|
|
219
|
-
unless @monkey.
|
|
219
|
+
unless @monkey.const_defined?(const_name, false)
|
|
220
220
|
raise(PatchConstantNotFoundError.new(@monkey_patcher_name, monkey: @monkey, constant: const_name))
|
|
221
221
|
end
|
|
222
222
|
end
|
|
@@ -233,7 +233,7 @@ module MonkeyBars
|
|
|
233
233
|
module_to_include = Module.new
|
|
234
234
|
module_to_include.module_eval(&new_constant)
|
|
235
235
|
module_to_include.constants(false).each do |const_name|
|
|
236
|
-
if @monkey.
|
|
236
|
+
if @monkey.const_defined?(const_name, false)
|
|
237
237
|
raise(NewConstantAlreadyExistsError.new(@monkey_patcher_name, monkey: @monkey, constant: const_name))
|
|
238
238
|
end
|
|
239
239
|
end
|
data/lib/monkey_bars/version.rb
CHANGED
data/lib/monkey_bars.rb
CHANGED
|
@@ -31,6 +31,10 @@ module MonkeyBars
|
|
|
31
31
|
alias_method :🐵, :patch
|
|
32
32
|
|
|
33
33
|
def prepare_for_patching(monkey, version:, version_check:, patch_immediately: false, &block)
|
|
34
|
+
if @prepare_for_patching_performed
|
|
35
|
+
raise(PrepareForPatchingAlreadyPerformedError.new(@monkey_patcher_name))
|
|
36
|
+
end
|
|
37
|
+
|
|
34
38
|
@monkey = monkey
|
|
35
39
|
@version = version
|
|
36
40
|
@version_check_block = version_check
|
|
@@ -38,6 +42,8 @@ module MonkeyBars
|
|
|
38
42
|
yield if block_given?
|
|
39
43
|
|
|
40
44
|
patch! if patch_immediately
|
|
45
|
+
|
|
46
|
+
@prepare_for_patching_performed = true
|
|
41
47
|
end
|
|
42
48
|
|
|
43
49
|
def patch!
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: monkey_bars
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.2.
|
|
4
|
+
version: 0.2.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Andrés Rojas
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-02-
|
|
11
|
+
date: 2026-02-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rake
|