Skip to content

Commit

Permalink
11012 - Empty strings in RPC results doesnt display correctly with pr…
Browse files Browse the repository at this point in the history
…intrpc

The display helper would split a string on new lines and then print each
resulting line padded appropriately.

In the case of an empty line splitting on new lines would return an
empty array and so no output will be produced - not even a new line -
thus resulting in a badly formatted table.
  • Loading branch information
ripienaar committed Jan 10, 2012
1 parent 7457b2d commit 9e034f8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/mcollective/rpc/helpers.rb
Expand Up @@ -206,10 +206,16 @@ def self.text_for_result(sender, status, msg, result, ddl)
result_text << "#{display_as}:"

if [String, Numeric].include?(result[k].class)
result[k].to_s.split("\n").each_with_index do |line, i|
i == 0 ? padtxt = " " : padtxt = " " * (padding + display_length + 2)
lines = result[k].to_s.split("\n")

result_text << "#{padtxt}#{line}\n"
if lines.empty?
result_text << "\n"
else
lines.each_with_index do |line, i|
i == 0 ? padtxt = " " : padtxt = " " * (padding + display_length + 2)

result_text << "#{padtxt}#{line}\n"
end
end
else
padding = " " * (lengths.max + 5)
Expand Down
1 change: 1 addition & 0 deletions website/changelog.md
Expand Up @@ -11,6 +11,7 @@ title: Changelog

|Date|Description|Ticket|
|----|-----------|------|
|2012/01/09|The printrpc helper did not correctly display empty strings in received output|11012|
|2012/01/09|Add a halt method to the Application framework and standardize exit codes|11280|
|2011/11/21|Remove unintended dependency on _pp_ in the ActiveMQ plugin|10992|
|2011/11/17|Allow reply to destinations to be supplied on the command line or API|9847|
Expand Down

0 comments on commit 9e034f8

Please sign in to comment.