Created
January 14, 2018 20:23
-
-
Save tenderlove/eefcce7dcadb0ed48968f575698e3f04 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/example.rb b/example.rb | |
index 088e788..8616fa6 100644 | |
--- a/example.rb | |
+++ b/example.rb | |
@@ -1,3 +1,31 @@ | |
require 'coverage' | |
+module Coverage | |
+ module Extension | |
+ def pause; end | |
+ def reset; end | |
+ | |
+ def resume | |
+ @baseline = peek_result | |
+ end | |
+ | |
+ def subtract old, new | |
+ new.each_pair.with_object({}) do |(k, v), hash| | |
+ if old.key? k | |
+ prev_cov = old[k] | |
+ hash[k] = v.map.with_index { |info, i| info ? info - prev_cov[i] : info } | |
+ else | |
+ hash[k] = v.dup | |
+ end | |
+ end | |
+ end | |
+ | |
+ def result | |
+ return super unless @baseline | |
+ subtract @baseline, peek_result | |
+ end | |
+ end | |
+ | |
+ class << self; self; end.prepend Extension | |
+end | |
Coverage.start | |
require './covercheck' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment