batch 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.markdown +3 -6
- data/lib/batch.rb +3 -2
- data/test/batch_test.rb +15 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MGExOGRiYWFmYzFhZWQzMTNhMDc5Y2NiMjZlZWRhN2EwZDI4NDFkOQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
M2U0ZDA5ZjZiNDAwN2VjYjBjYTkwZjY2MDQ1MzgyMjY1MGY4YzU4YQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OWMxMDJjODdhYTY5OGExYzkyMDM3NDk2YWMyZmRhOWNkNGM5NjBmNWEwYmQ5
|
10
|
+
NzI4Y2RhNDZjNzcyOWRmMGJhMTE2OTYxYTAxMDJmYjMwNWM3ZjVhNmJlZmI4
|
11
|
+
NmRkMzI5N2RlNDQ5N2E4YTVmMDcyMGRiYjRjZDNlZTIwYTY2NzI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YTk0NjU2YWEyOWM1NDZmZmJhMmEzMTQ4MTA3MGMxODE4ZTdiYWQwNDkwYmNl
|
14
|
+
NTNmOTc5Y2NmMjk1MWYzOGVlN2FmOTIzZDc5Y2VlN2NlOTQzNjIwZmIyNDk2
|
15
|
+
MDNiNTJkOTdhZTg4MzAwNjY2MzE5NGJjMDhmMTc3N2YzNjA5MmM=
|
data/README.markdown
CHANGED
@@ -62,14 +62,11 @@ Debugging
|
|
62
62
|
---------
|
63
63
|
|
64
64
|
If you want Batch to halt as soon as there's an exception (just like a regular
|
65
|
-
`each` loop would do),
|
66
|
-
explicitly, then:
|
65
|
+
`each` loop would do), set `BATCH_DEBUG`:
|
67
66
|
|
68
|
-
$ ruby
|
67
|
+
$ BATCH_DEBUG=1 ruby <your-batch-script>
|
69
68
|
|
70
|
-
|
71
|
-
|
72
|
-
$ RUBYOPT=-d rake foo
|
69
|
+
Batch will also honor the `$DEBUG` flag and halt if an exception is caught.
|
73
70
|
|
74
71
|
Installation
|
75
72
|
------------
|
data/lib/batch.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
class Batch
|
2
|
-
VERSION = "1.0.
|
2
|
+
VERSION = "1.0.4"
|
3
3
|
|
4
4
|
attr :enumerable
|
5
5
|
|
@@ -7,6 +7,7 @@ class Batch
|
|
7
7
|
@enumerable = enumerable
|
8
8
|
@width = (ENV["BATCH_WIDTH"] || 75).to_i
|
9
9
|
@size = enumerable.size if enumerable.respond_to?(:size)
|
10
|
+
@debug = $DEBUG || (ENV["BATCH_DEBUG"] || "0").to_i == 1
|
10
11
|
end
|
11
12
|
|
12
13
|
def each(&block)
|
@@ -26,7 +27,7 @@ class Batch
|
|
26
27
|
raise e
|
27
28
|
|
28
29
|
rescue Exception => e
|
29
|
-
raise e if
|
30
|
+
raise e if @debug
|
30
31
|
io.print "E"
|
31
32
|
@errors << [item, e]
|
32
33
|
|
data/test/batch_test.rb
CHANGED
@@ -154,6 +154,21 @@ EOS
|
|
154
154
|
assert_equal " 0% .", stdout
|
155
155
|
end
|
156
156
|
|
157
|
+
should "halt when BATCH_DEBUG is set to 1" do
|
158
|
+
items = []
|
159
|
+
|
160
|
+
assert_raises(ArgumentError) do
|
161
|
+
with_env("BATCH_DEBUG" => "1", "BATCH_INTERACTIVE" => "0") do
|
162
|
+
Batch.each((1..80).to_a) do |item|
|
163
|
+
items << item
|
164
|
+
raise ArgumentError, "Two is bad." if item == 2
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
|
169
|
+
assert_equal [1, 2], items
|
170
|
+
end
|
171
|
+
|
157
172
|
def with_env(env)
|
158
173
|
old = {}
|
159
174
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: batch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Damian Janowski
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-19 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email:
|