specwrk 0.10.1 → 0.10.2
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 +4 -4
- data/lib/specwrk/store/file_adapter.rb +17 -13
- data/lib/specwrk/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4570e3aaeb01c00647b8671803076848bf28dee5068ec0cde66c88effea85bbe
|
4
|
+
data.tar.gz: 1d6709fc4b518ca5dcbad15e59820ba855adebb5dc6830ec26cc7f92d59f597d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3868e891fc3c14a8ce281b747d8e5b0c271e55f946f1fe1d23aa4d88d940ee40ea966fbf32bce5711ca1597c7870a8a4b1aa1bac610f117a9695888015eee6db
|
7
|
+
data.tar.gz: 385faa8d85c751eca15e1203ab626ec8d9abe3584e79265550dc52b18c81327f6a837535827dd63d56bc5fb0671fe11c8bd91698a96dc0d9a82d36a23edc7430
|
@@ -10,20 +10,24 @@ module Specwrk
|
|
10
10
|
class FileAdapter
|
11
11
|
EXT = ".wrk.json"
|
12
12
|
|
13
|
-
|
14
|
-
|
13
|
+
@work_queue = Queue.new
|
14
|
+
@threads = []
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
16
|
+
class << self
|
17
|
+
def schedule_work(&blk)
|
18
|
+
start_threads!
|
19
|
+
@work_queue.push blk
|
22
20
|
end
|
23
21
|
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
def start_threads!
|
23
|
+
return if @threads.length.positive?
|
24
|
+
|
25
|
+
Array.new(ENV.fetch("SPECWRK_THREAD_COUNT", "4").to_i) do
|
26
|
+
@threads << Thread.new do
|
27
|
+
loop do
|
28
|
+
@work_queue.pop.call
|
29
|
+
end
|
30
|
+
end
|
27
31
|
end
|
28
32
|
end
|
29
33
|
end
|
@@ -80,7 +84,7 @@ module Specwrk
|
|
80
84
|
result_queue = Queue.new
|
81
85
|
|
82
86
|
read_keys.each do |key|
|
83
|
-
|
87
|
+
self.class.schedule_work do
|
84
88
|
result_queue.push([key.to_s, read(key)])
|
85
89
|
end
|
86
90
|
end
|
@@ -107,7 +111,7 @@ module Specwrk
|
|
107
111
|
hash_with_filenames.each do |key, (filename, value)|
|
108
112
|
content = JSON.generate(value)
|
109
113
|
|
110
|
-
|
114
|
+
self.class.schedule_work do
|
111
115
|
result_queue << write(filename, content)
|
112
116
|
end
|
113
117
|
end
|
data/lib/specwrk/version.rb
CHANGED