-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(can-i-deploy): add --output option allowing table or json to be …
…specified For @mefellows
- Loading branch information
Showing
9 changed files
with
94 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
require 'pact_broker/client/matrix/json_formatter' | ||
require 'pact_broker/client/matrix/text_formatter' | ||
|
||
module PactBroker | ||
module Client | ||
class Matrix | ||
class Formatter | ||
def self.call(matrix_lines, format) | ||
formatter = case format | ||
when 'json' then JsonFormatter | ||
when 'table' then TextFormatter | ||
else | ||
raise PactBroker::Client::Error.new("Invalid output option '#{format}. Must be one of 'table' or 'json'.") | ||
end | ||
formatter.call(matrix_lines) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
require 'table_print' | ||
|
||
module PactBroker | ||
module Client | ||
class Matrix | ||
class JsonFormatter | ||
def self.call(matrix_lines) | ||
JSON.pretty_generate(matrix: matrix_lines) | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require 'table_print' | ||
|
||
module PactBroker | ||
module Client | ||
class Matrix | ||
class TextFormatter | ||
Line = Struct.new(:consumer, :consumer_version, :pact_publication_date, :provider, :provider_version, :verification_date) | ||
|
||
def self.call(matrix_lines) | ||
data = matrix_lines.collect do | line | | ||
Line.new( | ||
lookup(line, :consumer, :name), | ||
lookup(line, :consumer, :version, :number), | ||
lookup(line, :pact, :createdAt), | ||
lookup(line, :consumer, :name), | ||
lookup(line, :provider, :version, :number), | ||
lookup(line, :verificationResult, :verifiedAt), | ||
) | ||
end | ||
|
||
printer = TablePrint::Printer.new(data) | ||
printer.table_print | ||
end | ||
|
||
def self.lookup line, *keys | ||
keys.reduce(line) { | line, key | line[key] } | ||
rescue NoMethodError | ||
"???" | ||
end | ||
end | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...oker/client/matrix_text_formatter_spec.rb → ...oker/client/matrix/text_formatter_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57fa24e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm famous - my name is in a git commit message! :)
57fa24e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're immortalised now.