formatador 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +35 -0
- data/VERSION +1 -1
- data/formatador.gemspec +2 -2
- data/lib/formatador/progressbar.rb +5 -1
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -2,6 +2,41 @@
|
|
2
2
|
|
3
3
|
STDOUT text formatting
|
4
4
|
|
5
|
+
== Quick and dirty
|
6
|
+
|
7
|
+
You can call class methods to print out single lines like this:
|
8
|
+
|
9
|
+
Formatador.display_line('Hello World')
|
10
|
+
|
11
|
+
You use tags, similar to html, to set formatting options:
|
12
|
+
|
13
|
+
Formatador.display_line('[green]Hello World[/]')
|
14
|
+
|
15
|
+
[/] resets everything to normal, colors are supported and [_color_] sets the background color.
|
16
|
+
|
17
|
+
== Standard options
|
18
|
+
|
19
|
+
* format - and adds color codes if STDOUT.tty? is true
|
20
|
+
* display - calls format on the input and prints it
|
21
|
+
* display_line - calls display, but adds on a newline (\n)
|
22
|
+
* redisplay - Displays text, prepended with \r which will overwrite the last existing line
|
23
|
+
|
24
|
+
== Extensions
|
25
|
+
|
26
|
+
* display_table: takes an array of hashes. Each hash is a row, with the keys being the headers and values being the data. An optional second argument can specify which headers/columns to include and in what order they should appear.
|
27
|
+
* redisplay_progressbar: takes the current and total values as its first two arguments and redisplays a progressbar (until current = total and then it display_lines). An optional third argument represents the start time and will add an elapsed time counter.
|
28
|
+
|
29
|
+
== Indentation
|
30
|
+
|
31
|
+
By initializing a formatador object you can keep track of indentation:
|
32
|
+
|
33
|
+
formatador = Formatador.new
|
34
|
+
formatador.display_line('one level of indentation')
|
35
|
+
formatador.indent {
|
36
|
+
formatador.display_line('two levels of indentation')
|
37
|
+
}
|
38
|
+
formatador.display_line('one level of indentation')
|
39
|
+
|
5
40
|
== Copyright
|
6
41
|
|
7
42
|
(The MIT License)
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.12
|
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.12"
|
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-07}
|
13
13
|
s.description = %q{STDOUT text formatting}
|
14
14
|
s.email = %q{wbeary@engineyard.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -20,6 +20,10 @@ class Formatador
|
|
20
20
|
|
21
21
|
output = []
|
22
22
|
|
23
|
+
if options[:label]
|
24
|
+
output << options[:label]
|
25
|
+
end
|
26
|
+
|
23
27
|
padding = ' ' * (total.to_s.size - current.to_s.size)
|
24
28
|
output << "[#{color}]#{padding}#{current}/#{total}[/]"
|
25
29
|
|
@@ -34,7 +38,7 @@ class Formatador
|
|
34
38
|
end
|
35
39
|
|
36
40
|
output << ''
|
37
|
-
output.join('
|
41
|
+
output.join(' ')
|
38
42
|
end
|
39
43
|
|
40
44
|
end
|
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
|
+
- 12
|
9
|
+
version: 0.0.12
|
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-07 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|