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
109
110
111
|
# File 'lib/syntax_tree/cli.rb', line 109
def failure
warn("The listed files could not be formatted idempotently.")
end
|
#run(handler, filepath, source) ⇒ Object
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/syntax_tree/cli.rb', line 93
def run(handler, filepath, source)
warning = "[#{Color.yellow("warn")}] #{filepath}"
formatted = handler.format(source)
if formatted != handler.format(formatted)
raise NonIdempotentFormatError
end
rescue StandardError
warn(warning)
raise
end
|
#success ⇒ Object
105
106
107
|
# File 'lib/syntax_tree/cli.rb', line 105
def success
puts("All files can be formatted idempotently.")
end
|