formatador 0.1.5 → 0.2.0
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 +16 -5
- data/lib/formatador/progressbar.rb +6 -3
- metadata +6 -6
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.
|
17
|
-
s.date = '2011-07-
|
16
|
+
s.version = '0.2.0'
|
17
|
+
s.date = '2011-07-14'
|
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
@@ -3,7 +3,7 @@ require File.join(File.dirname(__FILE__), 'formatador', 'progressbar')
|
|
3
3
|
|
4
4
|
class Formatador
|
5
5
|
|
6
|
-
VERSION = '0.
|
6
|
+
VERSION = '0.2.0'
|
7
7
|
|
8
8
|
STYLES = {
|
9
9
|
:"\/" => "0",
|
@@ -68,7 +68,7 @@ class Formatador
|
|
68
68
|
|
69
69
|
def display_line(string = '')
|
70
70
|
display(string)
|
71
|
-
|
71
|
+
new_line
|
72
72
|
nil
|
73
73
|
end
|
74
74
|
|
@@ -97,13 +97,24 @@ class Formatador
|
|
97
97
|
' ' * @indent
|
98
98
|
end
|
99
99
|
|
100
|
-
def redisplay(string = '')
|
101
|
-
print("\r#{' ' *
|
100
|
+
def redisplay(string = '', width = 120)
|
101
|
+
print("\r#{' ' * width}\r")
|
102
102
|
display("#{string}")
|
103
103
|
nil
|
104
104
|
end
|
105
105
|
|
106
|
-
|
106
|
+
def redisplay_line(string = '', width = 120)
|
107
|
+
redisplay(string, width)
|
108
|
+
new_line
|
109
|
+
nil
|
110
|
+
end
|
111
|
+
|
112
|
+
def new_line
|
113
|
+
print("\n")
|
114
|
+
nil
|
115
|
+
end
|
116
|
+
|
117
|
+
%w{display display_line display_lines display_table display_compact_table indent parse redisplay redisplay_line new_line redisplay_progressbar}.each do |method|
|
107
118
|
eval <<-DEF
|
108
119
|
def self.#{method}(*args, &block)
|
109
120
|
Thread.current[:formatador] ||= new
|
@@ -1,12 +1,15 @@
|
|
1
1
|
class Formatador
|
2
2
|
|
3
3
|
def redisplay_progressbar(current, total, options = {})
|
4
|
-
options = { :color => 'white', :width => 50 }.merge!(options)
|
4
|
+
options = { :color => 'white', :width => 50, :new_line => true }.merge!(options)
|
5
5
|
data = progressbar(current, total, options)
|
6
6
|
if current < total
|
7
7
|
redisplay(data)
|
8
8
|
else
|
9
|
-
redisplay("#{data}
|
9
|
+
redisplay("#{data}")
|
10
|
+
if options[:new_line]
|
11
|
+
new_line
|
12
|
+
end
|
10
13
|
@progressbar_started_at = nil
|
11
14
|
end
|
12
15
|
end
|
@@ -32,7 +35,7 @@ class Formatador
|
|
32
35
|
# longer than the "total" string without problems. eg- current =
|
33
36
|
# 9.99, total = 10
|
34
37
|
padding = total.to_s.size * 2 + 3
|
35
|
-
|
38
|
+
|
36
39
|
output << "[#{color}]%#{padding}s[/]" % "#{current}/#{total}"
|
37
40
|
|
38
41
|
percent = current.to_f / total.to_f
|
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: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
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-07-
|
18
|
+
date: 2011-07-14 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
95
|
requirements: []
|
96
96
|
|
97
97
|
rubyforge_project: formatador
|
98
|
-
rubygems_version: 1.4.
|
98
|
+
rubygems_version: 1.4.2
|
99
99
|
signing_key:
|
100
100
|
specification_version: 2
|
101
101
|
summary: Ruby STDOUT text formatting
|