formatador 0.0.12 → 0.0.13
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.
- data/VERSION +1 -1
- data/formatador.gemspec +2 -2
- data/lib/formatador.rb +12 -6
- data/lib/formatador/progressbar.rb +3 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.13
|
data/formatador.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{formatador}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.13"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Wesley Beary"]
|
12
|
-
s.date = %q{2010-04-
|
12
|
+
s.date = %q{2010-04-13}
|
13
13
|
s.description = %q{STDOUT text formatting}
|
14
14
|
s.email = %q{wbeary@engineyard.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/formatador.rb
CHANGED
@@ -51,7 +51,7 @@ class Formatador
|
|
51
51
|
:_light_cyan_ => "106",
|
52
52
|
}
|
53
53
|
|
54
|
-
|
54
|
+
PARSE_REGEX = /\[(#{ STYLES.keys.join('|') })\]/ix
|
55
55
|
INDENT_REGEX = /\[indent\]/ix
|
56
56
|
|
57
57
|
def initialize
|
@@ -59,7 +59,7 @@ class Formatador
|
|
59
59
|
end
|
60
60
|
|
61
61
|
def display(string = '')
|
62
|
-
print(
|
62
|
+
print(parse("[indent]#{string}"))
|
63
63
|
STDOUT.flush
|
64
64
|
nil
|
65
65
|
end
|
@@ -70,11 +70,11 @@ class Formatador
|
|
70
70
|
nil
|
71
71
|
end
|
72
72
|
|
73
|
-
def
|
73
|
+
def parse(string)
|
74
74
|
if STDOUT.tty?
|
75
|
-
string.gsub(
|
75
|
+
string.gsub(PARSE_REGEX) { "\e[#{STYLES[$1.to_sym]}m" }.gsub(INDENT_REGEX) { indentation }
|
76
76
|
else
|
77
|
-
string.gsub(
|
77
|
+
string.gsub(PARSE_REGEX, '').gsub(INDENT_REGEX) { indentation }
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
@@ -94,7 +94,7 @@ class Formatador
|
|
94
94
|
nil
|
95
95
|
end
|
96
96
|
|
97
|
-
%w{display display_line display_table
|
97
|
+
%w{display display_line display_table parse redisplay redisplay_progressbar}.each do |method|
|
98
98
|
eval <<-DEF
|
99
99
|
def self.#{method}(*args, &block)
|
100
100
|
new.#{method}(*args, &block)
|
@@ -103,3 +103,9 @@ class Formatador
|
|
103
103
|
end
|
104
104
|
|
105
105
|
end
|
106
|
+
|
107
|
+
if __FILE__ == $0
|
108
|
+
|
109
|
+
Formatador.display_line("[negative]Formatador![/]")
|
110
|
+
|
111
|
+
end
|
@@ -28,7 +28,9 @@ class Formatador
|
|
28
28
|
output << "[#{color}]#{padding}#{current}/#{total}[/]"
|
29
29
|
|
30
30
|
percent = current.to_f / total.to_f
|
31
|
-
|
31
|
+
done = '*' * (percent * width).ceil
|
32
|
+
remaining = ' ' * (width - done.length)
|
33
|
+
output << "[_white_]|[/][#{color}][_#{color}_]#{done}[/]#{remaining}[_white_]|[/]"
|
32
34
|
|
33
35
|
if started_at
|
34
36
|
elapsed = Time.now - started_at
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 13
|
9
|
+
version: 0.0.13
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Wesley Beary
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-04-
|
17
|
+
date: 2010-04-13 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|