Sha256: e7014e93d15797007416b8d7a7661f15c7ba87bf2f212a8a3d7ac20bbda27176
Contents?: true
Size: 1.09 KB
Versions: 1
Compression:
Stored size: 1.09 KB
Contents
# frozen_string_literal: true module RuboCop module Rubycw module WarningCapturer if defined?(RubyVM::AbstractSyntaxTree) require 'stringio' module ::Warning def warn(*message) if WarningCapturer.warnings WarningCapturer.warnings.concat message else super end end end def self.capture(source) start RubyVM::AbstractSyntaxTree.parse(source) warnings ensure stop end def self.start @verbose = $VERBOSE $VERBOSE = true @warnings = [] end def self.stop $VERBOSE = @verbose if defined?(@verbose) @warnings = nil end def self.warnings @warnings end stop else require 'rbconfig' require 'open3' def self.capture(source) _stdout, stderr, _status = Open3.capture3(RbConfig.ruby, '-cw', '-e', source) stderr.lines.map(&:chomp) end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rubocop-rubycw-0.1.1 | lib/rubocop/rubycw/warning_capturer.rb |