Skip to content

Commit

Permalink
progress table
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Mulder committed Sep 23, 2011
1 parent d0e7212 commit 1b4b493
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/cucumber/ast/table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,13 @@ def to_s(options = {}) #:nodoc:
options = {:color => true, :indent => 2, :prefixes => TO_S_PREFIXES}.merge(options)
io = StringIO.new

c = Term::ANSIColor.coloring?
Term::ANSIColor.coloring = options[:color]
c = Cucumber::Formatter::AnsiEscapes.coloring?
Cucumber::Formatter::AnsiEscapes.coloring = options[:color]
formatter = Formatter::Pretty.new(nil, io, options)
formatter.instance_variable_set('@indent', options[:indent])
TreeWalker.new(nil, [formatter]).visit_multiline_arg(self)

Term::ANSIColor.coloring = c
Cucumber::Formatter::AnsiEscapes.coloring = c
io.rewind
s = "\n" + io.read + (" " * (options[:indent] - 2))
s
Expand Down
15 changes: 14 additions & 1 deletion lib/cucumber/formatter/ansi_escapes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,20 @@ module AnsiEscapes
ALIASES["#{key}_arg"].split(',').map{|color| COLORS[color]}.join('')
end
end


def self.coloring?
@coloring
end

# Turns the coloring on or off globally, so you can easily do
# this for example:
# Term::ANSIColor::coloring = STDOUT.isatty
def self.coloring=(val)
@coloring = val
end
self.coloring = true


def reset
"\e[0m"
end
Expand Down

0 comments on commit 1b4b493

Please sign in to comment.