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
RailsとYesodの比較
Search
Fujimura Daisuke
April 21, 2012
Programming
3
2.5k
RailsとYesodの比較
Fujimura Daisuke
April 21, 2012
Tweet
Share
More Decks by Fujimura Daisuke
See All by Fujimura Daisuke
庭と負債
fujimura
2
270
AIの時代で我々はどのようにコードを書くのか
fujimura
3
770
SaaSを作るという仕事について
fujimura
12
5.7k
一文字エイリアスのすすめ
fujimura
0
310
現役CTOが語る!RubyKaigiの楽しみ方
fujimura
0
1.2k
いかにして文系新卒エンジニアが「大きな問い」を大事にするCTOになったのか
fujimura
2
660
Kaigi on Rails 2022 - 既存Railsアプリ攻略法 CTOが見ること・やること・考えること
fujimura
14
3.9k
SimpleDelegator活用のご提案
fujimura
0
1.5k
入門 名前
fujimura
23
13k
Other Decks in Programming
See All in Programming
Click-free releases & the making of a CLI app
oheyadam
2
110
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
110
エンジニアとして関わる要件と仕様(公開用)
murabayashi
0
280
受け取る人から提供する人になるということ
little_rubyist
0
230
Quine, Polyglot, 良いコード
qnighy
4
640
Kaigi on Rails 2024 〜運営の裏側〜
krpk1900
1
190
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
100
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
110
Content Security Policy入門 セキュリティ設定と 違反レポートのはじめ方 / Introduction to Content Security Policy Getting Started with Security Configuration and Violation Reporting
uskey512
1
520
Creating a Free Video Ad Network on the Edge
mizoguchicoji
0
110
ペアーズにおけるAmazon Bedrockを⽤いた障害対応⽀援 ⽣成AIツールの導⼊事例 @ 20241115配信AWSウェビナー登壇
fukubaka0825
6
1.8k
【Kaigi on Rails 2024】YOUTRUST スポンサーLT
krpk1900
1
330
Featured
See All Featured
Building an army of robots
kneath
302
43k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Practical Orchestrator
shlominoach
186
10k
The Pragmatic Product Professional
lauravandoore
31
6.3k
Optimizing for Happiness
mojombo
376
70k
Building Adaptive Systems
keathley
38
2.3k
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
250
21k
Into the Great Unknown - MozCon
thekraken
32
1.5k
RailsConf 2023
tenderlove
29
900
A better future with KSS
kneath
238
17k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
26
2.1k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
4
370
Transcript
RailsͱYesodͷൺֱ ౻ଜେհ Sunday, April 22, 12
ࣗݾհ • ౻ଜେհ • גࣜձࣾAiming • @ffu_ • http://fujimuradaisuke.com Sunday,
April 22, 12
ࣗݾհ (2) Rubyͱࢲ • ੲABAPerͩͬͨɻ·ͱͳݴޠ͕Γͨ͘ͳΓRubyʹస • ͔Ε͜Ε3͘Β͍ϑϧλΠϜͰRailsͷࣄΛͯ͠Δ • Railsίϛολ @a_matsuda
ࣄͯ͠Rails෦ʹ͚ͬ͜͏ৄ͘͠ͳͬͨ • WEB+DB PRESSͷRails3ಛूΛͪΐͬͱखͬͨ • Railsͷ࡞ऀɺDHHͱ൴ͷಇ͘37signalsͷϑΝϯ Sunday, April 22, 12
ࣗݾհ (3) Haskellͱࢲ • The Little SchemerͰؔϓϩάϥϛϯάΛΔ • Seven Languages
in Seven WeeksͰHaskellΛΔ • ελʔτHaskellͰຊ֨తʹHaskell͕͖ʹͳΔ • ݱࡏɺձࣾͰYesodΛࢼݧతʹಋೖத Sunday, April 22, 12
ΞδΣϯμ • Railsʹ͋ͬͯYesodʹͳ͍ͷհ • Rails͍͔ΒݟͨYesod(ͱHaskell)ͷ͍͍ͱ͜Ζ • Yesodʹཉ͍͠ͷհ Sunday, April 22,
12
Yesodʹͳ͍ͷ(1) σϓϩΠπʔϧ • RailsʹCapistranoͱ͍͏σϓϩΠࣗಈԽπʔϧ͕͋Γ·͢ɻ • $ cap deploy ͰσϓϩΠ •
$ cap deploy:rollbackͰલճσϓϩΠͨ͠ίʔυʹϩʔϧόοΫ • ͦͷଞɺSSHͰೖͬͯσϓϩΠ࣌ʹߦ͏࡞ۀͷࣗಈԽҰൠ͕ՄೳͰ͢ɻ • https://github.com/capistrano/capistrano/wiki/2.x-Getting-Started Sunday, April 22, 12
Yesodʹͳ͍ͷ(1) σϓϩΠπʔϧ • cabal-dev ΛͬͨΒͰ͖·ͨ͠… • ͨͩ͠ຖճશґଘϥΠϒϥϦΛΠϯετʔϧ͢ΔͷͰ͕͔͔࣌ؒΔ • ͦͦHaskellerͱͯ͠ʮRubyͷπʔϧΛ͏ʯͰOKͳͷ͔ʁ Sunday,
April 22, 12
Yesodʹͳ͍ͷ(2) CRUDͷੜ • RailsscaffoldͰCRUD͕Ͱ͖Δίʔυ͕ੜ͞Ε·͢ɻ • ͜ͷҐͷίʔυ͕ ੜ͞ΕΔ • RailsྲྀͷRESTfulͳϧʔςΟϯάʹԊͬͨίʔυ͕ੜ͞ΕΔͷͰɺͦΕΛݩ ʹ։ൃ͍ͯ͠ΕɺࣗવͱRailsతͳΘ͔Γ͍͢ίʔυʹͳΓ·͢ɻ
• ࣗવͱRails wayͰ։ൃ͢Δ͜ͱʹͳΔͷͰɺ·ͳ͍ͰࡁΉͱ͍͏རɻ • YesodͰ·ͣ։ൃΛਐΊΒΕΔఔʹscaffoldͰίʔυΛੜͯ͠΄͠ ͍ɻ Sunday, April 22, 12
Yesodʹͳ͍ͷ(3) RSpec • ΄΅σϑΥϧτ࠾༻͞ΕͯΔςετϑϨʔϜϫʔΫɻ • ಈ࡞ݕূͰͳ͘ιϑτΣΞͷʮৼΔ͍ʯΛܾΊΔͨΊͷϥΠϒϥϦ • http://jp.rubyist.net/magazine/?0021-Rspec ʹ֓ཁ͕·ͱ·ͬͯ·͢ɻ •
rspec-railsͱ͍͏ϥΠϒϥϦͰRailsͷςετ͕ܹ͘͠ੜ࢈తʹͳΓ·͢ɻ • ͦͷଞपลϥΠϒϥϦଟɻ Sunday, April 22, 12
ͳͥRSpec͕ཉ͍͔͠ • RSpecઃܭπʔϧͱͯ͠ຊʹ༏लɻ·ͣSpecΛεέονײ֮Ͱॻ͍ͯҰ ୴ઃܭΛจষԽ͢ΔͱɺAPIશମ͕ݟ௨ͤΔΑ͏ʹͳΓ·͢ɻ͜͜Ͱઃܭͷྑ ͠ѱ͠Λݕ౼Ͱ͖ΔͷૉΒ͍͠Ͱ͢ɻ ͜Μͳ۩߹ʹઃܭΛઌʹॻ͘ ࣮ߦ͢Δͱ“PENDING” Sunday, April 22,
12
ͳͥRSpec͕ཉ͍͔͠ • request specཉ͍͠Ͱ͢ɻrequest specSeleniumͳͲͰ࣮ࡍʹΞϓϦέʔ γϣϯΛಈ͔ͯ͠ɺϑϩϯτΤϯυ͔ΒΞϓϦέʔγϣϯΛݕࠪ͢Δ Έɻclick_link(‘#submit-button’)ͱ͍ͬͨײ͡ͰखಈͰ͍ͯͨ͠ಈ࡞֬ೝΛࣗ ಈԽͰ͖·͢ɻ • ਅʹॻ͘ͱɺ࣮ߦՄೳͳड͚ೖΕςετܭըॻʹͳΓ·͢ɻ
• ෳͷػೳΛ·͙ͨγφϦΦςετ͕ॻ͖͍͢ɻ • ͜͜ɺRails͜ͷϨΠϠʔ·Ͱςετ͢Δͷ͕σϑΥϧτɻ Sunday, April 22, 12
ͳ͍ͷ(3) RSpec • ͪͳΈʹHaskellͰhspecͱ͍͏RSpecతͳϥΠϒϥϦ͕͋Γ·͢ɻ • http://hspec.github.com/ • ࠷ۙ1.1ʹͳΓ·ͨ͠ʂ • ͔͠͠ɺdescribe/contextͷೖΕࢠͰ͖ͳ͍͠ɺsetup/teardownແ͍͠ɺ
RSpecʹࣅͨߏจͷxUnitͱ͍͏ͷ͕࣮…ɻ • ࠓޙʹظɻ Sunday, April 22, 12
Rails͍͔ΒݟͨYesod(ͱHaskell)ͷ͍͍ͱ͜Ζ • NullPointerException͕ແ͍ʂ • ܕΛ͋ΘͤΔͱ͍͍ͩͨظ௨Γʹಈ͘ • undefinedΛ͏ͱςετίʔυͳ͠ͰBDDͬΆ͍͜ͱ͕Ͱ͖Δ • ى͜Γ͏Δ͜ͱΛશ෦ߟྀ͠ͳ͍ͱ͍͚ͳ͍ͷͰɺఆΕͷόά͕ͳ͘ͳ Δ
• ΞυϗοΫଟ૬͕RubyͷMix-inͱࣅ͍ͯΔͷͰ͠Έ͍͢ Sunday, April 22, 12
Yesodʹཉ͍͠ͷ(1) • ϏδωεϩδοΫΛهड़͢ΔͨΊͷϥΠϒϥϦ • PersistentΑΓ͏ͪΐͬͱநߴ͍هड़͕͍ͨ͠Ͱ͢ɻ • RailsͰActiveRecordͰϢʔβʔͷϝϯλϧϞσϧʹ͍ۙܗͷදݱ͕Ͱ͖ ͨɻ • ͱ͍ͬͯORϚούʔΛ࡞Δͷҧ͍·͢ΑͶɻDCI
͕ࢀߟʹͳΔؾ͕͠ ͍ͯ·͢ɻ • ࡞ͬͯΈ͍ͨͰ͢ɻ Sunday, April 22, 12
Yesodʹཉ͍͠ͷ(2) • Yesod way • RailsʹϨʔϧ͕͋ͬͯɺͦΕʹΕΔɻ • DHHᐌ͘ʮConstraints are liberatingʯ
• ࠓͷͱ͜ΖYesodʹϨʔϧ͕ݟͨΒͳ͍ɻ Sunday, April 22, 12
͓ΘΓ • ए͍ϥΠϒϥϦͳͷͰɺࠓޙʹظͰ͢ Sunday, April 22, 12
༨ஊ • ςϯϓϨʔτΤϯδϯͷ…ʁ • ձࣾͰ࡞ͬͯΔͷJSON APIͳͷͰɺ৮ͬͯͳ͍ΜͰ͢ɻ • ͠ΔͳΒmustacheΛ͏ͱࢥ͍·͢ɻShakespearean Templatesϑ ϩϯτΤϯυͷਓͱͷίϥϘϨʔγϣϯ͕ͦ͠͏ͳҹͰ͢ɻ
• scottyؾʹͳͬͯ·͢ • Web API࡞ΔͷͰ͋Εͬͪ͜ͷ΄͏͕खܰͦ͏ Sunday, April 22, 12