progress 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +12 -15
- data/VERSION +1 -1
- data/lib/progress.rb +5 -3
- data/lib/progress/active_record.rb +6 -4
- data/lib/progress/integer.rb +3 -2
- data/lib/progress/with_progress.rb +3 -2
- data/progress.gemspec +1 -1
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -13,7 +13,7 @@ Class to show progress during console script run
|
|
13
13
|
|
14
14
|
== SYNOPSIS:
|
15
15
|
|
16
|
-
1000.times_with_progress('Wait') do |time|
|
16
|
+
1000.times_with_progress('Wait') do |time| # title is optional
|
17
17
|
puts time
|
18
18
|
end
|
19
19
|
|
@@ -53,6 +53,7 @@ Class to show progress during console script run
|
|
53
53
|
|
54
54
|
or just
|
55
55
|
|
56
|
+
symbols = []
|
56
57
|
Progress('Input 100 symbols', 100) do
|
57
58
|
while symbols.length < 100
|
58
59
|
input = gets.scan(/\S/)
|
@@ -71,26 +72,22 @@ Note - you will get WRONG progress if you use something like this:
|
|
71
72
|
But you can use this:
|
72
73
|
|
73
74
|
10.times_with_progress('A') do |time|
|
74
|
-
Progress
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
10.times_with_progress('C'){ … }
|
80
|
-
end
|
75
|
+
Progress.step 1, 2 do
|
76
|
+
10.times_with_progress('B'){ … }
|
77
|
+
end
|
78
|
+
Progress.step 1, 2 do
|
79
|
+
10.times_with_progress('C'){ … }
|
81
80
|
end
|
82
81
|
end
|
83
82
|
|
84
83
|
Or if you know that B runs 10 times faster than C:
|
85
84
|
|
86
85
|
10.times_with_progress('A') do |time|
|
87
|
-
Progress
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
10.times_with_progress('C'){ … }
|
93
|
-
end
|
86
|
+
Progress.step 1, 11 do
|
87
|
+
10.times_with_progress('B'){ … }
|
88
|
+
end
|
89
|
+
Progress.step 10, 11 do
|
90
|
+
10.times_with_progress('C'){ … }
|
94
91
|
end
|
95
92
|
end
|
96
93
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.1
|
data/lib/progress.rb
CHANGED
@@ -85,9 +85,9 @@ class Progress
|
|
85
85
|
end
|
86
86
|
end
|
87
87
|
|
88
|
-
def step(
|
88
|
+
def step(num = 1, den = 1, &block)
|
89
89
|
if levels.last
|
90
|
-
set(levels.last.current + Float(
|
90
|
+
set(levels.last.current + Float(num) / den, &block)
|
91
91
|
elsif block
|
92
92
|
block.call
|
93
93
|
end
|
@@ -98,7 +98,9 @@ class Progress
|
|
98
98
|
ret = if block
|
99
99
|
levels.last.step(value - levels.last.current, &block)
|
100
100
|
end
|
101
|
-
levels.last
|
101
|
+
if levels.last
|
102
|
+
levels.last.current = Float(value)
|
103
|
+
end
|
102
104
|
print_message
|
103
105
|
ret
|
104
106
|
elsif block
|
@@ -4,8 +4,9 @@ if defined?(ActiveRecord::Base)
|
|
4
4
|
def find_each_with_progress(options = {})
|
5
5
|
Progress.start(name.tableize, count(options)) do
|
6
6
|
find_each do |model|
|
7
|
-
|
8
|
-
|
7
|
+
Progress.step do
|
8
|
+
yield model
|
9
|
+
end
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
@@ -13,8 +14,9 @@ if defined?(ActiveRecord::Base)
|
|
13
14
|
def find_in_batches_with_progress(options = {})
|
14
15
|
Progress.start(name.tableize, count(options)) do
|
15
16
|
find_in_batches do |batch|
|
16
|
-
|
17
|
-
|
17
|
+
Progress.step batch.length do
|
18
|
+
yield batch
|
19
|
+
end
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
data/lib/progress/integer.rb
CHANGED
data/progress.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: progress
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Boba Fat
|