shotgunner 0.0.1
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 +7 -0
- data/lib/shotgunner.rb +35 -0
- metadata +42 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 377273e56c678439072e88eb501c56c6d349662b92e62da37b6291615be532b0
|
4
|
+
data.tar.gz: 12985133b5b55d4689ee966165e9b09094205b26710e713c38376541eb8b8d48
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ece39ce4c736087077e5174f94c4db0bf313ab0ea3c71278abf86a728e6f12f4dc06eba612813fc3cc9f6d0cda4ce6b623fe5dfd2f1baa763c67b85544909f22
|
7
|
+
data.tar.gz: c38ec26daaabec76f0c6619004b00eb8b0ef65feba693ead45033d503aaaf91580e7d0ecf7e02e43b8438585f99e560e204e1710c30c2afc845347062c66718e
|
data/lib/shotgunner.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Shotgunner
|
4
|
+
class Parallel
|
5
|
+
def self.included(base)
|
6
|
+
base.extend(ClassMethods)
|
7
|
+
base.send(:set_defaults)
|
8
|
+
base.send(:include, InstanceMethods)
|
9
|
+
end
|
10
|
+
|
11
|
+
module InstanceMethods
|
12
|
+
def run(options = {}, &block)
|
13
|
+
self.class.call(options, &block)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
module ClassMethods
|
18
|
+
def run(options = {}, &block)
|
19
|
+
mutex = Mutex.new
|
20
|
+
threads = options[:threads] || 4
|
21
|
+
tasks = options[:tasks] || []
|
22
|
+
call_results = []
|
23
|
+
threads.times.map do
|
24
|
+
Thread.new(tasks, call_results) do |tasks, call_results|
|
25
|
+
while (task = mutex.synchronize { tasks.pop })
|
26
|
+
call_result = yield(task)
|
27
|
+
mutex.synchronize { call_results << call_result }
|
28
|
+
end
|
29
|
+
end.each(&:join)
|
30
|
+
end
|
31
|
+
call_results
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: shotgunner
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Oleg Saltykov
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2021-02-18 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/shotgunner.rb
|
20
|
+
homepage:
|
21
|
+
licenses: []
|
22
|
+
metadata: {}
|
23
|
+
post_install_message:
|
24
|
+
rdoc_options: []
|
25
|
+
require_paths:
|
26
|
+
- lib
|
27
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '0'
|
32
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
requirements: []
|
38
|
+
rubygems_version: 3.0.8
|
39
|
+
signing_key:
|
40
|
+
specification_version: 4
|
41
|
+
summary: shotgunner fetch external api in a shotgun way
|
42
|
+
test_files: []
|