Class: Tailor::Rulers::AllowInvalidRubyRuler
Instance Attribute Summary
#lexer_observers
Instance Method Summary
collapse
#add_child_ruler, #problem_type, #problems
included
Constructor Details
Returns a new instance of AllowInvalidRubyRuler.
7
8
9
10
|
# File 'lib/tailor/rulers/allow_invalid_ruby_ruler.rb', line 7
def initialize(config, options)
super(config, options)
add_lexer_observers :file_beg
end
|
Instance Method Details
#file_beg_update(file_name) ⇒ Object
12
13
14
15
|
# 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? ⇒ Boolean
18
19
20
21
22
23
|
# 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 ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
|
# 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
|