class Tailor::Rulers::AllowInvalidRubyRuler
Public Class Methods
new(config, options)
click to toggle source
Calls superclass method
Tailor::Ruler::new
# File lib/tailor/rulers/allow_invalid_ruby_ruler.rb, line 7 def initialize(config, options) super(config, options) add_lexer_observers :file_beg end
Public Instance Methods
file_beg_update(file_name)
click to toggle source
# File lib/tailor/rulers/allow_invalid_ruby_ruler.rb, line 12 def file_beg_update(file_name) @file_name = file_name measure end
invalid_ruby?()
click to toggle source
@return [Boolean]
# File lib/tailor/rulers/allow_invalid_ruby_ruler.rb, line 18 def invalid_ruby? log 'Checking for valid Ruby...' result = `"#{Gem.ruby}" -c "#{@file_name}"` result.size.zero? end
measure()
click to toggle source
# File lib/tailor/rulers/allow_invalid_ruby_ruler.rb, line 25 def measure if invalid_ruby? && @config == false lineno = 0 column = 0 msg = 'File contains invalid Ruby; run `ruby -c [your_file.rb]` ' msg << 'for more details.' @problems << Problem.new(problem_type, lineno, column, msg, @options[:level]) end end