formatador 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -0
- data/Rakefile +3 -7
- data/formatador.gemspec +7 -4
- data/lib/formatador.rb +1 -14
- data/lib/formatador/table.rb +1 -1
- data/tests/basic_tests.rb +28 -0
- data/tests/table_tests.rb +45 -0
- data/tests/tests_helper.rb +9 -0
- metadata +36 -7
- data/tests/formatador_tests.rb +0 -8
data/Gemfile
ADDED
data/Rakefile
CHANGED
@@ -43,14 +43,10 @@ end
|
|
43
43
|
#
|
44
44
|
#############################################################################
|
45
45
|
|
46
|
-
|
46
|
+
require 'shindo/rake'
|
47
|
+
Shindo::Rake.new
|
47
48
|
|
48
|
-
|
49
|
-
Rake::TestTask.new(:test) do |test|
|
50
|
-
test.libs << 'lib' << 'test'
|
51
|
-
test.pattern = 'test/**/test_*.rb'
|
52
|
-
test.verbose = true
|
53
|
-
end
|
49
|
+
task :default => :tests
|
54
50
|
|
55
51
|
desc "Generate RCov test coverage and open in your browser"
|
56
52
|
task :coverage do
|
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-03-
|
16
|
+
s.version = '0.1.2'
|
17
|
+
s.date = '2011-03-21'
|
18
18
|
s.rubyforge_project = 'formatador'
|
19
19
|
|
20
20
|
## Make sure your summary is short. The description may be as long
|
@@ -52,20 +52,23 @@ Gem::Specification.new do |s|
|
|
52
52
|
|
53
53
|
## List your development dependencies here. Development dependencies are
|
54
54
|
## those that are only needed during development
|
55
|
-
|
55
|
+
s.add_development_dependency('rake')
|
56
|
+
s.add_development_dependency('shindo')
|
56
57
|
|
57
58
|
## Leave this section as-is. It will be automatically generated from the
|
58
59
|
## contents of your Git repository via the gemspec task. DO NOT REMOVE
|
59
60
|
## THE MANIFEST COMMENTS, they are used as delimiters by the task.
|
60
61
|
# = MANIFEST =
|
61
62
|
s.files = %w[
|
63
|
+
Gemfile
|
62
64
|
README.rdoc
|
63
65
|
Rakefile
|
64
66
|
formatador.gemspec
|
65
67
|
lib/formatador.rb
|
66
68
|
lib/formatador/progressbar.rb
|
67
69
|
lib/formatador/table.rb
|
68
|
-
tests/
|
70
|
+
tests/basic_tests.rb
|
71
|
+
tests/table_tests.rb
|
69
72
|
tests/tests_helper.rb
|
70
73
|
]
|
71
74
|
# = MANIFEST =
|
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.1.
|
6
|
+
VERSION = '0.1.2'
|
7
7
|
|
8
8
|
STYLES = {
|
9
9
|
:"\/" => "0",
|
@@ -113,16 +113,3 @@ class Formatador
|
|
113
113
|
end
|
114
114
|
|
115
115
|
end
|
116
|
-
|
117
|
-
if __FILE__ == $0
|
118
|
-
|
119
|
-
Formatador.display_line("[negative]Formatador![/]")
|
120
|
-
Formatador.indent do
|
121
|
-
Formatador.display_lines([
|
122
|
-
'one',
|
123
|
-
'two'
|
124
|
-
])
|
125
|
-
end
|
126
|
-
Formatador.display_table([], [:foo])
|
127
|
-
|
128
|
-
end
|
data/lib/formatador/table.rb
CHANGED
@@ -0,0 +1,28 @@
|
|
1
|
+
Shindo.tests("Formatador") do
|
2
|
+
|
3
|
+
tests("#display_line(Formatador)").returns(" Formatador\n") do
|
4
|
+
capture_stdout do
|
5
|
+
Formatador.display_line('Formatador')
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
output = <<-OUTPUT
|
10
|
+
one
|
11
|
+
two
|
12
|
+
OUTPUT
|
13
|
+
|
14
|
+
tests("#display_lines(['one', 'two']").returns(output) do
|
15
|
+
capture_stdout do
|
16
|
+
Formatador.display_lines(['one', 'two'])
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
tests("#indent { display_line('Formatador') }").returns(" Formatador\n") do
|
21
|
+
capture_stdout do
|
22
|
+
Formatador.indent do
|
23
|
+
Formatador.display_line('Formatador')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
Shindo.tests("Formatador") do
|
2
|
+
|
3
|
+
output = <<-OUTPUT
|
4
|
+
+---+
|
5
|
+
| \e[1ma\e[0m |
|
6
|
+
+---+
|
7
|
+
| 1 |
|
8
|
+
+---+
|
9
|
+
| 2 |
|
10
|
+
+---+
|
11
|
+
OUTPUT
|
12
|
+
|
13
|
+
tests("#display_table([{:a => 1}, {:a => 2}])").returns(output) do
|
14
|
+
capture_stdout do
|
15
|
+
Formatador.display_table([{:a => 1}, {:a => 2}])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
output = <<-OUTPUT
|
20
|
+
+--------+
|
21
|
+
| \e[1mheader\e[0m |
|
22
|
+
+--------+
|
23
|
+
OUTPUT
|
24
|
+
|
25
|
+
tests("#display_table([], [:header])").returns(output) do
|
26
|
+
capture_stdout do
|
27
|
+
Formatador.display_table([], [:header])
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
output = <<-OUTPUT
|
32
|
+
+--------+
|
33
|
+
| \e[1mheader\e[0m |
|
34
|
+
+--------+
|
35
|
+
| |
|
36
|
+
+--------+
|
37
|
+
OUTPUT
|
38
|
+
|
39
|
+
tests("#display_table([{:a => 1}], [:header])").returns(output) do
|
40
|
+
capture_stdout do
|
41
|
+
Formatador.display_table([{:a => 1}], [:header])
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
data/tests/tests_helper.rb
CHANGED
@@ -3,3 +3,12 @@ $LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
3
3
|
require 'formatador'
|
4
4
|
require 'rubygems'
|
5
5
|
require 'shindo'
|
6
|
+
|
7
|
+
def capture_stdout
|
8
|
+
old_stdout = $stdout
|
9
|
+
new_stdout = StringIO.new
|
10
|
+
$stdout = new_stdout
|
11
|
+
yield
|
12
|
+
$stdout = old_stdout
|
13
|
+
new_stdout.string
|
14
|
+
end
|
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: 31
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 2
|
10
|
+
version: 0.1.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- geemus (Wesley Beary)
|
@@ -15,10 +15,37 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-21 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: rake
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: shindo
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :development
|
48
|
+
version_requirements: *id002
|
22
49
|
description: STDOUT text formatting
|
23
50
|
email: geemus@gmail.com
|
24
51
|
executables: []
|
@@ -28,13 +55,15 @@ extensions: []
|
|
28
55
|
extra_rdoc_files:
|
29
56
|
- README.rdoc
|
30
57
|
files:
|
58
|
+
- Gemfile
|
31
59
|
- README.rdoc
|
32
60
|
- Rakefile
|
33
61
|
- formatador.gemspec
|
34
62
|
- lib/formatador.rb
|
35
63
|
- lib/formatador/progressbar.rb
|
36
64
|
- lib/formatador/table.rb
|
37
|
-
- tests/
|
65
|
+
- tests/basic_tests.rb
|
66
|
+
- tests/table_tests.rb
|
38
67
|
- tests/tests_helper.rb
|
39
68
|
has_rdoc: true
|
40
69
|
homepage: http://github.com/geemus/NAME
|