safe_monkey_patching 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/safe_monkey_patching.rb +19 -12
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c508d0db24c17c17b38f91f3a895c7199c7d15a5ec16ab290cf4277b1d484a91
|
4
|
+
data.tar.gz: 4d1da46476acbe900b87dfdd9876629f76ee18e6e91d8db661bf2969acf29def
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a45b2ea9a111a896bfe124512209696cb77e254d43476ebf107526a656d639ab1b4cff83472ca873d7393f6b88756bb7a32940d24161a74a326ae1c2100759f
|
7
|
+
data.tar.gz: 3ade656056a11a2970dbf7bd81af1fd2cbc0d936f354a7b7ab9352723cd967c9a080b7975dfa8bf405b46eff03740e37d1b519c3cc0142444e3bac01c04751e7
|
data/lib/safe_monkey_patching.rb
CHANGED
@@ -58,27 +58,34 @@ class Object
|
|
58
58
|
end
|
59
59
|
|
60
60
|
at_exit do
|
61
|
+
generate_file = ENV.key?('MONKEY') || ENV.key?('GITHUB_SHA')
|
62
|
+
|
61
63
|
SafeMonkeyPatching::Behavior.gems_with_patches.each do |gem_path|
|
62
64
|
old_patches = SafeMonkeyPatching::Behavior.load_store(File.join(gem_path, "monkey_patches-old.yml")).sort.to_h.to_yaml
|
63
65
|
new_patches = SafeMonkeyPatching::Behavior.load_store(File.join(gem_path, "monkey_patches-new.yml")).sort.to_h.to_yaml
|
64
66
|
|
65
|
-
|
66
|
-
|
67
|
+
if generate_file
|
68
|
+
File.write(File.join(gem_path, "monkey_patches-old.yml"), old_patches)
|
69
|
+
File.write(File.join(gem_path, "monkey_patches-new.yml"), new_patches)
|
67
70
|
|
68
|
-
|
69
|
-
|
71
|
+
FileUtils.mv(File.join(gem_path, "monkey_patches-new.yml"),
|
72
|
+
File.join(gem_path, "monkey_patches-old.yml"))
|
73
|
+
end
|
70
74
|
|
71
75
|
diff = Diffy::Diff.new(old_patches, new_patches)
|
72
76
|
|
73
77
|
if diff.to_s.size.positive?
|
74
|
-
$stderr.puts "Wrong
|
75
|
-
$stderr.puts
|
76
|
-
$stderr.puts
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
78
|
+
$stderr.puts "Wrong monkey_patches! Did you changed something?".red.bold
|
79
|
+
$stderr.puts "If you want see and correct them then:"
|
80
|
+
$stderr.puts "#{"1".blue.bold}. Rerun rspec with variable #{ "MONKEY=1".green }"
|
81
|
+
$stderr.puts "#{"2".blue.bold}. Commit generated file #{ "monkey_patches-old.yml".green }"
|
82
|
+
|
83
|
+
if generate_file
|
84
|
+
open(ERROR_LOCATION, 'a') do |f|
|
85
|
+
f.puts("\n")
|
86
|
+
f.puts(gem_path)
|
87
|
+
f.puts(diff.to_s)
|
88
|
+
end
|
82
89
|
end
|
83
90
|
end
|
84
91
|
end
|