Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Handle Slim Safety
Search
ydah
September 09, 2023
Technology
0
670
Handle Slim Safety
大阪Ruby会議03 LT 「Handle Slim Safety」のスライド
https://regional.rubykaigi.org/osaka03/
#osrb03
ydah
September 09, 2023
Tweet
Share
More Decks by ydah
See All by ydah
作って理解する RDBMSのしくみ
ydah
21
5.9k
How does Lrama make the Ruby parser grammar G.O.A.T.?
ydah
2
130
The Sequel to a Dream of Ruby Parser's Grammar
ydah
1
270
Kaigi Effect
ydah
0
67
Does Ruby Parser dream of highly expressive grammar?
ydah
3
1.2k
Extracting from rubocop-rspec
ydah
0
100
Ruby Parser Basics
ydah
0
210
Menhir is here!
ydah
1
5.5k
ほんとにあった怖い話「slimに棲むもの」
ydah
0
1.3k
Other Decks in Technology
See All in Technology
Incident Response Practices: Waroom's Features and Future Challenges
rrreeeyyy
0
160
Taming you application's environments
salaboy
0
180
SREによる隣接領域への越境とその先の信頼性
shonansurvivors
2
510
エンジニア人生の拡張性を高める 「探索型キャリア設計」の提案
tenshoku_draft
1
120
TypeScriptの次なる大進化なるか!? 条件型を返り値とする関数の型推論
uhyo
2
1.6k
Oracle Cloud Infrastructureデータベース・クラウド:各バージョンのサポート期間
oracle4engineer
PRO
28
12k
OCI Vault 概要
oracle4engineer
PRO
0
9.7k
マルチモーダル / AI Agent / LLMOps 3つの技術トレンドで理解するLLMの今後の展望
hirosatogamo
37
12k
オープンソースAIとは何か? --「オープンソースAIの定義 v1.0」詳細解説
shujisado
4
530
Why App Signing Matters for Your Android Apps - Android Bangkok Conference 2024
akexorcist
0
120
TanStack Routerに移行するのかい しないのかい、どっちなんだい! / Are you going to migrate to TanStack Router or not? Which one is it?
kaminashi
0
570
誰も全体を知らない ~ ロールの垣根を超えて引き上げる開発生産性 / Boosting Development Productivity Across Roles
kakehashi
1
220
Featured
See All Featured
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
370
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
16
2.1k
Build The Right Thing And Hit Your Dates
maggiecrowley
33
2.4k
How to Ace a Technical Interview
jacobian
276
23k
Making the Leap to Tech Lead
cromwellryan
133
8.9k
Designing for humans not robots
tammielis
250
25k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
169
50k
4 Signs Your Business is Dying
shpigford
180
21k
Cheating the UX When There Is Nothing More to Optimize - PixelPioneers
stephaniewalter
280
13k
We Have a Design System, Now What?
morganepeng
50
7.2k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
740
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
Transcript
Yudai Takada Osaka RubyKaigi 03 2023.09.09 (Sat) Handle Slim Safety
ɾName: Yudai Takada ɾGitHub: @ydah ɾX: @ydah_ ɾMember of RuboCop
RSpec team ɾSoftware Engineer at ANDPAD, Inc. self.inspect
Handle Slim Safety
What is Slim?
4MJN3BJMTҎ߱ʹରԠͨ͠ߴ ܰྔͳςϯϓϨʔτΤϯδϯͰ͢ɻओ ཁͳ3VCZͷ࣮શͯͰ͔ͬ͠Γςετ͞Ε͍ͯ·͢ɻࢲͨͪܧଓతΠϯ ςάϨʔγϣϯΛ࠾༻͍ͯ͠·͢ɻ HJUIVCBDUJPOT 4MJNͷ֩ͱͳΔߏจͭͷߟ͑ʹΑͬͯಋ͔Ε͍ͯ·͢͜ͷಈ࡞Λߦ͏ ͨΊʹ࠷ݶඞཁͳͷԿ͔ɻଟ͘ͷਓʑͷ4MJNͷߩݙʹΑͬͯ ൴Β ͕͏)BNM+BEFͷӨڹΛड͚ߏจͷՃ͕ߦΘΕ͍ͯ·͢ɻ4MJNͷ
։ൃνʔϜඒݟΔਓͷͷதʹ͋Δ͜ͱΛ͍ͬͯΔͷͰɺ͜͏͍ͬͨ ՃʹΦʔϓϯͰ͢ɻ 4MJNߏจղੳίϯύΠϧʹ5FNQMFΛ͍5JMUʹΈࠐ·Ε·͢ɻ͜Ε ʹΑΓ4JOBUSBϓϨʔϯͳ3BDLͱҰॹʹ͑·͢ɻ
doctype html html head title My Slim Template body ruby:
message = "Slim!" h1 Welcome to #{ message} p This is a simple example. ͜͏͍͏ͭ
҆શʹ͔͋ͭ͏
doctype html html head title My Slim Template body ruby:
message = "Slim!" h1 Welcome to #{ message} p This is a simple example. ࠓͷλʔήοτ ˡ͜͜
͜ΕԿʁ Embedded engines: Tiltͷ͓͔͛ͰɺSlim ଞͷςϯ ϓϨʔτΤϯδϯͷຒΊࠐΈʹݟࣄʹ ରԠ͍ͯ͠·͢ɻ Ruby,JavaScript,css,sass…etc
҆શʹ͔͋ͭ͏
ຒΊࠐΈͷίϝϯτ doctype html html head title My Slim Template body
h1 Welcome to Slim! javascript: // comment alert("Hello, World!");
ίϯύΠϧޙ <!DOCTYPE html> <html> <head> <title>My Slim Template </ title>
< / head> : </ html> <script> / / mecha kimitsu joho alert("Hello, World!"); </ script> ݟΒΕͨ͘ͳ͍ίϝϯτ ݟΒΕͯ͠·͏
ࢼߦࡨޡ %BOHFS4FNHSFQͰܯࠂ͢Δʁ ⭕ϧʔϧΛՃ͢Δ͚ͩͰྑ͍ ❌ίϝϯτॻ͚ͩ͘ͰܯࠂͭΒͦ͏ ❌ܯࠂΛݟམͱ͞ΕΔͱҙຯ͕ͳ͍
ͭͬͨ͘ ZEBITMJNFNCFEEFENJOJGZ
slim-embedded-minify module Slim class Embedded < Filter class TagEngine <
Engine prepend Minify::Tag end class JavaScriptEngine < TagEngine prepend Minify::Javascript end ennd
slim-embedded-minify 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
slim-embedded-minify ⭕ίϝϯτ͕ࣗ༝ʹॻ͚Δ ⭕Ճআ͔ΜͨΜ ⭕ίϯύΠϧ݁ՌΛൺֱͯ͠ίϝϯτ ͷΈ͕ফ͍͑ͯΔ͔ʹΑͬͯ֬ೝՄ
Its safe now
੩తղੳʹ͍ͭͯ
3VCP$PQͰղੳෆՄ 4MJN3VCZͰͳ͍ͷͰɺ 4ZOUBY&SSPSʹͳΔ ͦΕͦ͏ 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: ^
ຒΊࠐΈҎ֎ͷTMJ̼ ੩తղੳπʔϧ͋Γ·͢ •r7kamura/slimcop •r7kamura/rubocop - slim ͕ɺຒΊࠐΜͰ͍ΔRubyίʔυͷ੩త ղੳग़དྷͳ͍
ຒΊࠐΈͷTMJ̼ ੩తղੳπʔϧ͋Γ·͢ •sds/slim - lint ͕ɺautocorrectग़དྷͳ͍
͍ͭͬͨͯ͘Δ ZEBITMJNFNCFEDPQ ❌
slimembedcop html ruby: if File.exists?("foo.txt") message = "Yay!" else message
= "Nooo!" end h1 #{ message} Γग़ͯ͠3VCP$PQʹͯ͠ ղੳͯ͠Β͏
slimembedcop ❯ 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") ^^^^^^^^^^^^
⭕3VCP$PQͷطଘͷDPQ͕͑Δ ⭕ࣗಈमਖ਼ʹରԠ͍ͯ͠Δ ⭕DPQ͕࡞ΕΔʹTMJNFNCFEDPQͷ DPQ࡞ΕΔ slimembedcop
We got static analysis
ීஈԿؾͳ͍ͬͯ͘Δͷʹվળ ͷ༨ҙ֎ͱ͍ͬͯΔͷͰɺͲΜ ͲΜվળͯ͠ɺͲΜͲΜͤʹͳͬͯ ͍͖·͠ΐ͏ʂʂ ·ͱΊ
end