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
introduction_scriptor_gem.pdf
Search
hatsu
January 09, 2025
Programming
1
98
introduction_scriptor_gem.pdf
hatsu
January 09, 2025
Tweet
Share
More Decks by hatsu
See All by hatsu
約9000個の自動テストの 時間を50分->10分に短縮 Flakyテストを1%以下に抑えた話
hatsu38
24
16k
Just a Rails Patch Update
hatsu38
2
650
Dive into MaintenanceTasks
hatsu38
1
130
GitHub Actions is Fun
hatsu38
1
150
Other Decks in Programming
See All in Programming
バックエンドNode.js × フロントエンドDeno で開発して得られた知見
ayame113
5
1.3k
エンジニア未経験が最短で戦力になるためのTips
gokana
0
210
NestJSのコードからOpenAPIを自動生成する際の最適解を探す
astatsuya
0
190
英語文法から学ぶ、クリーンな設計の秘訣
newnomad
1
270
安全に倒し切るリリースをするために:15年来レガシーシステムのフルリプレイス挑戦記
sakuraikotone
5
2.3k
S3静的ホスティング+Next.js静的エクスポート で格安webアプリ構築
iharuoru
0
190
php-fpm がリクエスト処理する仕組みを追う / Tracing-How-php-fpm-Handles-Requests
shin1x1
5
820
Node.js, Deno, Bun 最新動向とその所感について
yosuke_furukawa
PRO
6
3k
コンテナでLambdaをデプロイするときに知っておきたかったこと
_takahash
0
150
List とは何か? / PHPerKaigi 2025
meihei3
0
550
PsySHから紐解くREPLの仕組み
muno92
PRO
1
520
ベクトル検索システムの気持ち
monochromegane
30
8.9k
Featured
See All Featured
The MySQL Ecosystem @ GitHub 2015
samlambert
251
12k
We Have a Design System, Now What?
morganepeng
51
7.5k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
A Philosophy of Restraint
colly
203
16k
Art, The Web, and Tiny UX
lynnandtonic
298
20k
A Modern Web Designer's Workflow
chriscoyier
693
190k
Large-scale JavaScript Application Architecture
addyosmani
511
110k
Side Projects
sachag
452
42k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
12
610
It's Worth the Effort
3n
184
28k
Mobile First: as difficult as doing things right
swwweet
223
9.5k
The Power of CSS Pseudo Elements
geoffreycrofte
75
5.7k
Transcript
Rails8 scripts generatorͷհ ͱͦΕʹ·ͭΘΔGemΛ࡞ͬͨ Omotesando.rb #104 @hatsu_38 2025/01/09
ࣗݾհ • Twitter: @hatsu_38 • GitHub: @hatsu38 • SHE Inc.
• Rubyྺ 5 = ΤϯδχΞྺ • React.js / TypeScript / GitHub Actions • Ruby͕Ұ൪͖
Rails8͔ΒՃ͞Εͨ scriptϑΥϧμ͍ͬͯ·͢ʁ
None
https://discuss.rubyonrails.org/t/is-there-any-of fi cial-way-to-organize-one-off-scripts/74186
OneTime(Ұ͖Γ)ͷscriptͷஔ͖ͷ՝ • ࠓ·ͰRailsެࣜͰఏڙ͍ͯ͠ΔOneTimeઐ༻ͷscriptͷஔ͖ͳ͔ͬͨ • OneTimeͷεΫϦϓτlib/tasks/* ʹஔ͍ͯӡ༻͞Ε͍ͯΔέʔεଟ͍ • migrateͷͨΊͳΒdata_migrate gemmaintenance_tasks gemͷखஈ͋Δ
• ͨͩlib/tasks/*ʹԿ࣮ߦ͞ΕΔScriptͳͲઃஔ͞Ε͍ͯΔ
OneTime(Ұ͖Γ)ͷscriptͷஔ͖Ͳ͕͍͍͜ʁ • Ұ͔͠Θͳ͍scriptɺෳճ࣮ߦ͠ͳ͍͜ͱΛ໌ࣔ͢ΔͨΊʹผϑΥϧμʹ͓͍ ͓͖͍ͯͨ • DHHͷBasecampͰɺscript/migrate/* ͷΑ͏ͳϑΥϧμʹཧ͍ͯ͠Δ • ଞʹscript/benchmarks/*
script/ops/* ͷΑ͏ͳͷΛ࡞ͬͯͨΓ͢Δ
https://github.com/rails/rails/pull/52335
bin/rails generate script my_script • script/my_script.rb ͕ੜ͞ΕΔ • cat script/my_script.rb
• த͍͢͝γϯϓϧ
scriptϑΥϧμͷ͍ํͷྫ • ruby script/my_script.rb "1" "
[email protected]
"
script folderͷഎܠ͍ํҎ্
αʔόʔʹೖ࣮ͬͯߦͱ͔ݏͩͳ͊💭
࣮ߦ݁ՌཤྺͰͱ͓͖͍ͬͯͨͳ💭
GemΛ࡞ͬͯΈͨ💡 https://github.com/hatsu38/scriptor
scriptϑΥϧμʹ͋ΔϑΝΠϧҰཡΛϒϥβͰӾཡͰ͖Δ
scriptϑΥϧμʹ͋ΔϑΝΠϧΛϒϥβͰӾཡͰ͖Δ
ϒϥβ͔Βscriptͷίʔυͷ࣮ߦ͕Ͱ͖Δ/࣮ߦཤྺ͕Δ
None
scriptorͷಋೖ • bundle add scriptor • bin/rails generate scriptor:install •
con fi g/routes.rbʹ `mount Scriptor::Engine => “/scriptor"` ͕Ճ͞ΕΔ • db/migrations/****_create_scriptor_executions.scriptor.rb ͕ੜ͞ΕΔ
Rails8 scriptϑΥϧμͷհͱ Scriptor gemͷհͰͨ͠💡