progress 3.5.1 → 3.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.markdown +4 -0
- data/README.markdown +104 -78
- data/progress.gemspec +1 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 968512bbd9522d70ff093587d4ec2f75a82b8cfe3af204bbec0ccf461474ffa4
|
4
|
+
data.tar.gz: df95743ec5de95729873bc5afa3ffd7e507bd4f515b0918287cf69d1a3b70c07
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7767fac01705f63d745a64aa352aa9ce4afa998d33874967ddf397c912629f3b0a2b288bdab80c97123ff90be7432e43053301a643da47e2ab88d17359d16ad0
|
7
|
+
data.tar.gz: 8c1b6a5e2be195328dc59c15b5d9acdd3ed9bd93d76ca4c60301d9a33857174b45a8e78aa0c9b2e5a688fad0577f133a821fffac818bd00e71184d463495b8b7
|
data/.travis.yml
CHANGED
data/CHANGELOG.markdown
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
## unreleased
|
4
4
|
|
5
|
+
## v3.5.2 (2019-07-14)
|
6
|
+
|
7
|
+
* Remove deprecated `rubyforge_project` attribute from gemspec [rubygems/rubygems#2436](https://github.com/rubygems/rubygems/pull/2436) [@toy](https://github.com/toy)
|
8
|
+
|
5
9
|
## v3.5.1 (2019-05-25)
|
6
10
|
|
7
11
|
* Enable frozen string literals [@toy](https://github.com/toy)
|
data/README.markdown
CHANGED
@@ -14,126 +14,152 @@ Show progress during console script run.
|
|
14
14
|
|
15
15
|
## Usage
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
```ruby
|
18
|
+
1000.times_with_progress('Counting to 1000') do |i|
|
19
|
+
# do something with i
|
20
|
+
end
|
21
|
+
```
|
20
22
|
|
21
23
|
or without title:
|
22
24
|
|
23
|
-
|
24
|
-
|
25
|
-
|
25
|
+
```ruby
|
26
|
+
1000.times_with_progress do |i|
|
27
|
+
# do something with i
|
28
|
+
end
|
29
|
+
```
|
26
30
|
|
27
31
|
With array:
|
28
32
|
|
29
|
-
|
30
|
-
|
31
|
-
|
33
|
+
```ruby
|
34
|
+
[1, 2, 3].with_progress('1…2…3').each do |i|
|
35
|
+
# still counting
|
36
|
+
end
|
37
|
+
```
|
32
38
|
|
33
39
|
`.each` is optional:
|
34
40
|
|
35
|
-
|
36
|
-
|
37
|
-
|
41
|
+
```ruby
|
42
|
+
[1, 2, 3].with_progress('1…2…3') do |i|
|
43
|
+
# =||=
|
44
|
+
end
|
45
|
+
```
|
38
46
|
|
39
47
|
Nested progress
|
40
48
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
end
|
49
|
+
```ruby
|
50
|
+
(1..10).with_progress('Outer').map do |a|
|
51
|
+
(1..10).with_progress('Middle').map do |b|
|
52
|
+
(1..10).with_progress('Inner').map do |c|
|
53
|
+
# do something with a, b and c
|
47
54
|
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
```
|
48
58
|
|
49
59
|
You can also show note:
|
50
60
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
61
|
+
```ruby
|
62
|
+
[1, 2, 3].with_progress do |i|
|
63
|
+
Progress.note = i
|
64
|
+
sleep 5
|
65
|
+
end
|
66
|
+
```
|
55
67
|
|
56
68
|
You can use any enumerable method:
|
57
69
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
70
|
+
```ruby
|
71
|
+
[1, 2, 3].with_progress.map{ |i| 'do stuff' }
|
72
|
+
[1, 2, 3].with_progress.each_cons(3){ |i| 'do stuff' }
|
73
|
+
[1, 2, 3].with_progress.each_slice(2){ |i| 'do stuff' }
|
74
|
+
# …
|
75
|
+
```
|
62
76
|
|
63
77
|
Any enumerable will work:
|
64
78
|
|
65
|
-
|
66
|
-
|
67
|
-
|
79
|
+
```ruby
|
80
|
+
(1..100).with_progress('Wait') do |i|
|
81
|
+
# ranges are good
|
82
|
+
end
|
68
83
|
|
69
|
-
|
70
|
-
|
71
|
-
|
84
|
+
Dir.new('.').with_progress do |path|
|
85
|
+
# check path
|
86
|
+
end
|
87
|
+
```
|
72
88
|
|
73
89
|
NOTE: progress gets number of objects using `length`, `size`, `to_a.length` or just `inject` and if used on objects which needs rewind (like opened File), cycle itself will not work.
|
74
90
|
|
75
91
|
Use simple blocks:
|
76
92
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
93
|
+
```ruby
|
94
|
+
symbols = []
|
95
|
+
Progress.start('Input 100 symbols', 100) do
|
96
|
+
while symbols.length < 100
|
97
|
+
input = gets.scan(/\S/)
|
98
|
+
symbols += input
|
99
|
+
Progress.step input.length
|
100
|
+
end
|
101
|
+
end
|
102
|
+
```
|
85
103
|
|
86
104
|
or just
|
87
105
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
106
|
+
```ruby
|
107
|
+
symbols = []
|
108
|
+
Progress('Input 100 symbols', 100) do
|
109
|
+
while symbols.length < 100
|
110
|
+
input = gets.scan(/\S/)
|
111
|
+
symbols += input
|
112
|
+
Progress.step input.length
|
113
|
+
end
|
114
|
+
end
|
115
|
+
```
|
96
116
|
|
97
117
|
NOTE: you will get WRONG progress if you use something like this:
|
98
118
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
119
|
+
```ruby
|
120
|
+
10.times_with_progress('A') do |time|
|
121
|
+
10.times_with_progress('B') do
|
122
|
+
# code
|
123
|
+
end
|
124
|
+
10.times_with_progress('C') do
|
125
|
+
# code
|
126
|
+
end
|
127
|
+
end
|
128
|
+
```
|
107
129
|
|
108
130
|
But you can use this:
|
109
131
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
end
|
132
|
+
```ruby
|
133
|
+
10.times_with_progress('A') do |time|
|
134
|
+
Progress.step 5 do
|
135
|
+
10.times_with_progress('B') do
|
136
|
+
# code
|
137
|
+
end
|
138
|
+
end
|
139
|
+
Progress.step 5 do
|
140
|
+
10.times_with_progress('C') do
|
141
|
+
# code
|
121
142
|
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
```
|
122
146
|
|
123
147
|
Or if you know that B runs 9 times faster than C:
|
124
148
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
end
|
149
|
+
```ruby
|
150
|
+
10.times_with_progress('A') do |time|
|
151
|
+
Progress.step 1 do
|
152
|
+
10.times_with_progress('B') do
|
153
|
+
# code
|
154
|
+
end
|
155
|
+
end
|
156
|
+
Progress.step 9 do
|
157
|
+
10.times_with_progress('C') do
|
158
|
+
# code
|
136
159
|
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
```
|
137
163
|
|
138
164
|
## Copyright
|
139
165
|
|
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.5.
|
5
|
+
s.version = '3.5.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']
|
@@ -10,8 +10,6 @@ Gem::Specification.new do |s|
|
|
10
10
|
|
11
11
|
s.required_ruby_version = '>= 1.9.3'
|
12
12
|
|
13
|
-
s.rubyforge_project = s.name
|
14
|
-
|
15
13
|
s.metadata = {
|
16
14
|
'bug_tracker_uri' => "https://github.com/toy/#{s.name}/issues",
|
17
15
|
'changelog_uri' => "https://github.com/toy/#{s.name}/blob/master/CHANGELOG.markdown",
|
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.5.
|
4
|
+
version: 3.5.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: 2019-
|
11
|
+
date: 2019-07-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -69,7 +69,7 @@ licenses:
|
|
69
69
|
metadata:
|
70
70
|
bug_tracker_uri: https://github.com/toy/progress/issues
|
71
71
|
changelog_uri: https://github.com/toy/progress/blob/master/CHANGELOG.markdown
|
72
|
-
documentation_uri: https://www.rubydoc.info/gems/progress/3.5.
|
72
|
+
documentation_uri: https://www.rubydoc.info/gems/progress/3.5.2
|
73
73
|
source_code_uri: https://github.com/toy/progress
|
74
74
|
post_install_message:
|
75
75
|
rdoc_options: []
|