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
YARD with RBS Syntax
Search
Takumi Shotoku
July 06, 2023
Technology
1
480
YARD with RBS Syntax
【オフライン開催】Omotesando.rb #87
https://omotesandorb.connpass.com/event/287544/
Takumi Shotoku
July 06, 2023
Tweet
Share
More Decks by Takumi Shotoku
See All by Takumi Shotoku
ドメインの本質を掴む / Get the essence of the domain
sinsoku
2
160
"型"のあるRailsアプリケーション開発 / Typed Rails application development
sinsoku
9
2.4k
Let's get started with Ruby && Rails Tips
sinsoku
0
360
LTの敷居を下げる / Lower the threshold for LT
sinsoku
1
320
CircleCIの高速化🚀 / CircleCI faster
sinsoku
3
1.2k
Railsアプリと型検査 / Rails app and type checking
sinsoku
5
1.4k
💎のつくりかた 2023 / How to make gems 2023
sinsoku
2
330
Make tests run faster
sinsoku
2
640
Get started with OSS contributions
sinsoku
2
1.2k
Other Decks in Technology
See All in Technology
Making your applications cross-environment - OSCG 2024 NA
salaboy
0
200
BLADE: An Attempt to Automate Penetration Testing Using Autonomous AI Agents
bbrbbq
0
330
[CV勉強会@関東 ECCV2024 読み会] オンラインマッピング x トラッキング MapTracker: Tracking with Strided Memory Fusion for Consistent Vector HD Mapping (Chen+, ECCV24)
abemii
0
230
リンクアンドモチベーション ソフトウェアエンジニア向け紹介資料 / Introduction to Link and Motivation for Software Engineers
lmi
4
300k
RubyのWebアプリケーションを50倍速くする方法 / How to Make a Ruby Web Application 50 Times Faster
hogelog
3
950
アプリエンジニアのためのGraphQL入門.pdf
spycwolf
0
100
AI前提のサービス運用ってなんだろう?
ryuichi1208
8
1.4k
100 名超が参加した日経グループ横断の競技型 AWS 学習イベント「Nikkei Group AWS GameDay」の紹介/mediajaws202411
nikkei_engineer_recruiting
1
170
Lexical Analysis
shigashiyama
1
150
OCI Security サービス 概要
oracle4engineer
PRO
0
6.5k
障害対応指揮の意思決定と情報共有における価値観 / Waroom Meetup #2
arthur1
5
490
rootlessコンテナのすゝめ - 研究室サーバーでもできる安全なコンテナ管理
kitsuya0828
3
390
Featured
See All Featured
Rebuilding a faster, lazier Slack
samanthasiow
79
8.7k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
KATA
mclloyd
29
14k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
44
6.8k
Automating Front-end Workflow
addyosmani
1366
200k
Building Flexible Design Systems
yeseniaperezcruz
327
38k
Producing Creativity
orderedlist
PRO
341
39k
VelocityConf: Rendering Performance Case Studies
addyosmani
325
24k
Java REST API Framework Comparison - PWX 2021
mraible
PRO
28
8.2k
Statistics for Hackers
jakevdp
796
220k
Scaling GitHub
holman
458
140k
Learning to Love Humans: Emotional Interface Design
aarron
273
40k
Transcript
YARD with RBS Syntax Omotesando.rb #87 2023/07/06 1
ࣗݾհ • ໊લ: ਖ਼ಙ (aka: ਆ) • ձࣾ: - •
GitHub: @sinsoku (ը૾ӈ্) • Twitter: @sinsoku_listy (ը૾ӈԼ) • ͖ͳݴޠ: Rust • Railsྺ: 8͘Β͍ 2
ઌ݄͔ΒRBSΛ͍࢝Ί·ͨ͠ 3
͖͔͚ͬ: MedPeerͷϒϩά 4
ࣾͷ૯ҙ: ܕͷԸܙΛड͚͍ͨ ʢͨͩ͠ܕࣗͰॻ͖ͨ͘ͳ͍ʣ 5
RBSಋೖͷํ • *.rbs ࣗಈੜ͢Δ • rbs collection • rbs prototype
• sord1 ʢYARD -> rbsʣ • gemͷෆͯ͠Δܕఆٛ࠷খݶ͚ͩ༻ҙ 1 https://github.com/AaronC81/sord 6
ಋೖͷৄࡉׂѪʢͨͿΜϒϩάॻ͘ʣ 7
͔͜͜Βຊ 8
Α͋͘ΔYARDͷྫ class User # @param item [Item] ΞΠςϜ # @param
amount [Integer] ྔ # @param coupon [Coupon] Ϋʔϙϯ # @return [Boolean] ߪೖͷޭ/ࣦഊ def buy(item, amount, coupon = nil); end end 9
୭େͨ͠આ໌Λॻ͍͍ͯͳ͍ 10
ීஈܕ͚ͩॻ͚ेͰʁ 2 2 େࣄͳ෦ʹઆ໌Λॻ͚͘ͲɺܕͱҾ໊Ͱेͳέʔεଟ͍ɻ 11
ͦΜͳgemΛ࡞Γ·ͨ͠ 12
! yard-sig https://github.com/sinsoku/yard-sig 13
͜Ε͕ class User # @param item [Item] ΞΠςϜ # @param
amount [Integer] ྔ # @param coupon [Coupon] Ϋʔϙϯ # @return [Boolean] ߪೖͷޭ/ࣦഊ def buy(item, amount, coupon = nil); end end 14
͜͏ͳΔ class User # @!sig (Item, Integer, ?Coupon) -> bool
def buy(item, amount, coupon = nil); end end 15
yard-sig • YARDϓϥάΠϯ • yard doc --plugin sig Ͱ༻Մ3 •
จ๏RBS Syntaxͱಉ͡ • ෦Ͱ @param @return ͳͲͷλάʹม 3 .yardopts ʹ --plugin sig Λࢦఆ͢Δͱָ 16
σϞʢϦϦʔε࡞ۀʣ 17
͓·͚: Rails v7.0.5ͷ has_one ͕ਏ͍ 18
ͷཁ طଘϨίʔυ͕͋Δͱ͖ͷ create_association ͷڍಈ͕มΘΔɻ • v7.0.4: save(validate, INSERT) -> destroy(DELETE)
• v7.0.5: destroy(DELETE) -> save(validate, INSERT) v7.0.4·ͰผʑͷτϥϯβΫγϣϯͰɺόϦσʔγϣϯʹࣦഊ͠ ͯطଘϨίʔυ͕আ͞Ε͍ͯͨɻ 19
Өڹ͕͋Δέʔε 1. Uniquness Validator4 2. UNIQ constraint 3. DBґଘͷCustom Validation
• ྫ: ϨίʔυΛ࡞͔ͯ͠Β10Ҏ 4 v7.0.4ͰόάͬͯΔͷͰɺجຊతʹؾʹ͢Δඞཁ͕ͳ͍ͣɻ 20
rails/rails#48643 21