Class: Lintrunner::Executor

Inherits:
Object
  • Object
show all
Defined in:
lib/lintrunner/executor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Executor

Returns a new instance of Executor.



7
8
9
10
11
# File 'lib/lintrunner/executor.rb', line 7

def initialize(options = {})
  @command = options[:command]
  @parser = options[:parser]
  @plugin = options[:plugin]
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



5
6
7
# File 'lib/lintrunner/executor.rb', line 5

def command
  @command
end

#parserObject (readonly)

Returns the value of attribute parser.



5
6
7
# File 'lib/lintrunner/executor.rb', line 5

def parser
  @parser
end

#pluginObject (readonly)

Returns the value of attribute plugin.



5
6
7
# File 'lib/lintrunner/executor.rb', line 5

def plugin
  @plugin
end

Instance Method Details

#execute(filename, options = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/lintrunner/executor.rb', line 13

def execute(filename, options = {})
  if command && parser
    output = `#{command} #{filename} 2>/dev/null`
    exit_code = $?.exitstatus
    parser.parse(output, exit_code, options)
  elsif plugin
    plugin.new(filename).run(options)
  end
end