Skip to content

Commit

Permalink
feat: remove 'no data' message when there are no rows.
Browse files Browse the repository at this point in the history
  • Loading branch information
bethesque committed Mar 4, 2019
1 parent 8f2d5a9 commit b0246a2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
11 changes: 8 additions & 3 deletions lib/pact_broker/client/can_i_deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,26 @@ def create_result(matrix)
def success_message(matrix)
message = format_matrix(matrix)
if format != 'json'
message = 'Computer says yes \o/ ' + "\n\n" + message + "\n\n#{Term::ANSIColor.green(matrix.reason)}"
message = 'Computer says yes \o/ ' + message + "\n\n" + Term::ANSIColor.green(matrix.reason)
end
message
end

def failure_message(matrix)
message = format_matrix(matrix)
if format != 'json'
message = 'Computer says no ¯\_(ツ)_/¯ ' + "\n\n" + message + "\n\n#{Term::ANSIColor.red(matrix.reason)}"
message = 'Computer says no ¯\_(ツ)_/¯ ' + message + "\n\n" + Term::ANSIColor.red(matrix.reason)
end
message
end

def format_matrix(matrix)
Matrix::Formatter.call(matrix, format)
formatted_matrix = Matrix::Formatter.call(matrix, format)
if format != 'json' && formatted_matrix.size > 0
"\n\n" + formatted_matrix
else
formatted_matrix
end
end

def format
Expand Down
4 changes: 3 additions & 1 deletion lib/pact_broker/client/matrix/text_formatter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ class TextFormatter
]

def self.call(matrix)
data = matrix[:matrix].collect do | line |
matrix_rows = matrix[:matrix]
return "" if matrix_rows.size == 0
data = matrix_rows.collect do | line |
Line.new(
lookup(line, :consumer, :name),
lookup(line, :consumer, :version, :number),
Expand Down

0 comments on commit b0246a2

Please sign in to comment.