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
690
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
たのしいparse.y
ydah
3
120
作って理解する RDBMSのしくみ
ydah
21
6.3k
How does Lrama make the Ruby parser grammar G.O.A.T.?
ydah
2
150
The Sequel to a Dream of Ruby Parser's Grammar
ydah
1
280
Kaigi Effect
ydah
0
84
Does Ruby Parser dream of highly expressive grammar?
ydah
3
1.3k
Extracting from rubocop-rspec
ydah
0
110
Ruby Parser Basics
ydah
0
240
Menhir is here!
ydah
1
5.8k
Other Decks in Technology
See All in Technology
TSKaigi 2024 の登壇から広がったコミュニティ活動について
tsukuha
0
160
プロダクト開発を加速させるためのQA文化の築き方 / How to build QA culture to accelerate product development
mii3king
1
260
レンジャーシステムズ | 会社紹介(採用ピッチ)
rssytems
0
150
成果を出しながら成長する、アウトプット駆動のキャッチアップ術 / Output-driven catch-up techniques to grow while producing results
aiandrox
0
180
10分で学ぶKubernetesコンテナセキュリティ/10min-k8s-container-sec
mochizuki875
3
320
複雑性の高いオブジェクト編集に向き合う: プラガブルなReactフォーム設計
righttouch
PRO
0
110
LINEスキマニにおけるフロントエンド開発
lycorptech_jp
PRO
0
330
Fanstaの1年を大解剖! 一人SREはどこまでできるのか!?
syossan27
2
160
Microsoft Azure全冠になってみた ~アレを使い倒した者が試験を制す!?~/Obtained all Microsoft Azure certifications Those who use "that" to the full will win the exam! ?
yuj1osm
1
110
権威ドキュメントで振り返る2024 #年忘れセキュリティ2024
hirotomotaguchi
2
730
AI時代のデータセンターネットワーク
lycorptech_jp
PRO
1
280
大幅アップデートされたRagas v0.2をキャッチアップ
os1ma
2
520
Featured
See All Featured
GitHub's CSS Performance
jonrohan
1030
460k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
Producing Creativity
orderedlist
PRO
341
39k
Speed Design
sergeychernyshev
25
670
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
Intergalactic Javascript Robots from Outer Space
tanoku
270
27k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
32
2.7k
Designing on Purpose - Digital PM Summit 2013
jponch
116
7k
Building Your Own Lightsaber
phodgson
103
6.1k
How GitHub (no longer) Works
holman
311
140k
BBQ
matthewcrist
85
9.4k
It's Worth the Effort
3n
183
28k
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