carrousel 0.0.4 → 0.0.5
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.
- data/README.md +3 -1
- data/lib/carrousel.rb +1 -89
- data/lib/carrousel/runner.rb +100 -0
- data/lib/carrousel/version.rb +1 -1
- metadata +14 -5
- checksums.yaml +0 -15
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# Carrousel
|
2
2
|
|
3
|
+
[](http://badge.fury.io/rb/carrousel)
|
4
|
+
|
3
5
|
The Carrousel gem is a command line utility for running a single command on
|
4
6
|
multiple targets. Carrousel tracks which commands have succeeded or failed
|
5
7
|
based on the return of the system call, and sends failed jobs to the back of
|
@@ -41,7 +43,7 @@ carrousel and resumes it using a carrousel runner status file:
|
|
41
43
|
|
42
44
|
$ carrousel -c 'echo' foo bar baz
|
43
45
|
... CTRL-C to kill this for some reason ...
|
44
|
-
$ carrousel -s .
|
46
|
+
$ carrousel -s .carrousel_runner_status_130b02b
|
45
47
|
|
46
48
|
If you would like there to be some sort of delay between individual jobs, you
|
47
49
|
can specify that with a delay argument. The following example inserts a 30
|
data/lib/carrousel.rb
CHANGED
@@ -2,8 +2,7 @@
|
|
2
2
|
# enconding: UTF-8
|
3
3
|
|
4
4
|
require "carrousel/version"
|
5
|
-
require '
|
6
|
-
require 'yaml'
|
5
|
+
require 'carrousel/runner'
|
7
6
|
|
8
7
|
##
|
9
8
|
# "Enter the Carrousel. This is the time of renewal."
|
@@ -11,91 +10,4 @@ require 'yaml'
|
|
11
10
|
# Carrousel is a system command execution and tracker utility.
|
12
11
|
module Carrousel
|
13
12
|
|
14
|
-
class Runner
|
15
|
-
|
16
|
-
def initialize(args, opts = {})
|
17
|
-
@args = args
|
18
|
-
@opts = opts
|
19
|
-
@incomplete = []
|
20
|
-
@complete = []
|
21
|
-
|
22
|
-
unless @opts[:listfile].nil?
|
23
|
-
lines = File.readlines(@opts[:listfile]).map(&:strip)
|
24
|
-
@incomplete.concat(lines)
|
25
|
-
end
|
26
|
-
@incomplete.concat(@args)
|
27
|
-
|
28
|
-
@opts[:statusfile] ||= generate_status_filename
|
29
|
-
open_status_file
|
30
|
-
|
31
|
-
p self if @opts[:debug]
|
32
|
-
|
33
|
-
raise ArgumentError.new("Command option is required") if @opts[:command].nil?
|
34
|
-
end # def initialize
|
35
|
-
|
36
|
-
def run
|
37
|
-
# Loop over everything in the list. Run the command. If the command fails
|
38
|
-
# then we move the item to the bottom of the list. If the command
|
39
|
-
# succeeds, we move the item to the completed list. If we are interrupted
|
40
|
-
# in the middle of processing, we ensure that the item is saved in the
|
41
|
-
# normal list, and we ensure that we write out the completed list.
|
42
|
-
until @incomplete.empty?
|
43
|
-
begin
|
44
|
-
command = [@opts[:command], @incomplete.first].join(' ')
|
45
|
-
warn "Executing command: #{command}" if @opts[:verbose]
|
46
|
-
resp = system(command)
|
47
|
-
warn "System response: #{resp}" if @opts[:verbose]
|
48
|
-
if resp
|
49
|
-
@complete << @incomplete.delete(@incomplete.first)
|
50
|
-
else
|
51
|
-
@incomplete.rotate!
|
52
|
-
end
|
53
|
-
ensure
|
54
|
-
save_status_file
|
55
|
-
end
|
56
|
-
|
57
|
-
if @opts[:delay] > 0
|
58
|
-
warn "Sleeping for #{@opts[:delay]} seconds" if @opts[:verbose]
|
59
|
-
sleep @opts[:delay]
|
60
|
-
end
|
61
|
-
end # until @incomplete.empty?
|
62
|
-
end # def run
|
63
|
-
|
64
|
-
private
|
65
|
-
def generate_status_filename
|
66
|
-
key = Digest::SHA256.hexdigest(@incomplete.sort.join).slice(0...7)
|
67
|
-
warn "status file key: #{key}" if @opts[:debug]
|
68
|
-
name = self.class.name.gsub('::', '_').downcase
|
69
|
-
File.expand_path(".#{name}_status_#{key}", Dir.pwd)
|
70
|
-
end # def generate_status_filename
|
71
|
-
|
72
|
-
private
|
73
|
-
def open_status_file
|
74
|
-
if File.exists?(@opts[:statusfile])
|
75
|
-
dbs = YAML.load(File.read(@opts[:statusfile]))
|
76
|
-
warn "opened status file:\n#{dbs}" if @opts[:debug]
|
77
|
-
if dbs
|
78
|
-
@opts[:command] ||= dbs[:command]
|
79
|
-
@complete.concat(dbs[:complete])
|
80
|
-
@incomplete.concat(dbs[:incomplete])
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end # def open_status_file
|
84
|
-
|
85
|
-
private
|
86
|
-
def save_status_file
|
87
|
-
warn "Saving status file: #{@opts[:statusfile]}" if @opts[:verbose]
|
88
|
-
File.open(@opts[:statusfile], 'w') do |f|
|
89
|
-
ydb = {
|
90
|
-
:command => @opts[:command],
|
91
|
-
:complete => @complete,
|
92
|
-
:incomplete => @incomplete
|
93
|
-
}.to_yaml
|
94
|
-
f.puts(ydb)
|
95
|
-
warn "Saved status file:\n#{ydb}" if @opts[:debug]
|
96
|
-
end
|
97
|
-
true
|
98
|
-
end # def save_status_file
|
99
|
-
|
100
|
-
end # class Runner
|
101
13
|
end # module Carrousel
|
@@ -0,0 +1,100 @@
|
|
1
|
+
#!/usr/env ruby
|
2
|
+
# enconding: UTF-8
|
3
|
+
|
4
|
+
require 'digest'
|
5
|
+
require 'yaml'
|
6
|
+
|
7
|
+
##
|
8
|
+
# "Enter the Carrousel. This is the time of renewal."
|
9
|
+
#
|
10
|
+
# Carrousel is a system command execution and tracker utility.
|
11
|
+
module Carrousel
|
12
|
+
|
13
|
+
class Runner
|
14
|
+
|
15
|
+
def initialize(args, opts = {})
|
16
|
+
@args = args
|
17
|
+
@opts = opts
|
18
|
+
@incomplete = []
|
19
|
+
@complete = []
|
20
|
+
|
21
|
+
unless @opts[:listfile].nil?
|
22
|
+
lines = File.readlines(@opts[:listfile]).map(&:strip)
|
23
|
+
@incomplete.concat(lines)
|
24
|
+
end
|
25
|
+
@incomplete.concat(@args)
|
26
|
+
|
27
|
+
@opts[:statusfile] ||= generate_status_filename
|
28
|
+
open_status_file
|
29
|
+
|
30
|
+
p self if @opts[:debug]
|
31
|
+
|
32
|
+
raise ArgumentError.new("Command option is required") if @opts[:command].nil?
|
33
|
+
end # def initialize
|
34
|
+
|
35
|
+
def run
|
36
|
+
# Loop over everything in the list. Run the command. If the command fails
|
37
|
+
# then we move the item to the bottom of the list. If the command
|
38
|
+
# succeeds, we move the item to the completed list. If we are interrupted
|
39
|
+
# in the middle of processing, we ensure that the item is saved in the
|
40
|
+
# normal list, and we ensure that we write out the completed list.
|
41
|
+
until @incomplete.empty?
|
42
|
+
begin
|
43
|
+
command = [@opts[:command], @incomplete.first].join(' ')
|
44
|
+
warn "Executing command: #{command}" if @opts[:verbose]
|
45
|
+
resp = system(command)
|
46
|
+
warn "System response: #{resp}" if @opts[:verbose]
|
47
|
+
if resp
|
48
|
+
@complete << @incomplete.delete(@incomplete.first)
|
49
|
+
else
|
50
|
+
@incomplete.rotate!
|
51
|
+
end
|
52
|
+
ensure
|
53
|
+
save_status_file
|
54
|
+
end
|
55
|
+
|
56
|
+
if @opts[:delay] > 0
|
57
|
+
warn "Sleeping for #{@opts[:delay]} seconds" if @opts[:verbose]
|
58
|
+
sleep @opts[:delay]
|
59
|
+
end
|
60
|
+
end # until @incomplete.empty?
|
61
|
+
end # def run
|
62
|
+
|
63
|
+
private
|
64
|
+
def generate_status_filename
|
65
|
+
key = Digest::SHA256.hexdigest(@incomplete.sort.join).slice(0...7)
|
66
|
+
warn "status file key: #{key}" if @opts[:debug]
|
67
|
+
name = self.class.name.gsub('::', '_').downcase
|
68
|
+
File.expand_path(".#{name}_status_#{key}", Dir.pwd)
|
69
|
+
end # def generate_status_filename
|
70
|
+
|
71
|
+
private
|
72
|
+
def open_status_file
|
73
|
+
if File.exists?(@opts[:statusfile])
|
74
|
+
dbs = YAML.load(File.read(@opts[:statusfile]))
|
75
|
+
warn "opened status file:\n#{dbs}" if @opts[:debug]
|
76
|
+
if dbs
|
77
|
+
@opts[:command] ||= dbs[:command]
|
78
|
+
@complete.concat(dbs[:complete])
|
79
|
+
@incomplete.concat(dbs[:incomplete])
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end # def open_status_file
|
83
|
+
|
84
|
+
private
|
85
|
+
def save_status_file
|
86
|
+
warn "Saving status file: #{@opts[:statusfile]}" if @opts[:verbose]
|
87
|
+
File.open(@opts[:statusfile], 'w') do |f|
|
88
|
+
ydb = {
|
89
|
+
:command => @opts[:command],
|
90
|
+
:complete => @complete,
|
91
|
+
:incomplete => @incomplete
|
92
|
+
}.to_yaml
|
93
|
+
f.puts(ydb)
|
94
|
+
warn "Saved status file:\n#{ydb}" if @opts[:debug]
|
95
|
+
end
|
96
|
+
true
|
97
|
+
end # def save_status_file
|
98
|
+
|
99
|
+
end # class Runner
|
100
|
+
end # module Carrousel
|
data/lib/carrousel/version.rb
CHANGED
metadata
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrousel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Raj Sahae
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2014-03-
|
12
|
+
date: 2014-03-27 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - ~>
|
18
20
|
- !ruby/object:Gem::Version
|
@@ -20,6 +22,7 @@ dependencies:
|
|
20
22
|
type: :development
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
27
|
- - ~>
|
25
28
|
- !ruby/object:Gem::Version
|
@@ -27,6 +30,7 @@ dependencies:
|
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: rake
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
35
|
- - ! '>='
|
32
36
|
- !ruby/object:Gem::Version
|
@@ -34,6 +38,7 @@ dependencies:
|
|
34
38
|
type: :development
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
43
|
- - ! '>='
|
39
44
|
- !ruby/object:Gem::Version
|
@@ -41,6 +46,7 @@ dependencies:
|
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: minitest
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
51
|
- - ! '>='
|
46
52
|
- !ruby/object:Gem::Version
|
@@ -48,6 +54,7 @@ dependencies:
|
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
59
|
- - ! '>='
|
53
60
|
- !ruby/object:Gem::Version
|
@@ -74,32 +81,34 @@ files:
|
|
74
81
|
- bin/carrousel
|
75
82
|
- carrousel.gemspec
|
76
83
|
- lib/carrousel.rb
|
84
|
+
- lib/carrousel/runner.rb
|
77
85
|
- lib/carrousel/version.rb
|
78
86
|
- test/minitest_helper.rb
|
79
87
|
- test/test_carrousel.rb
|
80
88
|
homepage: https://github.com/rajsahae/carrousel
|
81
89
|
licenses:
|
82
90
|
- MIT
|
83
|
-
metadata: {}
|
84
91
|
post_install_message:
|
85
92
|
rdoc_options: []
|
86
93
|
require_paths:
|
87
94
|
- lib
|
88
95
|
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
89
97
|
requirements:
|
90
98
|
- - ! '>='
|
91
99
|
- !ruby/object:Gem::Version
|
92
100
|
version: '0'
|
93
101
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
none: false
|
94
103
|
requirements:
|
95
104
|
- - ! '>='
|
96
105
|
- !ruby/object:Gem::Version
|
97
106
|
version: '0'
|
98
107
|
requirements: []
|
99
108
|
rubyforge_project:
|
100
|
-
rubygems_version:
|
109
|
+
rubygems_version: 1.8.23
|
101
110
|
signing_key:
|
102
|
-
specification_version:
|
111
|
+
specification_version: 3
|
103
112
|
summary: Robust list based action tracking utility.
|
104
113
|
test_files:
|
105
114
|
- test/minitest_helper.rb
|
checksums.yaml
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
---
|
2
|
-
!binary "U0hBMQ==":
|
3
|
-
metadata.gz: !binary |-
|
4
|
-
ZDllYjNiM2Y5MzY0NDI0MzEyZDZhMTZlNGM0MDY3N2EwYTJiZTY5Zg==
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
YjhlYzMzNDBlNzE0OTg2YmM5NjIxZmY0NTY2NzZhODE2YTM4NDhlMQ==
|
7
|
-
SHA512:
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
MmRjYWJjNjI1Y2M1NmExNjI0NzIxZGZjZTRkM2QxZjdmMTMzNjM0MDU1MjAx
|
10
|
-
MzYxZjI3MjUyZTlhY2NmYTZhYmRhZDZhODlkZTMzOTM2YjIxYmQwZWNjMjE2
|
11
|
-
ZjY5ZTYxNjI2ODZkZmUxZTI2NzkwODVjMzk3NzUxZGIyZTZiNTM=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
YWJiZWI4YjViZmJkZTk4ZTIyNDllOWZlZGQ1ZmYxODFhMDNmMjAwNGRhZjgy
|
14
|
-
N2EwMGY3MDVmY2ZjZTFmZTk1OTQ1Mzk5ODdlYjNlNjJkNGFkOGY5NzIzNDQ5
|
15
|
-
MmRhYWQxMzJhMjU5ODljMDAwNTcxOGQ5NDRlZmZmZWRiYzM1YzY=
|