progress 3.2.1 → 3.2.2
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 +8 -8
- data/lib/progress/with_progress.rb +4 -4
- data/progress.gemspec +1 -1
- data/spec/progress_spec.rb +38 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZDQ1YmVhMWRhNzgwNWY3NTA0NTlmMGEzMGFhYWU0MTQ3NWU4MTUxNw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NzAwYjY4ZTIxMWM2ZmRhYjgxYzkxNTFjN2E1YzVjMGJlYjhiYTM0MA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YjUwNzgyNTA4MjMzODQzNzAwYjE2N2UxNmFlYzM0Nzk0MWZiMjdhNTFhMzk1
|
10
|
+
MzY4ZTAyY2I5N2MyMDU0ZTIyZjAwYWUyNTA1MDYwYTkyOWJiN2NhNGU4MTVj
|
11
|
+
NTI4ZDcwY2MwMzRhYzA2OWExM2JjMGU5MmRkOWFmYTc2OGFhY2I=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
108
|
+
enum.send(method, *args) do |block_args|
|
109
109
|
Progress.step do
|
110
|
-
yield(
|
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
|
119
|
+
io.send(method, *args) do |block_args|
|
120
120
|
Progress.set(io.pos) do
|
121
|
-
yield(
|
121
|
+
yield(block_args)
|
122
122
|
end
|
123
123
|
end
|
124
124
|
end
|
data/progress.gemspec
CHANGED
data/spec/progress_spec.rb
CHANGED
@@ -137,35 +137,55 @@ describe Progress do
|
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
140
|
-
|
141
|
-
[
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
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
|
-
|
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
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
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
|
-
|
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.
|
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-
|
11
|
+
date: 2016-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|