console_progress 0.1.1 → 0.1.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 +4 -4
- data/README.md +10 -0
- data/lib/console_progress/version.rb +1 -1
- data/lib/console_progress.rb +11 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ce12a09624536ea9d1aa967907a660f746691d42
|
4
|
+
data.tar.gz: 3065de5244a2f7beb809171373bfdfc0743c2cc6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2fb7200b2e11141f95326a0357d45f11a808703f6d64ec075242bf56fb0ac512b88a78560b47f86a12b2b7d01b4e44a0570895d843ab95a57ced5095b06ef7a
|
7
|
+
data.tar.gz: b8c4834ede1cf1f8d30902b30a89cfc66d4081a879ffb832e9249e99c6e1626ece79bcbae0d97b19cd5f8c16925286961dcaea46a563b7b26d7c7dc5493f29fe
|
data/README.md
CHANGED
@@ -38,6 +38,16 @@ ETA: 4/100 Remainng: 2:25 Took: 2.00s Avg: 1.50s Elapsed: 6
|
|
38
38
|
...
|
39
39
|
```
|
40
40
|
|
41
|
+
You can also do it every 10 steps by doing something like this:
|
42
|
+
```
|
43
|
+
prog = ConsoleProgress::ETA.new(100)
|
44
|
+
prog.start
|
45
|
+
100.times do |i|
|
46
|
+
puts prog.progress(current_step: i) if i % 10 == 0
|
47
|
+
sleep 2
|
48
|
+
end
|
49
|
+
```
|
50
|
+
|
41
51
|
Initialize with `number of steps`. Start it. Call `.progress` to move up a step.
|
42
52
|
|
43
53
|
You can override the default message prefix with `prog.message_prefix = 'Bob'`
|
data/lib/console_progress.rb
CHANGED
@@ -19,6 +19,7 @@ module ConsoleProgress
|
|
19
19
|
"Elapsed: {{elapsed_time}}"
|
20
20
|
@step = 0
|
21
21
|
@times = []
|
22
|
+
start
|
22
23
|
end
|
23
24
|
|
24
25
|
def start
|
@@ -31,7 +32,7 @@ module ConsoleProgress
|
|
31
32
|
t = Time.now
|
32
33
|
@step_time = t - @step_time_start
|
33
34
|
|
34
|
-
@elapsed_time = seconds_to_time(
|
35
|
+
@elapsed_time = seconds_to_time(t - @start_time)
|
35
36
|
|
36
37
|
@times << @step_time
|
37
38
|
@avg_time = @times.reduce(0, :+) / @times.size
|
@@ -72,5 +73,14 @@ module ConsoleProgress
|
|
72
73
|
sleep 2
|
73
74
|
end
|
74
75
|
end
|
76
|
+
|
77
|
+
def self.example2
|
78
|
+
eta = ConsoleProgress::ETA.new(100)
|
79
|
+
eta.start
|
80
|
+
100.times do |i|
|
81
|
+
puts eta.progress(current_step: i) if i % 10 == 0
|
82
|
+
sleep 1
|
83
|
+
end
|
84
|
+
end
|
75
85
|
end
|
76
86
|
end
|