progress 1.1.2 → 1.1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE.txt +20 -0
- data/README.markdown +111 -0
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/progress.gemspec +7 -6
- metadata +9 -7
- data/Manifest +0 -10
- data/README.rdoc +0 -137
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Ivan Kuchin
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.markdown
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
# progress
|
2
|
+
|
3
|
+
http://github.com/toy/progress/tree/master
|
4
|
+
|
5
|
+
## DESCRIPTION:
|
6
|
+
|
7
|
+
Class to show progress during console script run
|
8
|
+
|
9
|
+
## SYNOPSIS:
|
10
|
+
|
11
|
+
1000.times_with_progress('Wait') do |time| # title is optional
|
12
|
+
puts time
|
13
|
+
end
|
14
|
+
|
15
|
+
[1, 2, 3].with_progress('Wait').each do |i|
|
16
|
+
puts i
|
17
|
+
end
|
18
|
+
|
19
|
+
(1..100).with_progress('Wait').each do |i|
|
20
|
+
puts i
|
21
|
+
end
|
22
|
+
|
23
|
+
{
|
24
|
+
:a => 'a',
|
25
|
+
:b => 'b',
|
26
|
+
:c => 'c',
|
27
|
+
:d => 'd',
|
28
|
+
}.with_progress('Wait').each do |k, v|
|
29
|
+
puts "#{k} => #{v}"
|
30
|
+
end
|
31
|
+
|
32
|
+
(1..10).with_progress('Outer').map do |a|
|
33
|
+
(1..10).with_progress('Middle').map do |b|
|
34
|
+
(1..10).with_progress('Inner').map do |c|
|
35
|
+
[a, b, c]
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
symbols = []
|
41
|
+
Progress.start('Input 100 symbols', 100) do
|
42
|
+
while symbols.length < 100
|
43
|
+
input = gets.scan(/\S/)
|
44
|
+
symbols += input
|
45
|
+
Progress.step input.length
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
or just
|
50
|
+
|
51
|
+
symbols = []
|
52
|
+
Progress('Input 100 symbols', 100) do
|
53
|
+
while symbols.length < 100
|
54
|
+
input = gets.scan(/\S/)
|
55
|
+
symbols += input
|
56
|
+
Progress.step input.length
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
Note - you will get WRONG progress if you use something like this:
|
61
|
+
|
62
|
+
10.times_with_progress('A') do |time|
|
63
|
+
10.times_with_progress('B') do
|
64
|
+
# code
|
65
|
+
end
|
66
|
+
10.times_with_progress('C') do
|
67
|
+
# code
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
But you can use this:
|
72
|
+
|
73
|
+
10.times_with_progress('A') do |time|
|
74
|
+
Progress.step 1, 2 do
|
75
|
+
10.times_with_progress('B') do
|
76
|
+
# code
|
77
|
+
end
|
78
|
+
end
|
79
|
+
Progress.step 1, 2 do
|
80
|
+
10.times_with_progress('C') do
|
81
|
+
# code
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
Or if you know that B runs 10 times faster than C:
|
87
|
+
|
88
|
+
10.times_with_progress('A') do |time|
|
89
|
+
Progress.step 1, 11 do
|
90
|
+
10.times_with_progress('B') do
|
91
|
+
# code
|
92
|
+
end
|
93
|
+
end
|
94
|
+
Progress.step 10, 11 do
|
95
|
+
10.times_with_progress('C') do
|
96
|
+
# code
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
## REQUIREMENTS:
|
102
|
+
|
103
|
+
ruby )))
|
104
|
+
|
105
|
+
## INSTALL:
|
106
|
+
|
107
|
+
sudo gem install progress
|
108
|
+
|
109
|
+
## Copyright
|
110
|
+
|
111
|
+
Copyright (c) 2010 Ivan Kuchin. See LICENSE.txt for details.
|
data/Rakefile
CHANGED
@@ -11,7 +11,7 @@ Jeweler::Tasks.new do |gem|
|
|
11
11
|
gem.summary = %Q{Show progress of long running tasks}
|
12
12
|
gem.homepage = "http://github.com/toy/#{name}"
|
13
13
|
gem.license = 'MIT'
|
14
|
-
gem.authors = ['
|
14
|
+
gem.authors = ['Ivan Kuchin']
|
15
15
|
gem.add_development_dependency 'jeweler', '~> 1.5.1'
|
16
16
|
gem.add_development_dependency 'rake-gem-ghost'
|
17
17
|
gem.add_development_dependency 'rspec'
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.2
|
1
|
+
1.1.2.1
|
data/progress.gemspec
CHANGED
@@ -5,17 +5,18 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{progress}
|
8
|
-
s.version = "1.1.2"
|
8
|
+
s.version = "1.1.2.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["
|
12
|
-
s.date = %q{2010-12-
|
11
|
+
s.authors = ["Ivan Kuchin"]
|
12
|
+
s.date = %q{2010-12-15}
|
13
13
|
s.extra_rdoc_files = [
|
14
|
-
"
|
14
|
+
"LICENSE.txt",
|
15
|
+
"README.markdown"
|
15
16
|
]
|
16
17
|
s.files = [
|
17
|
-
"
|
18
|
-
"README.
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.markdown",
|
19
20
|
"Rakefile",
|
20
21
|
"VERSION",
|
21
22
|
"lib/progress.rb",
|
metadata
CHANGED
@@ -1,21 +1,22 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: progress
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 93
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 1
|
9
9
|
- 2
|
10
|
-
|
10
|
+
- 1
|
11
|
+
version: 1.1.2.1
|
11
12
|
platform: ruby
|
12
13
|
authors:
|
13
|
-
-
|
14
|
+
- Ivan Kuchin
|
14
15
|
autorequire:
|
15
16
|
bindir: bin
|
16
17
|
cert_chain: []
|
17
18
|
|
18
|
-
date: 2010-12-
|
19
|
+
date: 2010-12-15 00:00:00 +03:00
|
19
20
|
default_executable:
|
20
21
|
dependencies:
|
21
22
|
- !ruby/object:Gem::Dependency
|
@@ -69,10 +70,11 @@ executables: []
|
|
69
70
|
extensions: []
|
70
71
|
|
71
72
|
extra_rdoc_files:
|
72
|
-
-
|
73
|
+
- LICENSE.txt
|
74
|
+
- README.markdown
|
73
75
|
files:
|
74
|
-
-
|
75
|
-
- README.
|
76
|
+
- LICENSE.txt
|
77
|
+
- README.markdown
|
76
78
|
- Rakefile
|
77
79
|
- VERSION
|
78
80
|
- lib/progress.rb
|
data/Manifest
DELETED
data/README.rdoc
DELETED
@@ -1,137 +0,0 @@
|
|
1
|
-
= progress
|
2
|
-
|
3
|
-
* http://github.com/toy/progress/tree/master
|
4
|
-
|
5
|
-
== DESCRIPTION:
|
6
|
-
|
7
|
-
Class to show progress during console script run
|
8
|
-
|
9
|
-
== FEATURES:
|
10
|
-
|
11
|
-
* Progress
|
12
|
-
* Enclosed progress
|
13
|
-
|
14
|
-
== SYNOPSIS:
|
15
|
-
|
16
|
-
1000.times_with_progress('Wait') do |time| # title is optional
|
17
|
-
puts time
|
18
|
-
end
|
19
|
-
|
20
|
-
[1, 2, 3].with_progress('Wait').each do |i|
|
21
|
-
puts i
|
22
|
-
end
|
23
|
-
|
24
|
-
(1..100).with_progress('Wait').each do |i|
|
25
|
-
puts i
|
26
|
-
end
|
27
|
-
|
28
|
-
{
|
29
|
-
:a => 'a',
|
30
|
-
:b => 'b',
|
31
|
-
:c => 'c',
|
32
|
-
:d => 'd',
|
33
|
-
}.with_progress('Wait').each do |k, v|
|
34
|
-
puts "#{k} => #{v}"
|
35
|
-
end
|
36
|
-
|
37
|
-
(1..10).with_progress('Outer').map do |a|
|
38
|
-
(1..10).with_progress('Middle').map do |b|
|
39
|
-
(1..10).with_progress('Inner').map do |c|
|
40
|
-
[a, b, c]
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
symbols = []
|
46
|
-
Progress.start('Input 100 symbols', 100) do
|
47
|
-
while symbols.length < 100
|
48
|
-
input = gets.scan(/\S/)
|
49
|
-
symbols += input
|
50
|
-
Progress.step input.length
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
or just
|
55
|
-
|
56
|
-
symbols = []
|
57
|
-
Progress('Input 100 symbols', 100) do
|
58
|
-
while symbols.length < 100
|
59
|
-
input = gets.scan(/\S/)
|
60
|
-
symbols += input
|
61
|
-
Progress.step input.length
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
Note - you will get WRONG progress if you use something like this:
|
66
|
-
|
67
|
-
10.times_with_progress('A') do |time|
|
68
|
-
10.times_with_progress('B') do
|
69
|
-
# code
|
70
|
-
end
|
71
|
-
10.times_with_progress('C') do
|
72
|
-
# code
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
But you can use this:
|
77
|
-
|
78
|
-
10.times_with_progress('A') do |time|
|
79
|
-
Progress.step 1, 2 do
|
80
|
-
10.times_with_progress('B') do
|
81
|
-
# code
|
82
|
-
end
|
83
|
-
end
|
84
|
-
Progress.step 1, 2 do
|
85
|
-
10.times_with_progress('C') do
|
86
|
-
# code
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
Or if you know that B runs 10 times faster than C:
|
92
|
-
|
93
|
-
10.times_with_progress('A') do |time|
|
94
|
-
Progress.step 1, 11 do
|
95
|
-
10.times_with_progress('B') do
|
96
|
-
# code
|
97
|
-
end
|
98
|
-
end
|
99
|
-
Progress.step 10, 11 do
|
100
|
-
10.times_with_progress('C') do
|
101
|
-
# code
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
== REQUIREMENTS:
|
107
|
-
|
108
|
-
* ruby )))
|
109
|
-
|
110
|
-
== INSTALL:
|
111
|
-
|
112
|
-
* sudo gem install progress
|
113
|
-
|
114
|
-
== LICENSE:
|
115
|
-
|
116
|
-
(The MIT License)
|
117
|
-
|
118
|
-
Copyright (c) 2008 toy
|
119
|
-
|
120
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
121
|
-
a copy of this software and associated documentation files (the
|
122
|
-
'Software'), to deal in the Software without restriction, including
|
123
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
124
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
125
|
-
permit persons to whom the Software is furnished to do so, subject to
|
126
|
-
the following conditions:
|
127
|
-
|
128
|
-
The above copyright notice and this permission notice shall be
|
129
|
-
included in all copies or substantial portions of the Software.
|
130
|
-
|
131
|
-
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
132
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
133
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
134
|
-
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
135
|
-
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
136
|
-
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
137
|
-
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|