Skip to content

Commit dc45340

Browse files
committed
Don't output information for users when we're not on a TTY
1 parent 301027e commit dc45340

File tree

2 files changed

+21
-24
lines changed

2 files changed

+21
-24
lines changed

lib/rdoc/rdoc.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ def document options
442442
generate file_info
443443
end
444444

445-
unless @options.quiet or not @stats then
445+
if @stats and (@options.coverage_report or not @options.quiet) then
446446
puts
447447
puts @stats.summary
448448
end

lib/rdoc/stats/normal.rb

Lines changed: 20 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,46 +5,43 @@
55
class RDoc::Stats::Normal < RDoc::Stats::Quiet
66

77
def begin_adding # :nodoc:
8-
puts "Parsing sources..."
8+
puts "Parsing sources..." if $stdout.tty?
99
end
1010

1111
##
1212
# Prints a file with a progress bar
1313

1414
def print_file files_so_far, filename
15+
return unless $stdout.tty?
16+
1517
progress_bar = sprintf("%3d%% [%2d/%2d] ",
1618
100 * files_so_far / @num_files,
1719
files_so_far,
1820
@num_files)
1921

20-
if $stdout.tty? then
21-
# Print a progress bar, but make sure it fits on a single line. Filename
22-
# will be truncated if necessary.
23-
terminal_width = (ENV['COLUMNS'] || 80).to_i
24-
max_filename_size = terminal_width - progress_bar.size
25-
26-
if filename.size > max_filename_size then
27-
# Turn "some_long_filename.rb" to "...ong_filename.rb"
28-
filename = filename[(filename.size - max_filename_size) .. -1]
29-
filename[0..2] = "..."
30-
end
31-
32-
# Pad the line with whitespaces so that leftover output from the
33-
# previous line doesn't show up.
34-
line = "#{progress_bar}#{filename}"
35-
padding = terminal_width - line.size
36-
line << (" " * padding) if padding > 0
37-
38-
$stdout.print("#{line}\r")
39-
else
40-
$stdout.puts "#{progress_bar} #{filename}"
22+
# Print a progress bar, but make sure it fits on a single line. Filename
23+
# will be truncated if necessary.
24+
terminal_width = (ENV['COLUMNS'] || 80).to_i
25+
max_filename_size = terminal_width - progress_bar.size
26+
27+
if filename.size > max_filename_size then
28+
# Turn "some_long_filename.rb" to "...ong_filename.rb"
29+
filename = filename[(filename.size - max_filename_size) .. -1]
30+
filename[0..2] = "..."
4131
end
4232

33+
# Pad the line with whitespaces so that leftover output from the
34+
# previous line doesn't show up.
35+
line = "#{progress_bar}#{filename}"
36+
padding = terminal_width - line.size
37+
line << (" " * padding) if padding > 0
38+
39+
$stdout.print("#{line}\r")
4340
$stdout.flush
4441
end
4542

4643
def done_adding # :nodoc:
47-
puts
44+
puts if $stdout.tty?
4845
end
4946

5047
end

0 commit comments

Comments
 (0)