Class: Linter
- Inherits:
-
Object
- Object
- Linter
- Defined in:
- lib/B4U/linter.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#ignore ⇒ Object
readonly
Returns the value of attribute ignore.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(name:, command:, ignore: false) ⇒ Linter
constructor
A new instance of Linter.
- #run ⇒ Object
Constructor Details
#initialize(name:, command:, ignore: false) ⇒ Linter
Returns a new instance of Linter.
4 5 6 7 8 |
# File 'lib/B4U/linter.rb', line 4 def initialize(name:, command:, ignore: false) @name = name @command = command @ignore = ignore end |
Instance Attribute Details
#command ⇒ Object (readonly)
Returns the value of attribute command.
2 3 4 |
# File 'lib/B4U/linter.rb', line 2 def command @command end |
#ignore ⇒ Object (readonly)
Returns the value of attribute ignore.
2 3 4 |
# File 'lib/B4U/linter.rb', line 2 def ignore @ignore end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
2 3 4 |
# File 'lib/B4U/linter.rb', line 2 def name @name end |
Instance Method Details
#run ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/B4U/linter.rb', line 10 def run console_output, status = Open3.capture2e(command) if status.success? puts "✅ - #{name}".green elsif ignore puts "❌ - #{name} (ignored)".magenta else puts "❌ - #{name}".red raise LinterError.new(linter: name, console_output:) end end |