ɾ Name: Yudai Takada
ɾ GitHub: @ydah / X: @ydah_
ɾ Software Engineer at ANDPAD, Inc.
ɾ Member of RuboCop RSpec team
ɾ Member of Ruby Kansai
ɾ Loves beer and heavy metal/hardcore
self.inspect
module Slim
class Embedded < Filter
class TagEngine < Engine
prepend Minify::Tag
end
class JavaScriptEngine < TagEngine
prepend Minify::Javascript
end
ennd
Slide 21
Slide 21 text
module Slim
class Embedded < Filter
module Minify
module Javascript
include Tag
def on_slim_embedded(engine, body, attrs)
mini
fi
ed_body = minify(body)
super(engine, mini
fi
ed_body, attrs)
end
ennnnd
spec/f
i
xtures/dummy.slim:1
:
5
:
F
:
Lint/Syntax:
unexpected token tCOLON
(Using Ruby 2.7 parser; conf
i
gure using
TargetRubyVersion parameter, under AllCops)
ruby:
^
4MJN3VCZͰͳ͍ͷͰɺ3VCP$PQͰղ
ੳෆՄɻ4ZOUBY&SSPSʹͳΔɻ ͦΕͦ͏
html
ruby:
if File.exists?("foo.txt")
message = "Yay!"
else
message = "Nooo!"
end
h1
#{
message}
Γग़ͯ͠3VCP$PQʹͯ͠
ղੳͯ͠Β͏
Slide 47
Slide 47 text
html
ruby:
if File.exists?("foo.txt")
message = "Yay!"
else
message = "Nooo!"
end
h1
#
{
message}
if File.exists?("foo.txt")
message = "Yay!"
else
message = "Nooo!"
end
Extract & Calc offset
Slim Code
Offset
Slide 48
Slide 48 text
❯ slimembedcop dummy.slim
Inspecting 1 f
i
le
W
Offenses:
dummy.slim:3
:
8
:
W
:
[Correctable] Lint/
DeprecatedClassMethods: File.exists? is deprecated in
favor of File.exist
?.
if File.exists?("foo.txt")
^^^^^^^^^^^^
Slide 49
Slide 49 text
w 3VCP$PQͷطଘͷDPQΛ͑Δ
w ࣗಈमਖ਼ʹରԠ͍ͯ͠Δ
w DPQͷ࡞Γํ͕͔ΕɺTMJNFNCFEDPQ
ͷDPQΛ࡞Δ͜ͱ͕Ͱ͖Δ