Class: SyntaxTree::CLI::Check
Overview
An action of the CLI that ensures that the filepath is formatted as expected.
Defined Under Namespace
Classes: UnformattedError
Instance Attribute Summary collapse
-
#print_width ⇒ Object
readonly
Returns the value of attribute print_width.
Instance Method Summary collapse
- #failure ⇒ Object
-
#initialize(print_width:) ⇒ Check
constructor
A new instance of Check.
- #run(item) ⇒ Object
- #success ⇒ Object
Constructor Details
#initialize(print_width:) ⇒ Check
Returns a new instance of Check.
96 97 98 |
# File 'lib/syntax_tree/cli.rb', line 96 def initialize(print_width:) @print_width = print_width end |
Instance Attribute Details
#print_width ⇒ Object (readonly)
Returns the value of attribute print_width.
94 95 96 |
# File 'lib/syntax_tree/cli.rb', line 94 def print_width @print_width end |
Instance Method Details
#failure ⇒ Object
114 115 116 |
# File 'lib/syntax_tree/cli.rb', line 114 def failure warn("The listed files did not match the expected format.") end |
#run(item) ⇒ Object
100 101 102 103 104 105 106 107 108 |
# File 'lib/syntax_tree/cli.rb', line 100 def run(item) source = item.source if source != item.handler.format(source, print_width) raise UnformattedError end rescue StandardError warn("[#{Color.yellow("warn")}] #{item.filepath}") raise end |
#success ⇒ Object
110 111 112 |
# File 'lib/syntax_tree/cli.rb', line 110 def success puts("All files matched expected format.") end |