Class: SyntaxTree::CLI::Debug
Overview
An action of the CLI that formats the source twice to check if the first format is not idempotent.
Defined Under Namespace
Classes: NonIdempotentFormatError
Instance Method Summary
collapse
Instance Method Details
#failure ⇒ Object
98
99
100
|
# File 'lib/syntax_tree/cli.rb', line 98
def failure
warn("The listed files could not be formatted idempotently.")
end
|
#run(handler, filepath, source) ⇒ Object
84
85
86
87
88
89
90
91
92
|
# File 'lib/syntax_tree/cli.rb', line 84
def run(handler, filepath, source)
warning = "[#{Color.yellow("warn")}] #{filepath}"
formatted = handler.format(source)
raise NonIdempotentFormatError if formatted != handler.format(formatted)
rescue StandardError
warn(warning)
raise
end
|
#success ⇒ Object
94
95
96
|
# File 'lib/syntax_tree/cli.rb', line 94
def success
puts("All files can be formatted idempotently.")
end
|