Class: Pronto::Stylelint::Linter
- Inherits:
-
Object
- Object
- Pronto::Stylelint::Linter
- Extended by:
- Forwardable
- Defined in:
- lib/pronto/stylelint/linter.rb
Constant Summary collapse
- STYLELINT_FAILURE =
'Stylelint failed to run'
- STATUS_CODES =
{ 0 => :success, 1 => :fatal_error, 2 => :lint_problem, 64 => :invalid_cli_usage, 78 => :invalid_configuration_file }.freeze
Instance Attribute Summary collapse
-
#stylelint_config ⇒ Object
readonly
Returns the value of attribute stylelint_config.
Instance Method Summary collapse
-
#initialize(patch, stylelint_config) ⇒ Linter
constructor
A new instance of Linter.
- #run ⇒ Object
Constructor Details
#initialize(patch, stylelint_config) ⇒ Linter
Returns a new instance of Linter.
32 33 34 35 36 |
# File 'lib/pronto/stylelint/linter.rb', line 32 def initialize(patch, stylelint_config) @patch = patch @stylelint_config = stylelint_config @stylint_major_version = nil end |
Instance Attribute Details
#stylelint_config ⇒ Object (readonly)
Returns the value of attribute stylelint_config.
12 13 14 |
# File 'lib/pronto/stylelint/linter.rb', line 12 def stylelint_config @stylelint_config end |
Instance Method Details
#run ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/pronto/stylelint/linter.rb', line 38 def run Dir.chdir(git_repo_path) do stdout, stderr, status = Open3.capture3(cli_command) JSON.parse( case thread_status(status) when :success, :lint_problem stdout.empty? ? stderr : stdout else puts "#{STYLELINT_FAILURE} - #{thread_status(status)}:\n#{stderr}" '[]' end ) end end |