Class: Codeqa::Checkers::CheckErb
Instance Attribute Summary
#errors, #sourcefile
Class Method Summary
collapse
Instance Method Summary
collapse
#initialize
Class Method Details
.available? ⇒ Boolean
8
9
10
|
# File 'lib/codeqa/checkers/check_erb.rb', line 8
def self.available?
engine?
end
|
.check?(sourcefile) ⇒ Boolean
4
5
6
|
# File 'lib/codeqa/checkers/check_erb.rb', line 4
def self.check?(sourcefile)
sourcefile.erb?
end
|
.engine? ⇒ Boolean
rubocop:enable RescueException,HandleExceptions
37
38
39
40
41
42
43
44
45
|
# File 'lib/codeqa/checkers/check_erb.rb', line 37
def self.engine?
@@engine ||= if %w(actionview action_view).include? Codeqa.configuration.erb_engine.downcase
require 'action_view'
true
else
require 'erb'
true
end
end
|
Instance Method Details
#check ⇒ Object
rubocop:disable RescueException,HandleExceptions
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/codeqa/checkers/check_erb.rb', line 21
def check
if defined?(ActionView)
ActionView::Template::Handlers::Erubis.new(erb).result
else
ERB.new(sourcefile.content.gsub('<%=', '<%'), nil, '-').result
end
rescue SyntaxError => e
errors.add(nil, <<-EOF)
#{e.message}
#{e.backtrace.join("\n")}
EOF
rescue Exception
true end
|
#hint ⇒ Object
16
17
18
|
# File 'lib/codeqa/checkers/check_erb.rb', line 16
def hint
'There is a syntax error in the ruby code of the erb parsed file.'
end
|
#name ⇒ Object
12
13
14
|
# File 'lib/codeqa/checkers/check_erb.rb', line 12
def name
'erb syntax'
end
|