Sha256: 30d9d2a082e939db9f8f00ba564b45f188396568e22f11ced19458dc57c38f92
Contents?: true
Size: 1.07 KB
Versions: 2
Compression:
Stored size: 1.07 KB
Contents
# frozen_string_literal: true module RuboCop module Rubycw module WarningCapturer if defined?(RubyVM::AbstractSyntaxTree) module ::Warning def self.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', stdin_data: source) stderr.lines.map(&:chomp) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubocop-rubycw-0.1.5 | lib/rubocop/rubycw/warning_capturer.rb |
rubocop-rubycw-0.1.4 | lib/rubocop/rubycw/warning_capturer.rb |