safe_monkey_patching 0.0.3 → 0.0.7
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 +9 -3
- data/lib/safe_monkey_patching.rb +7 -5
- 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: e01bc3976674082551512928046bb759e70151602b8af093235e1a1961073088
|
4
|
+
data.tar.gz: a22799598c7a3c8ae838e04bc043db906f85682c8df5282d9d64585eed412317
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54dd179f6cb888f7972eedd1b1878f191948a3ed1a416186e7fa8623d58d22108984d6d3d8c6f980933e1cfd94510240b2d544dfe7f3a699a23e625532fcbf37
|
7
|
+
data.tar.gz: dcc4aaae9eae3017b1e6a4f4c1c89e7a2948d762dc25b19d00342c74fe29bb3172869608e39a648b3fde7c188f67d0da4d92f50f972ad7a01797ef1695e751b3
|
data/README.md
CHANGED
@@ -8,7 +8,7 @@ module ActiveJob
|
|
8
8
|
monkey_patch :deserialize
|
9
9
|
|
10
10
|
def deserialize(job_data)
|
11
|
-
...
|
11
|
+
# ...
|
12
12
|
end
|
13
13
|
end
|
14
14
|
end
|
@@ -27,7 +27,7 @@ a więc, gdy podbijemy railsy i zmieni się kod źródłowy, to `gif diff` nam o
|
|
27
27
|
|
28
28
|
```diff
|
29
29
|
|
30
|
-
diff --git a/
|
30
|
+
diff --git a/monkey_patches-old.yml b/monkey_patches-old.yml
|
31
31
|
|
32
32
|
ActiveJob::Core::ClassMethods:
|
33
33
|
deserialize:
|
@@ -35,5 +35,11 @@ diff --git a/monkey_patchs.yml b/monkey_patchs.yml
|
|
35
35
|
+ sha1: 131d3acf24768b30a3ccb1052591b1cdb603f0cd
|
36
36
|
```
|
37
37
|
|
38
|
-
|
38
|
+
Również pokażą się pliki `monkey_patches-old.yml` i `WRONG_MONKEY_PATCHES.txt`, który pokazuje niekompatybilności z gemów.
|
39
|
+
|
40
|
+
Aby zaktualizować łatki, to trzeba zcomitować `monkey_patches-old.yml` i będzie :ok:.
|
41
|
+
|
42
|
+
Dzięki temu gemu nie będzie trzeba pamiętać o przejrzeniu patchów przy podbijaniu gemów 🥳
|
43
|
+
|
44
|
+
|
39
45
|
|
data/lib/safe_monkey_patching.rb
CHANGED
@@ -45,7 +45,7 @@ module SafeMonkeyPatching
|
|
45
45
|
method_entry = { method.owner.to_s => { method.name.to_s =>
|
46
46
|
{ 'sha1' => Digest::SHA1.hexdigest(method.source) } } }
|
47
47
|
|
48
|
-
new_database = database.
|
48
|
+
new_database = database.deep_merge(method_entry)
|
49
49
|
File.open(File.join(gem_path, 'monkey_patches-new.yml'), 'w') do |f|
|
50
50
|
f.puts(new_database.to_yaml)
|
51
51
|
end
|
@@ -58,10 +58,12 @@ class Object
|
|
58
58
|
end
|
59
59
|
|
60
60
|
at_exit do
|
61
|
-
break unless Rails.env.test?
|
62
61
|
SafeMonkeyPatching::Behavior.gems_with_patches.each do |gem_path|
|
63
|
-
old_patches = SafeMonkeyPatching::Behavior.load_store(File.join(gem_path, "monkey_patches-old.yml").sort.to_h
|
64
|
-
new_patches = SafeMonkeyPatching::Behavior.load_store(File.join(gem_path, "monkey_patches-new.yml").sort.to_h
|
62
|
+
old_patches = SafeMonkeyPatching::Behavior.load_store(File.join(gem_path, "monkey_patches-old.yml")).sort.to_h.to_yaml
|
63
|
+
new_patches = SafeMonkeyPatching::Behavior.load_store(File.join(gem_path, "monkey_patches-new.yml")).sort.to_h.to_yaml
|
64
|
+
|
65
|
+
File.write(File.join(gem_path, "monkey_patches-old.yml"), old_patches)
|
66
|
+
File.write(File.join(gem_path, "monkey_patches-new.yml"), new_patches)
|
65
67
|
|
66
68
|
FileUtils.mv(File.join(gem_path, "monkey_patches-new.yml"),
|
67
69
|
File.join(gem_path, "monkey_patches-old.yml"))
|
@@ -69,7 +71,7 @@ at_exit do
|
|
69
71
|
diff = Diffy::Diff.new(old_patches, new_patches)
|
70
72
|
|
71
73
|
if diff.to_s.size.positive?
|
72
|
-
$stderr.puts
|
74
|
+
$stderr.puts "Wrong monkeypatches! \n But if they are correct, then just commit 'monkey_patches-old.yml'".red.bold
|
73
75
|
$stderr.puts gem_path
|
74
76
|
$stderr.puts diff.to_s(:color)
|
75
77
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: safe_monkey_patching
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrzej Bisewski
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
description: Safe
|
27
|
+
description: Safe monkey patching
|
28
28
|
email: andrzej@bisewski.dev
|
29
29
|
executables: []
|
30
30
|
extensions: []
|