Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

documentation for the next release

  • Loading branch information...
commit 5df672fe367628744142696697254e0a3e02fcda 1 parent 20ca6f8
@wbailey authored
View
15 README.md
@@ -4,6 +4,9 @@ This gem provides an simple way to add RSpec like formatting of the output of yo
eliminates the need to litter your code with *puts* statements instead providing a cleaner, more
ruby like way of reporting progress to the user throught the command line interface.
+With the release of Version 2.0, it is now possible to produce tables with and without borders. See
+the section on *Tables* for more examples.
+
### Installation
It is up on rubygems.org so add it to your bundle or do it the old fashioned way:
@@ -58,6 +61,18 @@ There are several methods the mixin provides that do not depend on the formatter
* _text_ - String to display
* _:align_ - 'left'|'right'|'center' align the string text. _Default: 'left'_
* _:width_ - The width in characters of the string text. _Default: 100_
+* _table(hash) {block}_
+ * The first argument is a hash that defines properties of the table.
+ * _:border_ - true|false indicates whether to include borders around the table cells
+ * The second argument is a block which includes calls the to the _row_ method
+* _row {block}_
+ * Only argument is a block with calls to _column_ allowed
+* _column(string, hash)_
+ * _text_ - String to display in the table cell
+ * _options_ - The options to define the column
+ * :width
+ * :padding
+ * :align
### Progress Formatter
View
6 lib/table.rb
@@ -4,17 +4,13 @@
class Table
include OptionsValidator
- VALID_OPTIONS = [:width, :border, :padding]
+ VALID_OPTIONS = [:border]
attr_accessor :rows, *VALID_OPTIONS
def initialize(options = {})
self.validate_options(options, *VALID_OPTIONS)
- self.width = (options[:width] || 100).to_i
self.border = options[:border] || false
- self.padding = (options[:padding] || 1).to_i
-
- raise ArgumentError unless self.width > 0 && self.padding > 0
@rows = []
end
View
2  spec/command_line_reporter_spec.rb
@@ -534,7 +534,7 @@
it 'accepts valid options' do
expect {
- subject.table(:width => 50) { }
+ subject.table(:border => true) { }
}.to_not raise_error
end
View
28 spec/table_spec.rb
@@ -9,20 +9,6 @@
}.to_not raise_error
end
- it 'defaults the width' do
- Table.new.width.should == 100
- end
-
- it 'accepts the width' do
- Table.new(:width => 50).width.should == 50
- end
-
- it 'requires valid widths' do
- expect {
- Table.new(:width => 'asdf')
- }.to raise_error ArgumentError
- end
-
it 'defaults the border' do
Table.new.border.should == false
end
@@ -30,20 +16,6 @@
it 'accepts the border' do
Table.new(:border => true).border.should == true
end
-
- it 'defaults the padding' do
- Table.new.padding.should == 1
- end
-
- it 'accepts the padding' do
- Table.new(:padding => 10).padding.should == 10
- end
-
- it 'requires valid padding' do
- expect {
- Table.new(:padding => 'asdf')
- }.to raise_error ArgumentError
- end
end
context 'rows' do
Please sign in to comment.
Something went wrong with that request. Please try again.