batch 1.0.3 → 1.0.4

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Yzk2NTUwZGY3OGIwZGY0MmM4MmMzZWIwMmMwYjI3YzU3YjA1MzhkYQ==
4
+ MGExOGRiYWFmYzFhZWQzMTNhMDc5Y2NiMjZlZWRhN2EwZDI4NDFkOQ==
5
5
  data.tar.gz: !binary |-
6
- NmE4NGM0Y2ZkMzNhNDM5N2RjOTI1NWNlZDhmNzY1NDdhMmUwOWQ0NQ==
6
+ M2U0ZDA5ZjZiNDAwN2VjYjBjYTkwZjY2MDQ1MzgyMjY1MGY4YzU4YQ==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ODYwOWUyNTA0OGU0Zjc0MGZhMjFkNTI5ZDU1YzUyYjVlNmQ3MjFiMDlhY2Ew
10
- ZjFhNDEzMzkxNmRkMWYyOWQwMjRkNWYxYTg5NWE5OGMyYjZmMDJjNzRmZDdj
11
- OTI0YjFmZDlmNTA2MTk3OTI0MGRmMjc3YWZkODEyNTU4YWI4ZGQ=
9
+ OWMxMDJjODdhYTY5OGExYzkyMDM3NDk2YWMyZmRhOWNkNGM5NjBmNWEwYmQ5
10
+ NzI4Y2RhNDZjNzcyOWRmMGJhMTE2OTYxYTAxMDJmYjMwNWM3ZjVhNmJlZmI4
11
+ NmRkMzI5N2RlNDQ5N2E4YTVmMDcyMGRiYjRjZDNlZTIwYTY2NzI=
12
12
  data.tar.gz: !binary |-
13
- YzVhYjdmN2Q4MTQ5ZDlmN2ZkODQ2NTQzNDkzNDlhZjM5ZDk5M2UzMDFmMzVm
14
- YmE4N2I0YWQyYmM2Y2NjYzQwOTBiMjAyNDRmMTBjZDk3MDVjNjAwMWQ2MTMy
15
- NjY5MTRlZWM0N2E0N2FiOTg4MWQ4MWU5ZTgwYWEzYmRjMjM4ZDc=
13
+ YTk0NjU2YWEyOWM1NDZmZmJhMmEzMTQ4MTA3MGMxODE4ZTdiYWQwNDkwYmNl
14
+ NTNmOTc5Y2NmMjk1MWYzOGVlN2FmOTIzZDc5Y2VlN2NlOTQzNjIwZmIyNDk2
15
+ MDNiNTJkOTdhZTg4MzAwNjY2MzE5NGJjMDhmMTc3N2YzNjA5MmM=
@@ -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), simply set `$DEBUG` to true. If you're running Ruby
66
- explicitly, then:
65
+ `each` loop would do), set `BATCH_DEBUG`:
67
66
 
68
- $ ruby -d <your-batch-script>
67
+ $ BATCH_DEBUG=1 ruby <your-batch-script>
69
68
 
70
- If you're running another tool which uses Batch, then set `RUBYOPT`:
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
  ------------
@@ -1,5 +1,5 @@
1
1
  class Batch
2
- VERSION = "1.0.3"
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 $DEBUG
30
+ raise e if @debug
30
31
  io.print "E"
31
32
  @errors << [item, e]
32
33
 
@@ -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.3
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-10 00:00:00.000000000 Z
12
+ date: 2013-06-19 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: