safe_monkey_patching 0.0.7 → 0.0.8

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/safe_monkey_patching.rb +19 -12
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e01bc3976674082551512928046bb759e70151602b8af093235e1a1961073088
4
- data.tar.gz: a22799598c7a3c8ae838e04bc043db906f85682c8df5282d9d64585eed412317
3
+ metadata.gz: c508d0db24c17c17b38f91f3a895c7199c7d15a5ec16ab290cf4277b1d484a91
4
+ data.tar.gz: 4d1da46476acbe900b87dfdd9876629f76ee18e6e91d8db661bf2969acf29def
5
5
  SHA512:
6
- metadata.gz: 54dd179f6cb888f7972eedd1b1878f191948a3ed1a416186e7fa8623d58d22108984d6d3d8c6f980933e1cfd94510240b2d544dfe7f3a699a23e625532fcbf37
7
- data.tar.gz: dcc4aaae9eae3017b1e6a4f4c1c89e7a2948d762dc25b19d00342c74fe29bb3172869608e39a648b3fde7c188f67d0da4d92f50f972ad7a01797ef1695e751b3
6
+ metadata.gz: 8a45b2ea9a111a896bfe124512209696cb77e254d43476ebf107526a656d639ab1b4cff83472ca873d7393f6b88756bb7a32940d24161a74a326ae1c2100759f
7
+ data.tar.gz: 3ade656056a11a2970dbf7bd81af1fd2cbc0d936f354a7b7ab9352723cd967c9a080b7975dfa8bf405b46eff03740e37d1b519c3cc0142444e3bac01c04751e7
@@ -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
- 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)
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
- FileUtils.mv(File.join(gem_path, "monkey_patches-new.yml"),
69
- File.join(gem_path, "monkey_patches-old.yml"))
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 monkeypatches! \n But if they are correct, then just commit 'monkey_patches-old.yml'".red.bold
75
- $stderr.puts gem_path
76
- $stderr.puts diff.to_s(:color)
77
-
78
- open(ERROR_LOCATION, 'a') do |f|
79
- f.puts("\n")
80
- f.puts(gem_path)
81
- f.puts(diff.to_s)
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
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.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrzej Bisewski