progress 3.2.1 → 3.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWI0NTI1YjgxOTFiODcwZTA0NGQyMTUwMTg1NWM2NDM2N2RhM2E2YQ==
4
+ ZDQ1YmVhMWRhNzgwNWY3NTA0NTlmMGEzMGFhYWU0MTQ3NWU4MTUxNw==
5
5
  data.tar.gz: !binary |-
6
- ZDMyYThlNDA5NjY5ZDMxYmRhMmQ3ZjA4YWI1NzE0MDBkYzQ4ZmVjOA==
6
+ NzAwYjY4ZTIxMWM2ZmRhYjgxYzkxNTFjN2E1YzVjMGJlYjhiYTM0MA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MjZhOGNmYTY0N2Y5YWFmMDViNTA5OWU0ZGY4ZTZmNzBiYjgxNWRmZWEwM2Zk
10
- YTBjN2U3MzBjMThiYWMxMWFiZWZmYjQ4Yzg3MWRlYzkzYWUxNWFkMGUyMmI3
11
- NGI3MDVhNzE3NjU3Y2EyYmZlNGYzNDJmMjc1OGJlYmM5MzE2NjI=
9
+ YjUwNzgyNTA4MjMzODQzNzAwYjE2N2UxNmFlYzM0Nzk0MWZiMjdhNTFhMzk1
10
+ MzY4ZTAyY2I5N2MyMDU0ZTIyZjAwYWUyNTA1MDYwYTkyOWJiN2NhNGU4MTVj
11
+ NTI4ZDcwY2MwMzRhYzA2OWExM2JjMGU5MmRkOWFmYTc2OGFhY2I=
12
12
  data.tar.gz: !binary |-
13
- ODA4MGQ2NDYwMzYwZDExNDg5ODVjZjM1YzMxYmRlYTMxNmJjMThhMjZhNTVl
14
- NzlhZTExYjQ4NmJlZWJkZWEyZWIzNTUyODVmZjMwMGI4Y2ZhOWNlZjI1ZDdl
15
- YWI2OGVjYzczMmJkNmNlMWZlMmJkOTI0MTBjOTgwOTRhODJkY2E=
13
+ YmEyNjdjZGQxM2E3ZGMwNGM0NGU0N2JiMWNlYmE1ZmFlNmU5YTE1NjU5MTIy
14
+ OGM5YTYzOWQ2MDUzODU4MDI2OGFhNmVmZTc0MzBhODI0Y2Q2ZmRkMDVkZmI2
15
+ MzNiYTE2YzRlOGVhMDQ4MTQ3MjA2MGMzMTNmYTNkYjdkNjBiYzE=
@@ -105,9 +105,9 @@ class Progress
105
105
 
106
106
  def run_with_length(enum, length, method, *args)
107
107
  Progress.start(@title, length) do
108
- enum.send(method, *args) do |*block_args|
108
+ enum.send(method, *args) do |block_args|
109
109
  Progress.step do
110
- yield(*block_args)
110
+ yield(block_args)
111
111
  end
112
112
  end
113
113
  end
@@ -116,9 +116,9 @@ class Progress
116
116
  def run_with_pos(io, method, *args)
117
117
  size = io.respond_to?(:size) ? io.size : io.stat.size
118
118
  Progress.start(@title, size) do
119
- io.send(method, *args) do |*block_args|
119
+ io.send(method, *args) do |block_args|
120
120
  Progress.set(io.pos) do
121
- yield(*block_args)
121
+ yield(block_args)
122
122
  end
123
123
  end
124
124
  end
data/progress.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'progress'
5
- s.version = '3.2.1'
5
+ s.version = '3.2.2'
6
6
  s.summary = %q{Show progress of long running tasks}
7
7
  s.homepage = "http://github.com/toy/#{s.name}"
8
8
  s.authors = ['Ivan Kuchin']
@@ -137,35 +137,55 @@ describe Progress do
137
137
  end
138
138
  end
139
139
 
140
- describe 'collections' do
141
- [
142
- [1, 2, 3],
143
- {1 => 1, 2 => 2, 3 => 3},
144
- [1, 2, 3].to_set,
145
- ].each do |enum|
146
- it "calls each only once for #{enum.class}" do
140
+ shared_examples 'yielding' do |enum|
141
+ let(:expected){ [] }
142
+ let(:got){ [] }
143
+
144
+ after{ expect(got).to eq(expected) }
145
+
146
+ it 'yields same objects with one block argument' do
147
+ enum.each{ |a| expected << a }
148
+ enum.with_progress{ |a| got << a }
149
+ end
150
+
151
+ it 'yields same objects with two block arguments' do
152
+ enum.each{ |a, b| expected << [a, b] }
153
+ enum.with_progress{ |a, b| got << [a, b] }
154
+ end
155
+
156
+ it 'yields same objects with splat block arguments' do
157
+ enum.each{ |*a| expected << a }
158
+ enum.with_progress{ |*a| got << a }
159
+ end
160
+ end
161
+
162
+ [
163
+ [1, [2, :b], [3, :c, :d, :e]],
164
+ {1 => 1, 2 => 2, 3 => 3},
165
+ [1, 2, 3].to_set,
166
+ ].each do |enum|
167
+ describe enum.class do
168
+ it 'calls each only once' do
147
169
  expect(enum).to receive(:each).once.and_call_original
148
170
  expect(enum.with_progress.each{}).to eq(enum)
149
171
  end
150
172
 
151
- it "yields same objects for #{enum.class}" do
152
- expect(enum.with_progress.entries).to eq(enum.entries)
153
- end
173
+ include_examples 'yielding', enum
154
174
  end
175
+ end
155
176
 
156
- [
157
- 100.times,
158
- 'a'..'z',
159
- ].each do |enum|
160
- it "calls each twice for #{enum.class}" do
177
+ [
178
+ 100.times,
179
+ 'a'..'z',
180
+ ].each do |enum|
181
+ describe enum.class do
182
+ it 'calls each twice' do
161
183
  enum_each = enum.each{}
162
184
  expect(enum).to receive(:each).at_most(:twice).and_call_original
163
185
  expect(enum.with_progress.each{}).to eq(enum_each)
164
186
  end
165
187
 
166
- it "yields same objects for #{enum.class}" do
167
- expect(enum.with_progress.entries).to eq(enum.entries)
168
- end
188
+ include_examples 'yielding', enum
169
189
  end
170
190
  end
171
191
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: progress
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.1
4
+ version: 3.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Kuchin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-26 00:00:00.000000000 Z
11
+ date: 2016-07-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec