simplecov-parallel 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4fdc5794fb5634ad9c97afcdf6783daf7d1220cd
4
- data.tar.gz: 055eb756b87784b13681d0fc9bcf54bc3558f30b
3
+ metadata.gz: ef73c5648b57532f6b44d43cafd921779a969366
4
+ data.tar.gz: 6b542836cc4264a7a60ae18c4b61b0a8a6dd1ba0
5
5
  SHA512:
6
- metadata.gz: ca8662037eed8bce87500d0c9958506b76599d291cb9098e03fb7c7c770f5ac6e9193d72d02bf96d0f342ba308a2b223e0546d2ac29a72af9163dfb8b8a4c8d6
7
- data.tar.gz: 4bd82d8cb9c78f9ef55d7f4a115bb795ef14313c330fa8a7f4a9b6ec8f19b52ead689a58e654f98f34d75d505bcd1893d6b104ede5c7d0fcd999c05e1e9e0b49
6
+ metadata.gz: 0e2bb376613c10b3c27aa4035a993983e3f2239f6406e12106778ec60835f47d2eb6728cdeae1d2cabe1f0314a57334d1ed543877988b8b5cacf4500fc4f33a2
7
+ data.tar.gz: 6af0c497e862afd8e6c482c62756c1a72d08f233570accb4a9afc9ecb33e4bf6e968cfbfcb20542c32f06b522190644fd76dfa658b9c5d9ece51331dc053c32a
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Development
4
4
 
5
+ ## v0.1.2
6
+
7
+ * Refactor method stashing.
8
+
5
9
  ## v0.1.1
6
10
 
7
11
  * Fix a bug in method stashing of `SimpleCov::ResultMerger#resultset_path`.
data/README.md CHANGED
@@ -6,6 +6,7 @@
6
6
  # SimpleCov::Parallel
7
7
 
8
8
  **SimpleCov::Parallel** is a [SimpleCov](https://github.com/colszowka/simplecov) extension for parallelism support.
9
+ It automatically transfers each node coverage data to a single master node and merges the data.
9
10
  Currently only [CircleCI parallelism](https://circleci.com/docs/parallelism/) is supported.
10
11
 
11
12
  ## Installation
@@ -78,24 +78,44 @@ module SimpleCov
78
78
  # SimpleCov.root and SimpleCov.coverage_dir does not work well because .root is used in
79
79
  # the root filter, which is invoked from SimpleCov::Result#initialize.
80
80
  # https://github.com/colszowka/simplecov/blob/v0.12.0/lib/simplecov/defaults.rb#L9
81
- method_name = :resultset_path
82
- original_method = SimpleCov::ResultMerger.method(method_name)
83
- singleton_class = SimpleCov::ResultMerger.singleton_class
81
+ method_stasher = MethodStasher.new(SimpleCov::ResultMerger, :resultset_path)
82
+ method_stasher.stash
84
83
 
85
- singleton_class.__send__(:undef_method, method_name)
86
- singleton_class.__send__(:define_method, method_name) { File.join(dir, '.resultset.json') }
84
+ SimpleCov::ResultMerger.define_singleton_method(:resultset_path) do
85
+ File.join(dir, '.resultset.json')
86
+ end
87
87
 
88
88
  begin
89
89
  yield
90
90
  ensure
91
- singleton_class.__send__(:undef_method, method_name)
92
- singleton_class.__send__(:define_method, method_name, original_method)
91
+ method_stasher.pop
93
92
  end
94
93
  end
95
94
 
96
95
  def current_node
97
96
  ::CircleCI::Parallel.current_node
98
97
  end
98
+
99
+ MethodStasher = Struct.new(:object, :method_name) do
100
+ def stash
101
+ @original_method = object.method(method_name)
102
+ klass.__send__(:undef_method, method_name)
103
+ end
104
+
105
+ def pop
106
+ if klass.__send__(:method_defined?, method_name)
107
+ klass.__send__(:undef_method, method_name)
108
+ end
109
+
110
+ klass.__send__(:define_method, method_name, @original_method)
111
+ end
112
+
113
+ private
114
+
115
+ def klass
116
+ object.singleton_class
117
+ end
118
+ end
99
119
  end
100
120
  end
101
121
  end
@@ -3,7 +3,7 @@ module SimpleCov
3
3
  module Version
4
4
  MAJOR = 0
5
5
  MINOR = 1
6
- PATCH = 1
6
+ PATCH = 2
7
7
 
8
8
  def self.to_s
9
9
  [MAJOR, MINOR, PATCH].join('.')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simplecov-parallel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuji Nakayama