Class: Pronto::ClangFormat::Wrapper
- Inherits:
-
Object
- Object
- Pronto::ClangFormat::Wrapper
- Defined in:
- lib/pronto/clang_format/wrapper.rb
Instance Method Summary collapse
-
#initialize ⇒ Wrapper
constructor
A new instance of Wrapper.
-
#run(file_path) ⇒ Object
runs clang-format for the provided file and returns an array of offence objects Params: - file_path: path to the file to be examined by clang-format.
Constructor Details
#initialize ⇒ Wrapper
Returns a new instance of Wrapper.
9 10 11 |
# File 'lib/pronto/clang_format/wrapper.rb', line 9 def initialize @clang_format_path = ENV['PRONTO_CLANG_FORMAT_PATH'] || 'clang-format' end |
Instance Method Details
#run(file_path) ⇒ Object
runs clang-format for the provided file and returns an array of offence objects Params:
-
file_path: path to the file to be examined by clang-format
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/pronto/clang_format/wrapper.rb', line 17 def run(file_path) stdout, stderr, = Open3.capture3("#{@clang_format_path} "\ "-style=#{style} "\ "-output-replacements-xml "\ "#{file_path}") if stderr && !stderr.empty? puts "WARN: pronto-clang_format: #{file_path}: #{stderr}" end return [] if stdout.nil? || stdout == 0 parse_output(file_path, stdout) end |