each_in_thread 0.1.10 → 0.1.12
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/.github/workflows/gem-push.yml +0 -14
- data/Gemfile.lock +2 -1
- data/README.md +4 -3
- data/lib/each_in_thread/version.rb +1 -1
- data/lib/each_in_thread.rb +7 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b153a43ac62f6396f0d29546f9c5098c0fe0be22871d7b9f012f01f7521d9dc
|
4
|
+
data.tar.gz: fbb41b8af6fb7a027afdaea47285169c3841b8ab706911f76872c54cf7d6f45d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2573af13aba213d8478b44774c2670a2d41dd2c562ab4f47931f4f3fcf77cf7dca967f510df53bb963b35ccb8c9bbb06adae7e9e060f4b2fdfae5602c31622d2
|
7
|
+
data.tar.gz: 5d53815f410c96e48cd85ed445a88b675b4e43a89bf14e5ab9aa7151162569b9ee111ab1e437b7c161eacb75d12b8f9f61eeccb3a7d0e00dfeef4b62bdbe8e3d
|
@@ -3,8 +3,6 @@ name: Ruby Gem
|
|
3
3
|
on:
|
4
4
|
push:
|
5
5
|
branches: [ "main" ]
|
6
|
-
pull_request:
|
7
|
-
branches: [ "main" ]
|
8
6
|
|
9
7
|
jobs:
|
10
8
|
build:
|
@@ -21,18 +19,6 @@ jobs:
|
|
21
19
|
with:
|
22
20
|
ruby-version: 2.6
|
23
21
|
|
24
|
-
# - name: Publish to GPR
|
25
|
-
# run: |
|
26
|
-
# mkdir -p $HOME/.gem
|
27
|
-
# touch $HOME/.gem/credentials
|
28
|
-
# chmod 0600 $HOME/.gem/credentials
|
29
|
-
# printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
30
|
-
# gem build *.gemspec
|
31
|
-
# gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
|
32
|
-
# env:
|
33
|
-
# GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
|
34
|
-
# OWNER: ${{ github.repository_owner }}
|
35
|
-
|
36
22
|
- name: Publish to RubyGems
|
37
23
|
run: |
|
38
24
|
mkdir -p $HOME/.gem
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# EachInThread
|
2
|
+
[](https://badge.fury.io/rb/each_in_thread)
|
2
3
|
|
3
4
|
The `each_in_thread` gem extends Ruby's Enumerable module to provide an easy way to iterate over collections with
|
4
5
|
concurrency. This means you can perform actions on each item in an array (or any other enumerable) in separate threads.
|
@@ -29,9 +30,9 @@ require 'net/http'
|
|
29
30
|
urls = %w[http://example.com http://example.org http://example.net]
|
30
31
|
|
31
32
|
# We can fetch each URL in a separate thread like this:
|
32
|
-
urls.each_in_thread(concurrency: 5) do |url|
|
33
|
+
urls.each_in_thread(concurrency: 5) do |url, i|
|
33
34
|
response = Net::HTTP.get(URI(url))
|
34
|
-
puts "Fetched #{url}: #{response.size} bytes"
|
35
|
+
puts "(#{i}) Fetched #{url}: #{response.size} bytes"
|
35
36
|
end
|
36
37
|
```
|
37
38
|
|
@@ -43,7 +44,7 @@ The each_in_thread method takes an options hash, where you can specify the follo
|
|
43
44
|
|
44
45
|
## Contributing
|
45
46
|
|
46
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
47
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/Galaxy83/each_in_thread. This
|
47
48
|
project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code
|
48
49
|
of conduct.
|
49
50
|
|
data/lib/each_in_thread.rb
CHANGED
@@ -13,7 +13,13 @@ module Enumerable
|
|
13
13
|
|
14
14
|
each_with_index do |item, i|
|
15
15
|
pool.process do
|
16
|
-
|
16
|
+
begin
|
17
|
+
yield item, i
|
18
|
+
rescue => e
|
19
|
+
puts "Exception in thread:"
|
20
|
+
puts e.message
|
21
|
+
puts e.backtrace if verbose
|
22
|
+
end
|
17
23
|
|
18
24
|
if verbose
|
19
25
|
mutex.synchronize do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: each_in_thread
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Igor Novikov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06
|
11
|
+
date: 2023-11-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thread
|