in-parallel 0.1.16 → 0.1.17

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NGJlY2ZkMDkyMjM3MGE4NGIxNjljNDU1YTE1NGRkYWY2OWE2NjZkZA==
4
+ NWY0MDhlZmFhMGU4ZjNjY2U0YTAyYTJmOTJkYWExMWRhNTFiNTE2Mw==
5
5
  data.tar.gz: !binary |-
6
- ZmQ4NmExZGJmYmZiNDM5NjM1MWQ1OGM5MTMwMGMwMjYzMDdjY2ViOQ==
6
+ NzQ4MzE5Yjk0NDc5NjY3YjUxOWM4ODY0NGE2NTk5ZWJiNmY0NWQwMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MGFjZTBkNGUzYTEwYWFkMDY0YWVhNGIxNjc2MzhkOWUwNTg5Y2NjNmQxOTAy
10
- ZjAwNTliZWJmZTU4NjU1ODg0OGExNmRkZTljMzk0OWQyZGU2ODFhOWQ3ZTUw
11
- ZWQzNTRkMjY5YzM5MGYyZGViNGY4MjVhMjQwMDExYjE5MTQ3ZWY=
9
+ YzMwMWI3MGI2N2FiMDljMDUwM2JkNmVlNzI2ODRmOWM5NmJjYzU3NjBkMDdi
10
+ MTE5NDI0OGYzMzQ4MzNhNDdkOGYyZDBkYTBmOTgxNDQ2ZWU1Zjc1YmUzNDQy
11
+ OWU2NTJiODYzODE5NWUxODVlOTQ0MjMzZjM1ZWQ4NGE3YWJjMGE=
12
12
  data.tar.gz: !binary |-
13
- OWEyOGQ2MWJiY2RiZTVhNTMxM2VhNDllM2MwNmM2ZTVjNWVhNjljMjcxZDU4
14
- NWIxNTAxNzMyZDM1YWZlYjhhOWQ2Y2I0NzRmNGZmOWJlN2EzOTlhYTA5ZTk2
15
- NDZlZGVhYmYyYzFkOTcwN2E0MWY4NjQ1NTEzOGZmMGE0OGE0MWM=
13
+ Y2UyNDhlZjFjNWQzZjNkMWMyOTVlNjljZjkzOWJhZWQ2ZDM1MmUwNTNlNTJm
14
+ NDY4MTBhYjVmMGJkMzAzMDU0OWE0NDMwZDA1ODc4MGFkZjNjZWQ5ZDBlOGZm
15
+ NTYxYjVlZGZkYTFjN2NlNTIxZGJmOGJlYjQ2NTVmNDFhNjc1MDk=
data/HISTORY.md CHANGED
@@ -1,12 +1,43 @@
1
1
  # experimental_in-parallel_bump_and_tag_master - History
2
2
  ## Tags
3
- * [LATEST - 6 Feb, 2017 (27b497ea)](#LATEST)
3
+ * [LATEST - 6 Feb, 2017 (8e97ff25)](#LATEST)
4
+ * [0.1.16 - 6 Feb, 2017 (0d5030c3)](#0.1.16)
4
5
  * [0.1.15 - 3 Feb, 2017 (ff16929c)](#0.1.15)
5
6
  * [0.1.14 - 8 Aug, 2016 (ce331dbd)](#0.1.14)
6
7
  * [0.1.13 - 8 Aug, 2016 (26d19934)](#0.1.13)
7
8
 
8
9
  ## Details
9
- ### <a name = "LATEST">LATEST - 6 Feb, 2017 (27b497ea)
10
+ ### <a name = "LATEST">LATEST - 6 Feb, 2017 (8e97ff25)
11
+
12
+ * (GEM) update in-parallel version to 0.1.17 (8e97ff25)
13
+
14
+ * Merge pull request #17 from nicklewis/handle-non-parallel-enumerables (dca0b0a5)
15
+
16
+
17
+ ```
18
+ Merge pull request #17 from nicklewis/handle-non-parallel-enumerables
19
+
20
+ (maint) Properly handle non-parallel enumerables
21
+ ```
22
+ * (maint) Properly handle non-parallel enumerables (b041b864)
23
+
24
+
25
+ ```
26
+ (maint) Properly handle non-parallel enumerables
27
+
28
+ For Enumerables containing 0 or 1 items, the #each_in_parallel method
29
+ was improperly calling the block without an argument, then calling it
30
+ again properly but not returning the result of the block.
31
+
32
+ The #each method returns the Enumerable that was it was called on,
33
+ rather than the value of the block. This needs to be #map instead, to
34
+ actually return an array of the one or zero values. The tests weren't
35
+ catching this because they were effectively passing `identity` as the
36
+ block, nullifying the distinction between #each and #map.
37
+ ```
38
+ ### <a name = "0.1.16">0.1.16 - 6 Feb, 2017 (0d5030c3)
39
+
40
+ * (HISTORY) update in-parallel history for gem release 0.1.16 (0d5030c3)
10
41
 
11
42
  * (GEM) update in-parallel version to 0.1.16 (27b497ea)
12
43
 
@@ -1,3 +1,3 @@
1
1
  module InParallel
2
- VERSION = '0.1.16'
2
+ VERSION = '0.1.17'
3
3
  end
@@ -16,9 +16,9 @@ module Enumerable
16
16
  end
17
17
  # return the array of values, no need to look up from the map.
18
18
  return InParallel::InParallelExecutor.wait_for_processes(nil, block.binding, timeout, kill_all_on_error)
19
+ else
20
+ # If fork is not supported
21
+ map(&block)
19
22
  end
20
- # If fork is not supported
21
- block.call
22
- each(&block)
23
23
  end
24
24
  end
@@ -228,23 +228,36 @@ describe '.each_in_parallel' do
228
228
 
229
229
  it 'should return correct values' do
230
230
  start_time = Time.now
231
- items = ['foo', 'bar', 'baz', 'blah', 'foobar'].each_in_parallel do |item|
231
+ items = [1,2,3,4,5].each_in_parallel do |item|
232
232
  sleep(Random.rand(1.0))
233
- item
233
+ item * 2
234
234
  end
235
235
  # return values should be an array of the returned items in the last line of the block, in correct order
236
- expect(['foo', 'bar', 'baz', 'blah', 'foobar']).to eq(items)
236
+ expect(items).to eq([2,4,6,8,10])
237
237
  # time should be less than combined delay in the 3 block calls
238
238
  expect(expect(Time.now - start_time).to be < 5)
239
239
  end
240
240
 
241
241
  it 'should run each iteration of a map in parallel' do
242
- items = ['foo', 'bar', 'baz'].map.each_in_parallel do |item|
242
+ items = [1,2,3].map.each_in_parallel do |item|
243
243
  puts item
244
- item
244
+ item * 2
245
245
  end
246
246
  # return values should be an array of the returned items in the last line of the block, in correct order
247
- expect(items).to eq(['foo', 'bar', 'baz'])
247
+ expect(items).to eq([2,4,6])
248
+ end
249
+
250
+ it 'should return an empty array and do nothing with an empty enumerator' do
251
+ result = [].each_in_parallel do |item|
252
+ raise "Incorrectly called the block with an empty enumerator"
253
+ end
254
+ expect(result).to eq []
255
+ end
256
+
257
+ it 'should return the result of the block with only 1 item in the enumerator' do
258
+ expect([1].each_in_parallel do |item|
259
+ item * 2
260
+ end).to eq([2])
248
261
  end
249
262
 
250
263
  it 'should not run in parallel if there is only 1 item in the enumerator' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: in-parallel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.16
4
+ version: 0.1.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - samwoods1
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-06 00:00:00.000000000 Z
11
+ date: 2017-02-07 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Many other Ruby libraries that simplify parallel execution support one
14
14
  primary use case - crunching through a large queue of small, similar tasks as quickly