formatador 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/formatador.gemspec +2 -2
- data/lib/formatador.rb +1 -1
- data/lib/formatador/progressbar.rb +15 -4
- data/tests/table_tests.rb +1 -0
- metadata +4 -4
data/formatador.gemspec
CHANGED
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
|
|
13
13
|
## If your rubyforge_project name is different, then edit it and comment out
|
14
14
|
## the sub! line in the Rakefile
|
15
15
|
s.name = 'formatador'
|
16
|
-
s.version = '0.1.
|
17
|
-
s.date = '2011-05
|
16
|
+
s.version = '0.1.5'
|
17
|
+
s.date = '2011-07-05'
|
18
18
|
s.rubyforge_project = 'formatador'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
data/lib/formatador.rb
CHANGED
@@ -24,18 +24,29 @@ class Formatador
|
|
24
24
|
output << options[:label]
|
25
25
|
end
|
26
26
|
|
27
|
-
|
28
|
-
|
27
|
+
# width
|
28
|
+
# we are going to write a string that looks like " current/total"
|
29
|
+
# It would be nice if it were left padded with spaces in such a way that
|
30
|
+
# it puts the progress bar in a constant place on the page. This witdh
|
31
|
+
# calculation allows for the "current" string to be up to two characters
|
32
|
+
# longer than the "total" string without problems. eg- current =
|
33
|
+
# 9.99, total = 10
|
34
|
+
padding = total.to_s.size * 2 + 3
|
35
|
+
|
36
|
+
output << "[#{color}]%#{padding}s[/]" % "#{current}/#{total}"
|
29
37
|
|
30
38
|
percent = current.to_f / total.to_f
|
39
|
+
percent = 0 if percent < 0
|
40
|
+
percent = 1 if percent > 1
|
41
|
+
|
31
42
|
done = '*' * (percent * width).ceil
|
32
43
|
remaining = ' ' * (width - done.length)
|
33
44
|
output << "[_white_]|[/][#{color}][_#{color}_]#{done}[/]#{remaining}[_white_]|[/]"
|
34
45
|
|
35
46
|
if started_at
|
36
47
|
elapsed = Time.now - started_at
|
37
|
-
minutes = (elapsed / 60).
|
38
|
-
seconds = (elapsed % 60).
|
48
|
+
minutes = (elapsed / 60).truncate.to_s
|
49
|
+
seconds = (elapsed % 60).truncate.to_s
|
39
50
|
output << "#{minutes}:#{'0' if seconds.size < 2}#{seconds}"
|
40
51
|
end
|
41
52
|
|
data/tests/table_tests.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: formatador
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 17
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 5
|
10
|
+
version: 0.1.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- geemus (Wesley Beary)
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-05
|
18
|
+
date: 2011-07-05 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|