shotgunner 0.0.1 → 0.1.4

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,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 377273e56c678439072e88eb501c56c6d349662b92e62da37b6291615be532b0
4
- data.tar.gz: 12985133b5b55d4689ee966165e9b09094205b26710e713c38376541eb8b8d48
3
+ metadata.gz: 6ec6606a8eab14fe6a3e852250000220fac0241fb7acb77d87e81eddd9545115
4
+ data.tar.gz: f278873f790da5b90a14c0664dea0941778346a2628c58737ed1905df9d1745f
5
5
  SHA512:
6
- metadata.gz: ece39ce4c736087077e5174f94c4db0bf313ab0ea3c71278abf86a728e6f12f4dc06eba612813fc3cc9f6d0cda4ce6b623fe5dfd2f1baa763c67b85544909f22
7
- data.tar.gz: c38ec26daaabec76f0c6619004b00eb8b0ef65feba693ead45033d503aaaf91580e7d0ecf7e02e43b8438585f99e560e204e1710c30c2afc845347062c66718e
6
+ metadata.gz: eab16fc2914834b6a003f8c37735b8226544fe538ebf004fc06c283dae6f743ed5a2d889408b3c35ade831a742063f5ef3f03c565bcfa3f2deed2f2b388bd083
7
+ data.tar.gz: 546bf51dacc3fdfee6761a9723a723ac60161bb18bd3cffd454be25d8ae1666ae31dea623685f4bfeb4eae6ca8d784485f3b0e91ac336098e76daedc023a5f8d
@@ -1,16 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Shotgunner
4
- class Parallel
4
+ module Parallel
5
5
  def self.included(base)
6
6
  base.extend(ClassMethods)
7
- base.send(:set_defaults)
8
7
  base.send(:include, InstanceMethods)
9
8
  end
10
9
 
11
10
  module InstanceMethods
12
11
  def run(options = {}, &block)
13
- self.class.call(options, &block)
12
+ self.class.run(options, &block)
14
13
  end
15
14
  end
16
15
 
@@ -18,7 +17,8 @@ module Shotgunner
18
17
  def run(options = {}, &block)
19
18
  mutex = Mutex.new
20
19
  threads = options[:threads] || 4
21
- tasks = options[:tasks] || []
20
+ tasks = options[:tasks]&.dup || []
21
+ raise ArgumentError, 'There is no tasks array defined!' if tasks.empty?
22
22
  call_results = []
23
23
  threads.times.map do
24
24
  Thread.new(tasks, call_results) do |tasks, call_results|
@@ -26,8 +26,8 @@ module Shotgunner
26
26
  call_result = yield(task)
27
27
  mutex.synchronize { call_results << call_result }
28
28
  end
29
- end.each(&:join)
30
- end
29
+ end
30
+ end.each(&:join)
31
31
  call_results
32
32
  end
33
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shotgunner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Saltykov
@@ -16,8 +16,8 @@ executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
- - lib/shotgunner.rb
20
- homepage:
19
+ - lib/shotgunner/parallel.rb
20
+ homepage: https://github.com/nucleom42/shotgunner
21
21
  licenses: []
22
22
  metadata: {}
23
23
  post_install_message:
@@ -38,5 +38,5 @@ requirements: []
38
38
  rubygems_version: 3.0.8
39
39
  signing_key:
40
40
  specification_version: 4
41
- summary: shotgunner fetch external api in a shotgun way
41
+ summary: Shotgunner - helps to fetch external api in a parallel way! Fast and furious!
42
42
  test_files: []