safe_monkey_patching 0.0.5 → 0.0.10
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 +27 -14
- 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: 9cc771a21035ae487d38091ccc66b924ced972aac8240d0588c0591979308641
|
4
|
+
data.tar.gz: f35f5d81b079a5a53b1735e2e463653b35dc5b7b1b487ea2f918d83a61c4c6cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db1f4770c03d722b98efac8e702defa8bfb7fa2dad4996676c2e8938d49f1c7a8254985330704c52990315abd3775189386377c65f1f2c355d8a869a365edeb8
|
7
|
+
data.tar.gz: c0c51109a4a1152a37cf3683b0f81038aaca8b3fe18870d81ef97581e36f4c1cf41ec7ebbef750c332e7d2d339679275f1cecf2858c5807d897ba9db5ece993c
|
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,28 +58,41 @@ class Object
|
|
58
58
|
end
|
59
59
|
|
60
60
|
at_exit do
|
61
|
-
|
61
|
+
generate_file = ENV.key?('MONKEY') || ENV.key?('GITHUB_SHA')
|
62
|
+
written = false
|
63
|
+
|
62
64
|
SafeMonkeyPatching::Behavior.gems_with_patches.each do |gem_path|
|
63
65
|
old_patches = SafeMonkeyPatching::Behavior.load_store(File.join(gem_path, "monkey_patches-old.yml")).sort.to_h.to_yaml
|
64
66
|
new_patches = SafeMonkeyPatching::Behavior.load_store(File.join(gem_path, "monkey_patches-new.yml")).sort.to_h.to_yaml
|
65
67
|
|
66
|
-
|
67
|
-
|
68
|
+
if generate_file
|
69
|
+
File.write(File.join(gem_path, "monkey_patches-old.yml"), old_patches)
|
70
|
+
File.write(File.join(gem_path, "monkey_patches-new.yml"), new_patches)
|
68
71
|
|
69
|
-
|
70
|
-
|
72
|
+
FileUtils.mv(File.join(gem_path, "monkey_patches-new.yml"),
|
73
|
+
File.join(gem_path, "monkey_patches-old.yml"))
|
74
|
+
end
|
71
75
|
|
72
76
|
diff = Diffy::Diff.new(old_patches, new_patches)
|
73
77
|
|
74
78
|
if diff.to_s.size.positive?
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
79
|
+
unless written
|
80
|
+
written = true
|
81
|
+
$stderr.puts
|
82
|
+
$stderr.puts "Wrong monkey_patches! Did you changed something?".red.bold
|
83
|
+
$stderr.puts "to correct them:"
|
84
|
+
$stderr.puts "#{"-".blue.bold} Rerun rspec with variable #{ "MONKEY=1".green }" unless generate_file
|
85
|
+
$stderr.puts "#{"-".blue.bold} Commit generated file #{ "monkey_patches-old.yml".green }"
|
86
|
+
end
|
87
|
+
|
88
|
+
if generate_file
|
89
|
+
$stderr.puts gem_path
|
90
|
+
$stderr.puts diff.to_s(:color)
|
91
|
+
open(ERROR_LOCATION, 'a') do |f|
|
92
|
+
f.puts("\n")
|
93
|
+
f.puts(gem_path)
|
94
|
+
f.puts(diff.to_s)
|
95
|
+
end
|
83
96
|
end
|
84
97
|
end
|
85
98
|
end
|
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.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrzej Bisewski
|
@@ -51,7 +51,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '0'
|
53
53
|
requirements: []
|
54
|
-
rubygems_version: 3.
|
54
|
+
rubygems_version: 3.0.9
|
55
55
|
signing_key:
|
56
56
|
specification_version: 4
|
57
57
|
summary: Safe monkey patching
|