hydragen 0.5.0

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 1109e029319ca6f58a6ca2c64cf07124cac2fbc0b1cdee798336c42f0df0e684
4
+ data.tar.gz: 7357fec3fdb2bb791fd40c555fa2d26a36f9c0d1ba8904d2cc2c3207eb99a927
5
+ SHA512:
6
+ metadata.gz: b66a8123eef79437c492e7f965aae71dd5c66f74823e9f873412f089c45a8fecb4cfdcafd4a97603aa79aa2e2fa2dcd155d3e91752a31d40d0ce94be73e8ffee
7
+ data.tar.gz: 51fecdea7df46d430ccbacbab67f85072ace89a5620c713dcaf4966781fe470683b515a388df1fdc5d98de2e45813c42fe844397958fabbb60af78836b074c4b
@@ -0,0 +1 @@
1
+ 2.5
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 Steve Shreeve
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,3 @@
1
+ # hydragen
2
+
3
+ Ruby gem for low-down job spawning
@@ -0,0 +1,13 @@
1
+ # encoding: utf-8
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "hydragen"
5
+ s.version = "0.5.0"
6
+ s.author = "Steve Shreeve"
7
+ s.email = "steve.shreeve@gmail.com"
8
+ s.summary = "Spawn multiple processes to perform simulataneous jobs"
9
+ s.description = "This gem divides work and conquers."
10
+ s.homepage = "https://github.com/shreeve/hydragen"
11
+ s.license = "MIT"
12
+ s.files = `git ls-files`.split("\n") - %w[.gitignore]
13
+ end
@@ -0,0 +1,59 @@
1
+ STDOUT.sync = true
2
+
3
+ =begin
4
+
5
+ hydragen/
6
+ todo/* <= area holding all pending tasks
7
+ live/* <= jobs that are being processed
8
+ fail/* <= jobs that bomb out
9
+ done/* <= jobs that complete
10
+
11
+ =end
12
+
13
+ # get files
14
+ base = "hydragen"
15
+ list = Dir[File.join(base, 'todo', '*')].sort - ['.', '..']
16
+
17
+ # spawn jobs (optional)
18
+ jobs = ARGV.first.to_i
19
+ wait = 0
20
+ jobs.times {|n| wait = n + 1; fork or break; wait = nil } if jobs > 0
21
+ exit unless wait
22
+ sleep wait
23
+ print "Starting job #{$job = wait}...\n" if jobs > 0
24
+
25
+ $job = wait
26
+ $task = 0
27
+
28
+ # process list
29
+ rows = 0
30
+ list.each do |todo|
31
+ break if File.exists?("stop.now")
32
+
33
+ # build filenames
34
+ file = File.basename(todo)
35
+ live = File.join(base, "live", file)
36
+ done = File.join(base, "done", file)
37
+ fail = File.join(base, "fail", file)
38
+
39
+ # put file in 'live' spool and touch it
40
+ FileUtils.move(todo, live) rescue next
41
+ FileUtils.touch(live)
42
+
43
+ # perform work
44
+ begin
45
+ perform(file)
46
+ print "done: #{file}\n"
47
+ rescue
48
+ print "fail: #{file}\n"
49
+ print "Error: #{$!}\n"
50
+ puts "Stack:\n\n", $@ if ENV['HYDRAGEN_TRACE']
51
+ FileUtils.move(live, fail)
52
+ next
53
+ end
54
+
55
+ # put file in 'done' spool
56
+ FileUtils.move(live, done)
57
+
58
+ # exit if (rows += 1) >= 10
59
+ end
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hydragen
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.0
5
+ platform: ruby
6
+ authors:
7
+ - Steve Shreeve
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-12-10 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: This gem divides work and conquers.
14
+ email: steve.shreeve@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - ".ruby-version"
20
+ - Gemfile
21
+ - LICENSE
22
+ - README.md
23
+ - hydragen.gemspec
24
+ - lib/hydragen.rb
25
+ homepage: https://github.com/shreeve/hydragen
26
+ licenses:
27
+ - MIT
28
+ metadata: {}
29
+ post_install_message:
30
+ rdoc_options: []
31
+ require_paths:
32
+ - lib
33
+ required_ruby_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ requirements: []
44
+ rubygems_version: 3.0.6
45
+ signing_key:
46
+ specification_version: 4
47
+ summary: Spawn multiple processes to perform simulataneous jobs
48
+ test_files: []